Sei sulla pagina 1di 29

Graph Theory


Submitted To: Presented By:
Dr. Amit Chhabra Deepinder Singh (CO18319)
Ganga Singh (CO18321)
Tanveer Singh (CO18353)
Index

1. Regular Graph
2. Complete Graph
3. Bipartite Graph
4. Planar Graph
5. Graph Traversal Techniques
1. Breadth First Search
2. Depth First Search
Regular Graph
1.

A graph where each vertex has the same degree
is called a regular graph.

2. A directed graph is said to be regular directed


graph if it satisfies the condition that the in-
degree and out-degree of each vertex are equal to
each other.

3. A regular graph with vertices of degree k is called


a k‑regular graph.
Undirected Regular Graph

Cubic graph

Cycle
graph
Directed Regular Graph

In-degree=1 In-degree=1
Out-degree=1 Out-degree=2
Complete Graph

1. A graph in which every pair of distinct vertices  is
connected by a unique edge.

2. For m number of vertices there are m(m-1)/2


edges in a complete graph.

3. The complete graph on n vertices is denoted by Kn.

4. The complete graph Kn is strongly regular for


any n.
Why it is denoted by Kn ?

for n vertices
number of edges =n(n-1)/2

(n-1)+(n-2)+…+(n-n)
= n*n –(1+2+…+n) 
= n² -n(n+1)/2
= n(n-1)/2
K1 K2 K3

K4 K5 K6
What is a Bipartite Graph?

 A simple graph G is called bipartite if its vertex set V can be
partitioned into two disjoint sets V1 and V2 such that every edge
in the graph connects a vertex in V1 and a vertex in V2 (so that
no edge in G connects either two vertices in V1 or two vertices
in V2).
 When this condition holds, we call the pair (V1, V2) a bipartition
of the vertex set V of G.
Complete Bipartite Graph

 A bipartite graph where every vertex of set V1 is
joined to every vertex of set V2 is called as complete
bipartite graph.
 A complete bipartite graph Km,n contains mn edges.
Bipartite Graph Properties

 It does not contain any odd-length cycles.
 Bipartite graphs are 2-colorable.
 Every sub graph of a bipartite graph is itself
bipartite.
 Maximum possible number of edges in a bipartite
graph on ‘n’ vertices = (1/4) x n2.
 The degree sum formula for a bipartite graph states
that:
Some Other Properties

 If the two subsets have equal cardinality (|U|=|V|),
then is called a balanced bipartite graph.
 If all vertices on the same side of the bipartition have
the same degree, then it is called biregular.
 Every planar graph whose faces all have even length is
bipartite.
 A graph with no edges is also Bipartite.
 Every tree is bipartite.
 There does not exist a perfect matching for a bipartite
graph with bipartition X and Y if |X| ≠ |Y|.
What is a Planar Graph?

 Planar graph is a graph that can be drawn in a plane
such that none of its edges cross each other.
Regions of Plane

 The planar representation of the graph splits the plane into
connected areas called as Regions of the plane.
 Each region has some degree associated with it given as-
o Degree of Interior region = Number of edges enclosing that
region
o Degree of Exterior region = Number of edges exposed to
that region

Here, this planar graph splits the plane into 4 regions- R1,
R2, R3 and R4 where-

Degree (R1) = 3
Degree (R2) = 3
Degree (R3) = 3
Degree (R4) = 5
Properties of Planar Graph

 Sum of degrees of all the vertices = 2 x Total number of edges in
the graph
 Sum of degrees of all the regions = 2 x Total number of edges in
the graph
  If G is a connected planar simple graph with ‘e’ edges, ‘v’ vertices
and ‘r’ number of regions in the planar representation of G, then:
o r = e – v + 2 (Euler’s Formula)
 If G is a connected planar simple graph with e edges and v
vertices, where v ≥ 3, then e ≤ 3v − 6.
 If G is a connected planar simple graph, then G has a vertex of
degree not exceeding five.
Graph Traversal Techniques

 What is traversal?
 Traversal is a process to visit every element/record/node in
a list of records once.

 What is Graph Traversal?


 Graph traversal is the process of exploring a graph to find
all the possible paths, vertices or edges in that graph.
 The graph traversal is also used to decide the order of
vertices visited in the search process.
 A graph traversal finds the edges to be used in the search
process without creating loops.
Continued ...

A E

