fix bug

Wrong Code below:
delete edge; // after this edge->next can be any value.
edge = edge->next;
Fixed it.