3. What is a Graph?
•
•
•
A graph G = (V,E) is composed of:
V: set of vertices
E: set of edges connecting the vertices in V
An edge e = (u,v) is a pair of vertices
Example:
a b
c
d e
V= {a,b,c,d,e}
E= {(a,b),(a,c),
(a,d),
(b,e),(c,d),(c,e),
(d,e)}
10. Types of graph
finite Graph
A graph is said to
be finite where the
number of vertices
and edges are finite
in number
A
C D
B
E
11. Types of graph
Infinite Graph
In an infinite graph
the number of
vertices and
numbers of edges is
infinite
A B
C
E
D
F
12. Types of graph
Trivial Graph
The graph is said
to be trivial if there
is only a single
vertex without any
edges
A
13. Types of graph
Simple Graph
A graph is said to
be simple if there is
only one and one
edge between each
vertex
A
C D
B
14. Types of graph
Null Graph
The graph is said
to be a null graph If
there are only
vertices exits, not
edges
A B
C D
15. Types of graph
Complete Graph
The graph is a complete
graph where each vertex
must be connected with
other vertices using the
edges
A
C D
B
16. Types of graph
Directed Graph
The directed graph is a
graph where each edge
has a direction
associated with it
A
C D
B
17. Types of graph
Dis connected
Graph
A graph is said to be
disconnected where
each pair in the graph is
not connected
A
C
B
D
E
F
18. Graph representaion in data structure
There are two types of graph representation
1). Adjacency matrix representation
2). Adjacency list representation
1). Adjacency matrix representation
An adjacency matrix is used to represent adjacent
nodes in the graph. Two nodes are said to be adjacent
if there is an edge connecting them. We represent
graph in the form of matrix in Adjacency matrix
representation. For a graph G, if there is an edge
between two vertices a and b then we denote it 1 in
matrix. If there is no edge then denote it with 0 in
19. Continue
For Un-Directed graph
Mi,j = 1 if there is an edge between vertex i and j.
The direction does not matter here.
and Mi,j = 0 if there is no edge between vertex i and
j.
Mi,j not equal to Mj,i
Matrix Representation of Above Graph
22. Adjacency list representation
An adjacency list is another way to represented a
graph in the computer’s memory. This structure
consists of a list of all nodes in G. Every node is in
turn linked to its own list that contains the names of
all other nodes that are adjacent to it.