Fix bugs in getEdges and addEdge