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

Java Program on Queues using Arrays

            class QueuesArrays { public static void main(String args[] )throws IOException { BufferedReader br=new BufferedReader (new InputStreamReader(Syste...

Java Program on Output Restricted DeQueue

class Node { int n; Node prev,next; } class ORD { public static void main(String args[ ])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader (System.in()); N...

Explain about Notations in Data Structures?

Evaluating expressions: let Q be an arithmetic expression involving both operator &operands. Operator: operator is a symbol that perform a particular tasks. High priority { 1 }, c, {-----...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item