Adjacency Matrix

A graph is represented by a matrix indexed by nodes.

There is an entry in row N1 column N2 iff there is an edge from N1 to N2. In a weighted graph, the entry contains the weight.

        

For a directed graph: the successors of node N are stored in row N, its predecessors are found in column N.

        
Efficient to add/delete nodes/edges, but requires N*N space. We would prefer O(N + E).