Вы находитесь на странице: 1из 11

Linked Representation Of

Graphs And
Operations On Graphs
Presented By :-

Rahul Khurana
(A1000713044)
MCA 2
nd
Sem.
Let Us Know About Graph
A graph G consists of a set V of
vertices(nodes) and a set of edges (arcs).
G=(V,E)
V is a finite and non empty set of vertices.
E is a set of pairs of vertices called edges.
Therefore,
V(G),read as V of G , is a set of vertices.
E(G),read as E of G , is a set of edges.

Real Life Example Of A Graph :-
Delhi Metro Route Map
A Maze :-
Each corner
is a vertex
and line
between two
corners is an
edge.
Types Of Graph :-
(a) Directed Graph (b) Undirected Graph
Some Basic Terminologies :-
Adjacent Vertices.
Path.
Cycle.
Connected Graphs.
Degree.
Complete Graph.
Weighted Graph.

Representation Of Graph :-
Adjacency Matrix :
For N vertices an adjacency matrix is an N x N
array A such that
A[i][j] = 1 if there is an edge E(i,j)
= 0 otherwise

For an undirected graph, A[i][j] = A[j][i]

For weighted graphs,
A[i][j] = weight of the edge, if there
is an edge E(i,j)
= a constant representing no
edge (Eg., a very large or very small value)


Example Of An Adjacency Matrix:-
1
3
6
2
4
5
Linked Representation Of Graph

Adjacency List Representation :-

Adjacency matrix representation consume a lot
of memory . If the graph is complete or almost
complete(i.e. contains most of the edges
between the vertices), then this representation is
good to use. But if there are very few edges as
compared to number of vertices, it will
unnecessarily consume extra space. Adjacency
list can handle this situation very optimally.

Every vertex has a LINKED LIST of the
vertices it is connected with.

Example Of An Adjacency List :-
1
3
6
2 4 5
Different Operations On Graph:-
Creation.
Insertion.
Deletion.
Display.
Traversal.

Вам также может понравиться