Change the routine of insertEdge so that no vertex and edge are duplicated