toGraphSortedByEdges