B D F

C G
There are two methods used to transverse a graph:
1) BFS (Breadth First Search)
2) DFS (Depth First Search)
Breadth First Search(BFS)


BFS is a graph traversal technique that begins at the root node
and explores all the neighbouring nodes of every adjacent node.

BFS traversal of a graph produces a spanning tree as final result
which is a graph without loops.

Queue data structure with maximum size of total number of
vertices in the graph is used to implement BFS traversal.

BFS always returns the shortest path (the one with the fewest
edges) between the start and the end vertices.

There can be many possible ways for breadth first traversal in a
graph.
Example

Consider a graph having 6 vertices

A B C
G

D E F

Step 1 : Select vertex A as the starting point (any vertex can be selected as
a starting point if parent node is not given)

A B C
Vertices Visited:
G A

D E F
Step 2 : Visit all the adjacent vertices of A which are not visited i.e (B,E,D)
3
A B C
Vertices Visited:
2
1 G
A,D,E,B

D E F

Step 3 : Visit all the adjacent vertices of D which are not visited. Both A
and E has already been visited.

3
A B C
Vertices Visited:
2
1 G A,D,E,B

D E F
Step 4 : Visit all the adjacent vertices of E which are not visited i.e C and F
3
A B C
Vertices Visited:
2
1 4 G A,D,E,B,C,F

D E F
5

Step 5 : Come back to b and visit all the adjacent vertices of B which are not
visited. A,C and E are already visited.

3
A B C
2 Vertices Visited:
1 4 G
A,D,E,B,C,F

D E F
5
Step 6 : Visit all the adjacent vertices of C which are not visited i.e. G.
3
A B C 6
Vertices Visited:
1 2 G
4 A,D,E,B,C,F,G

D E F
5
Step 7 : Visit all the adjacent vertices of F which are not visited.(There is no
vertex to be visited.)
3
A B C 6
Vertices Visited:
1 2 G
4 A,D,E,B,C,F,G

D E F
5
Therefore the traversal order for the breadth first search traversal is

A D E B C F G
Depth First Search(BFS)

 DFS is a graph traversal technique that begins at the root node and
explores all the neighbouring vertices of an adjacent vertex before
visiting the other adjacent vertices.
 If at any vertex, its all the adjacent vertices are visited, then
backtracking is used until the first vertex having an adjacent vertex
that has not been traversed before is found.
 DFS traversal of a graph produces a spanning tree as final result.
 Stack data structure with maximum size of total number of vertices in
the graph to implement DFS traversal.

 There can be many possible ways for depth first traversal in a graph.
Example

Consider a graph having 6 vertices same as in BFS.

A B C
G

D E F

Step 1 : Select vertex A as the starting point (any vertex can be selected as a
starting point if parent node is not given)

A B C
Vertices Visited:
G
A

D E F
Step 2 : Visit any adjacent vertex of A which is not visited,
let us take vertex B.
1
A B C
Vertices Visited:
G
A,B

D E F

Step 3 : Visit any adjacent vertex of B which is not visited,


let us take vertex C.
1 2
A B C
Vertices Visited:
G
A,B,C

D E F
Step 4 : Visit any adjacent vertex of C which is not visited,
let us take vertex E.
1 2
A B C
Vertices Visited:
3 G
A,B,C,E

D E F

Step 5 : Visit any adjacent vertex of E which is not visited,


let us take vertex D.
1 2
A B C
Vertices Visited:
3 G
A,B,C,E,D

D E F
4
Step 6 : There is no new vertex to be visited from D, so
use backtrack and return to vertex E.
1 2
A B C
Vertices Visited:
3 G
A,B,C,E,D

D E F
4

Step 7 : Visit any adjacent vertex of E which is not visited,


i.e. F.
1 2
A B C
Vertices Visited:
3 G
A,B,C,E,D,F

D E F
4 5
Step 8 : Visit any adjacent vertex of F which is not visited, i.e. G.

1 2
A B C
Vertices Visited:
3 G
A,B,C,E,D,F,G
6
D E F
4 5
Step 9 : There is no new vertex to be visited from G, so use backtrack until
starting vertex is obtained.
1 2
A B C
Vertices Visited:
3 G
A,B,C,E,D,F,G
6
D E F
4 5
Therefore the traversal order for the breadth first search traversal is
A B C E D F G

Potrebbero piacerti anche