Graph Data Strucutre

Graph is a pictorial representation of the set of the object which is connected with the link. The individual object in graph is represented as Vertices, and the connecting links called Edges.

The representation of the graph in mathematical terms G{V, E}, where V is a set of vertices and E is the set of edges.
 
Pictorial representation of Graph
Here, V={A,B,C} is set of vertices and E={AB,BC,CA} is a set of edges.

A graphs are of two types as given below:
  1. Directed Graph
  2. Un-directed Graph
  3. Weighted Graph
(a) Un-directed Graph, (b) Directed Graph (c) Weighted Graph
The two most common representation of the Graph are:
  1. Adjacency Matrix
  2. Adjacency List
Adjacency Matrix of the Graph is a product of  VxV, where V is the set of the vertices. To create the adjacency matrix, the common edge between the vertices are called adjacent vertices. For adjacent vertices we assign 1 and for non-adjacent vertices assign 0. 



Adjacency Matrix 
                                                    0   1   2   3   4
                                          
                                         0         0   1   0   0   1
                                         1         1   0   1   1   1
                                         2         0   1   0   1   0
                                         3         0   1   1   0   1
                                         4         1   1   0   1   0
Adjacency List
    
In this representation,  the array of  linked list is used where size of the array is equal to number of vertices.



Comments

Popular posts from this blog

Types of Algorithm and Its Complexity Analysis

First Step of Problem Solving Using Data Structure and Algorithm

Asymptotic Notations