Representation of a Graph ?


Representation of a  graph is the way of storing data values in  memory location as graph data structure. There are two types  of graph representation techniques.

1. Adjacency matrix representation.

2. Adjacency list representation

Adjacency Matrix Representation :

According to this representation graph is stored using arrays in memory. This representation uses two types of arrays for storing data in memory.

    1.    An 1 – D array of size ‘n’ for storing all vertices in a graph . Here ‘n’ is the no. of vertices in  a graph.

    2.    Use 2 – D array of size(n,m) for storing information about edges b/w vertices . In this 2 – D array we have to enter either zero or one. If there is an edge between two vertices then one is placed in corresponding cell otherwise zero is placed.


graph reprasentation














10 :V
V ={ 10 , 20, 30, 40, 50}
T={(10, 20),(10, 30),(10, 50),(50 , 40),(20 , 50),(30 , 40),(50 , 30),(40 , 20)}

Adjacency list representation :

In this representation the vertices of the graph are represented as linked lists of nodes with one of the vertex as the starting vertex. Each vertex again has a different linked list connecting to some other vertices which are having this vertices. In first list of vertices , every node contains two links. In second list of edges every node contains one link this is explained by the following.

graphreprasentation2



Related

Data Structures 7228388896034472143

Post a Comment

emo-but-icon

item