changed mapEdges to also return a Graph