Representing graphs for algorithms
Adjacency matrix A[0..n-1, 0..n-1],
where V={0,1,..., n-1}.
A[i,j] = 1 if (i,j) in E
0 otherwise
Adjacency lists:
L[0..n-1] array of lists where L[i] = {v | (i,v) in E},
the set of neighbors of i.
Previous slide
Next slide
Back to first slide
View graphic version