Q. Describe the representations of graph. Represent the graph which is given to us using any two methods
Ans:
The different ways by which we can represent graphs are:
Adjacency list representation: In this representation of graph there is an array Adj of |V| lists, one for each vertex in V. For each uεV, the adjacency list Adj[u] contains all the vertices v such that there is an edge (u,v)ε E that is Adj[u] consists of all the vertices adjacent to u in G. The vertices in each and every adjacency list are stored in an arbitrary order. The adjacency list representation of given graph is shown in the following figure:
Adjacency Matrix representation: This representation consists of the |V|*|V| matrix
A=(aij) such that
The adjacency matrix representation of given graph is as follows