Use adjacency list instead of edge list and then converting to an adjacency list.