During this session you will learn about:
Adjacency matrix and lists.
Breadth search and depth search on graphs.
Some important functions and definitions regarding graphs.
A graph is a collection of vertices and edges, G =(V, E)where V is set of vertices and E is set of edges. An edge isdefined as pair of vertices, which are adjacent to each other.
When these pairs are ordered, the graph is known as
These graphs have many properties and they are veryimportant because they actually represent many practicalsituations, like networks. In our current discussion we areinterested on the algorithms which will be used for most ofthe problems related to graphs like to check connectivity, thedepth first search and breadth first search, to find a pathfrom one vertex to another, to find multiple paths from onevertex to another, to find the number of components of thegraph, to find the critical vertices and edges.The basic problem about the graph is its representationfor programming.
6.2. Adjacency Matrix and Adjacency lists
We can use the adjacency matrix, i.e. a matrix whose rowsand columns both represent the vertices to represent graphs.In such a matrix when the i
column element is 1, wesay that there is an edge between the i
vertex. Whenthere is no edge the value will be zero. The otherrepresentation is to prepare the adjacency lists for eachvertex.Now we will see an example of a graph and see how anadjacency matrix can be written for it. We will also see theadjacency relations expressed in form of a linked list.
Data Structures with ‘c’