Reputation: 21
Suppose a directed graph has a million nodes, most nodes have only a few edges, but a few nodes have hundreds of thousands of edges.
To represent this graph, I used an adjacency matrix but, as it turns out, its running time is O(n2) and for adjacency matrix random access is not efficient.
How can I represent this graph in an efficient way that could solve both random access and works faster?
Upvotes: 2
Views: 525