appendChain method
Implementation
VertexList appendChain(VertexNode vertex) {
if (head == null) {
head = vertex;
} else {
tail!.next = vertex;
}
vertex.prev = tail;
// ensure that the 'tail' reference points to the last vertex of the chain
while (vertex.next != null) {
vertex = vertex.next!;
}
tail = vertex;
return this;
}