optimize Method insertEdge()