Adjacency list representation
An Adjacency list representation of Graph G = {V, E} contains an array of adjacency lists mentioned by adj of V list. For each of the vertex u?V, adj[u] contains all vertices adjacent to u in the graph G.
Consider the graph of Figure.
Figure: A Graph
Given is the adjacency list representation of graph of above Figure:
adj [1] = {2, 3, 5}
adj [2] = {1, 4}
adj [3] = {1, 4, 5}
adj [4] = {2, 3, 5}
adj [5] = {1, 3, 4}
An adjacency matrix representation of a Graph G=(V, E) is a matrix
The adjacency matrix for the graph of Figure is following:
1
2
3
4
5
0
Observe that the matrix is symmetric along the main diagonal. If we described the adjacency matrix as A and the transpose as A^{T }, then for undirected graph G as above, A = A^{T}.