test legalizeEdge