insertNode function
Implementation
Node insertNode(int i, double x, y, Node? last) {
Node p = Node(i, x, y);
if (last == null) {
p.prev = p;
p.next = p;
} else {
p.next = last.next;
p.prev = last;
last.next?.prev = p;
last.next = p;
}
return p;
}