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.
Here, V={A,B,C} is set of vertices and E={AB,BC,CA} is a set of edges.
The two most common representation of the Graph are:
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 |
A graphs are of two types as given below:
- Directed Graph
- Un-directed Graph
- Weighted Graph
(a) Un-directed Graph, (b) Directed Graph (c) Weighted Graph |
- Adjacency Matrix
- 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
Post a Comment