0% found this document useful (0 votes)
10 views

Module 5.2 Graphs for Students

Graphs, Euler and Hamiltonian Graphs

Uploaded by

a4i20y1j8a
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Module 5.2 Graphs for Students

Graphs, Euler and Hamiltonian Graphs

Uploaded by

a4i20y1j8a
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 55

GRAPHS

Graphs: Definition and terminology,


Representation of graphs, Multi graphs,
Bipartite graphs, Planar graphs, Isomorphism
and Homeomorphism of graphs, Euler and
Hamiltonian paths, Graph colouring.
Graph :
Definition
Graph: It is a collection of set of vertices (nodes) and set of
edges(links) represented as 𝐺(𝑉, 𝐸),
1
1 4
4

2 3 2 3

(a) (b)

Order: Number of Vertices in a graph G.


Size: Number of Edges in a graph G.

𝑽𝒊, 𝑽𝒋 𝑽𝒊 , 𝑽𝒋 ≠
For Directed Graphs:
E= are
𝑽𝒊 , 𝑽𝒋
E= 𝑽𝒊 , 𝑽𝒋
ordered pairs, For Undirected Graphs:
are
Preliminaries
 Adjacent vertex: If two vertex are joined by the same
edge
(both the end points of one edge are adjacent vertex).
 Adjacent edge: If two edges are incident on same vertex (if
two edges have one common vertex, then those edges are
adjacent edges.
 Self loop: An edge with just one end-point.
 Parallel edges: Two or more edges of a graph having
same end points.
a
1 4

c Nodes 1 and 4 are adjacent vertex.


b d
Edges a and c are adjacent edges
2 3
e
GRAPHS
REPRESENTATION
Adjacency
Matrix
• In this representation, graph can be represented
using a matrix of size V×V.
• No matter how few edges the graph has, the matrix
takes O(V2) in memory.
Adjacency
Matrix
Adjacency matrix representation
self loops and parallel edges.
of graph with

3 denotes three different paths from node a to node b


Incidence
Matrix
• In this representation, graph can be represented using a
matrix of size V×E.
• This matrix is filled with either 0 or 1 or -1. Here, 0
represents row edge not connected to vertex, 1 as outgoing
edge and -1 as incoming edge.
Incidence
Matrix
Incidence matrix representation of undirected graph with self
loops and parallel edges.
Quiz
Draw the incidence matrix of given Graph.
Different
GraphsType Self Loop Parallel Edges
Graph Yes Yes
Multi-Graph No Yes
Pseudo Graph Yes No
Simple Graph No No

A A B
(a) (b)

Self loop: An edge with just Parallel Edges: two or more edges of
one end-point a graph having same end points.
Types of
Graphs
Trivia Undirecte Directed Connected
Null Graph
l d Graph Graph Graph
Graph
Disconnect Regular Complete Cycle Cyclic
ed Graph Graph Graph Graph
Graph
Acycli Finite Infinite Bipartite Simple
c Graph Graph
Graph Graph Graph
Planar Wheel Multi- Pseudo Euler
Graph Graph Graph Graph Graph

Hamiltonian
Sub-Graph
Graph
Types of
Graphs 1. Trivial Graph (The smallest graph)
1 • Vertex set contains only one vertex.
• Edge set is empty, i.e. no edge.

2. Null Graph
1 3
• Vertex set is non-empty.
2
• Edge set is empty.

1 3 3. Finite Graph
• Vertex set is non-empty and finite.
2 • Edge set is non-empty and finite.

4. Infinite Graph
• Vertex set is non-empty and infinite.
• Edge set is non-empty and infinite.
Types of
Graphs
1
2
5. Simple Graph
• A graph without self loops and parallel edges.
4
3
1 3 6. Cyclic Graph
• A graph containing at-least one cycle.
2 4

1 3 7. Acyclic Graph
• A graph containing no cycle.
2 4

1 2 8. Complete Graph (Represented by 𝑲𝒏)

between every pair of vertices. Ex: 𝐾4


• Graph in which exactly one edge is present
4 3
Types of
Graphs
1
2
9. Connected Graph
• 3 A graph in which there exists at-least one
4 5 path
between every pair of vertices.
1 3 10. Disconnected Graph
• A graph in which there does not exists at-least one
5 2 4 path between every pair of vertices.

1 3 11. Undirected Graph


• A graph with undirected edges (edges with no
2 4 direction) only.

1 4 12. Directed Graph


• A graph with directed edges only.
2 3
(𝑲 𝒏 ) graph in which there is exactly one edge between
Complete Graphs
A simple
very pair of vertices (every pair of vertices are adjacent to
each other) is called complete graph.

𝐾 𝐾
2 3
𝐾
4 6
3

1. No. of edges in complete graph =|E|= 𝟐𝒏𝑪 =n*(n-


Note:

2. If complete graph has 𝒏 vertices, degree of every vertex is n-


1)/2.
1.
Regular
Graphs
A simple graph in which all the vertices are of equal degree
is called regular graph and if the degree of every vertex

𝒌, then it is known as 𝒌-regular graph.


is

Note:
1. No. of edges in regular graph =|E|=n*k/2
2. Every Complete Graph (degree (n-1)) is Regular Graph BUT every Regular Graph
is NOT Complete Graph.
Bipartite
A simple graph whose vertex set 𝑽can be partitioned
Graphs
into two subsets 𝑴 and 𝑵 (𝑽 = 𝑴 𝖴 𝑵) the
vertices of set 𝑴 only join with the vertices of set 𝑵.
1
V=7 5

2
6

3
7
4

M=4 N=3

Note:
1. Smallest possible graph that is NOT bipartite is
(𝑲 )
Complete Bipartite Graphs
whose vertex set 𝑽 can be partitioned
𝒎,𝒏
into two subsets 𝑴 and 𝑵 𝑽 = 𝑴 𝖴 𝑵 such that
A simple graph

every vertices of subset 𝑴 joins with the every vertex


of subset 𝑵.
1
1 4
1 3

3 2 5
2 4
2 6
3
𝐾2,
5
�3,
1 𝐾2, �3
3
1. Total no. edges in 𝑲𝒎,𝒏 = 𝒎 ∗ 𝒏.
Note:

2. Smallest possible graph that is NOT bipartite is 𝑲𝟑.


3. Every Complete graph (degree (n-1)) is Regular graph BUT every Regular Graph
is NOT Complete Graph.
(𝑲𝒏 ) Vs
(𝑲 )
𝑲𝒏 is where every vertex is connected to every
𝒎,𝒏
is where every vertex of subset 𝒎 is connected
other vertex.
𝑲𝒎,
every vertex of subset 𝒏.
Remember: 𝑲𝒏 and 𝑲𝒎,𝒏are different i.e 𝑲𝟔 and
𝒏
with

𝑲𝟑,𝟑
means two different things.
1 1

3 3

𝐾
2 2
𝐾2,1
3
Not Bipartite • Bipartite
• Complete Bipartite
(𝑲𝒏 ) Vs
(𝑲𝒎,𝒏 )
1
4

2 5

6
𝐾
3
𝐾3,
6 3
Not Bipartite • Bipartite
• Complete Bipartite
Planar
Graph
Eg: 𝑲𝟒, 𝑸𝟑
A graph that can be drawn on a plane without
edges crossing is called planar graph.

𝑄
𝐾
3
4
A planar graph divides the plane into one or
more regions. One of these regions will be infinite.

1. 𝑲𝟓, 𝑲𝟑,𝟑 are Non-Planar Graphs


Note:
WALK, PATH,
TRAIL
CYCLE AND
CIRCUIT
Wal
A walk is defined as a finite alternating sequence of
k
vertices and edges, beginning and ending with vertices
such that edge and vertex can repeat.

Ex : 1 a 4 f 4 d 3d4 f

a
1 4
In WALK: c
A vertex CAN repeat b d
An edge CAN 3
2
repeat e

Note:
• Different names of Walk are Edge Train and Chain
• Length of the walk: |Number of edges covered in the walk|.
• Trivial Walk: Length of the walk =0
Open and Closed
• When a walk begins and ends at different vertices is
Walk
called Open Walk.
• When a walk begins and ends at same
vertices is called Closed Walk.
f

Ex : Open Walk: 1 a 4 f 4 d 3 a
1 4
Ex : Closed Walk: 1 a 4 f 4 c 2 b 1 c
b d

2 3
e
Trai
A trail is an open walk
lbut vertex can repeat. in which no edge is repeated

Ex : 1 a 4 f 4 d 3
f

a
1 4
In TRAIL: c
A vertex CAN repeat b d
An edge CANNOT repeat 3
2
e
Circuit
A circuit is a closed trail in which no edge
is repeated but vertex can repeat.

Ex : 1 a 4 f 4 d 3 e 2 b 1
f

a
1 4
In CIRCUIT: c
A vertex CAN repeat b d
An edge CANNOT repeat 3
2
e
Pat
An open walk in which no
hthan once is called as Path.vertex can appear more

Ex : 1 a 4 d 3
f
In PATH:
A vertex CANNOT repeat a
1 4
An edge CANNOT
repeat c
b d
Walk

2 3
Path e

Note: Every PATH is a WALK but every WALK is NOT a PATH.


Cycl
e closed path in which no vertex can repeat except
A
the end vertices are same is called as Cycle.

f
Ex : 1 a 4 d 3 e 2 b 1
a
1 4
In CYCLE:
c
A vertex CANNOT repeat b d
An edge CANNOT 3
2
repeat e
Quiz 1

14(W), Open Walk(OW)


a
2
3
Walk 4
b c
Closed Walk (CW), Trail (T), Path (P)
5 6 7
Circuit (Ckt) or Cycle (C) ?
d e
8
Sequence W OW CW T Ckt P C
a2b5d8e Yes Yes No Yes No Yes No
a2b5d8e7c3a Yes No Yes Yes Yes Yes Yes
a2b6e8d5b4c Yes Yes No Yes No No No
a3c7e6b4c7e6b Yes No No No No No No
b2a Yes Yes No Yes No Yes No
a3c4b2a3c7e6b Yes No No No No No No
a3c4b2a3c7e6b4c Yes No No No No No No
b4c7e6b Yes No Yes Yes Yes Yes Yes
Relationship
Diagram
No Vertex Repeat Walk Vertex Repeat
No Edge Repeat No Edge Repeat

Every
Path Trai
l
Closed Closed

Every
Cycle Circuit

Note:
1. Every Path is a Trail
2. Every Cycle is a Circuit
Summarized
Vertex Edge
Walk Can Repeat Can Repeat

Trail Can Repeat Cannot Repeat

Circuit (Closed Trail) Can Repeat Cannot Repeat

Path Cannot Repeat Cannot Repeat

Cycle (Closed Path) Cannot Repeat Cannot Repeat


(only end vertices are same )
EULER &
HAMILTONIAN
GRAPHS
Euler
Graph
• Eulerian Circuit is an Eulerian Path which starts and ends
on the same vertex.
• An Euler Path in G is a simple path containing every edge
of G exactly once.

Euler Graph: A connected multi-graph 𝑮 is said to be Euler


Graph if we can traverse each edge exactly once (vertices
may repeat).
OR “contains a Euler Circuit”.
A B

D C
Fig 1 Fig 2
Euler
Graph

Fig 2

Fig 3

Fig 4
Fig 5
Necessary and Sufficient
Condition
• For Eulerian Path: When only two vertices in the
connected graph has odd degree (any Euler path must
begin at one vertex with odd degree and end at the
other).
• For Eulerian Circuit: When every vertex in the connected
graph has even degree.

Theorem: A connected graph 𝑮 with at-least two vertices


has Euler Circuit if and only if (iff) each vertex is of even
degree.

Note:
Every Euler Circuit has Euler Path BUT NOT vice versa.
Hamiltonian
Graph
• Hamiltonian Circuit is a circuit that traverses
each vertex in G exactly once.
• Hamiltonian Path is a path that traverses each vertex in
G exactly once.
Hamiltonian Graph: A connected graph 𝑮 is said to
be Hamiltonian Graph if we can traverse each vertex exactly
once.

OR “contains a Hamiltonian Circuit”.

Fig 1 Fig 2
Hamiltonian
Graph

Fig 3

Fig 2

In Fig 2: Hamiltonian Path


but NO Hamiltonian Circuit Fig 4

Fig 3 and Fig 4 are Hamiltonian


Circuit
Note: There is NO Necessary condition to check whether a graph has
Hamiltonian Circuit or not. Sufficient BUT NOT Necessary conditions for the
existence of Hamiltonian Circuit:
Sufficient
Conditions
1. Dirac’s Theorem: If 𝑮 is a simple graph and 𝒏 ≥ 𝟑 such that

vertex has at-least 𝒏/𝟐 degree then 𝑮 has Hamiltonian Circuit.


each

2. Ore’s Theorem: If 𝑮 is a simple graph and 𝒏 ≥ 𝟑 such

𝒅𝒆𝒈 𝒖 + 𝒅𝒆𝒈 𝒗 ≥ 𝒏 for every pair of non-adjacent


that

𝒖 𝟏
3. will have a Hamiltonian Circuit if 𝒎 ≥�(𝒏� − 𝟑𝒏
and 𝒗 in 𝑮, then 𝑮 has Hamiltonian Circuit.
vertices of �

+ 𝟔) + 𝐝𝐞𝐠(𝐯) ≥𝒏
𝑮 𝒏
Let G be a linear graph of 𝒏 vertices, if 𝒎

−𝟏
If a connected graph has vertices and edges, then
𝒅𝐞𝐠If 𝐮
4. for
a connected graph 𝑮 has 𝒏 vertices & 𝒏 ≥ 𝟑 and 𝒅𝒆𝒈
it every pair of vertices, then there exists a Hamiltonian Circuit
5.
𝒗 ≥
𝒏 for every vertex then, 𝑮 has Hamiltonian Circuit.
6. If there is a vertexof degree 1
in a graph then it is impossible for the
GRAPH COLORING
APPLICATION
Graph Coloring
Problem
A coloring of a simple graph is the assignment of a
color to each vertex of the graph “such that no two
adjacent vertices are assigned the same color.”

1 2
M-Colorable and Chromatic
No.
• A graph G is called M-Colorable if it is possible to color

number 𝜸(𝑮):Minimum number of


the graph using at-most M-Colors.
• Chromatic
colors needed to color a graph is called chromatic
number of G.

1 2
Chromatic No.= 3 Chromatic No.= 3

Note: Every planar graph is 5-colorable.


Quiz
15 number of 𝑲 ?
What is the chromatic 𝒏

with 𝒏 vertices = 𝒏
Chromatic no. of completely connected graph

Since every vertex is connected to every other


vertex in a complete graph, the chromatic
number is n.
Quiz
16 number of 𝑪 ?
What is the chromatic 𝒏

If n =odd , chromatic no. =3


If n = even, chromatic no.=2
Quiz
17 number of 𝑲
What is the chromatic 𝒎,𝒏?

For biparite graph chromatic no. =2


Chromatic
Number
ISOMORPHISM OF
GRAPHS
Graph
Isomorphism
• Two graphs are said to be isomorphic if they are
perhaps the same graphs just drawn differently with
different names i.e. they have identical behavior for any
graph theoretic properties.
Formally: Two graphs G1 and G2 are said to be isomorphic, if
there is one-to-one correspondence between vertices and
edges and incidence relationship is preserved.

Fig 1
Graph
Isomorphism

Fig1: G1 and G2 are Isomorphic

Fig 2: G1 and G2 are Isomorphic but Not G3.


Graph
Isomorphism

Fig 4: G1 and G2 are Not Isomorphic.

Graph Isomorphism is a phenomenon of


existing the same graph in more than one forms.
Necessary
Conditions
1. Number of vertices in both the graphs must be same.
2. Number of edges in both the graphs must be same.
3. Degree sequence of both the graphs must be same.
4. Planar, Non-Planar
5. Connected, Disconnected
6. Minimum, Maximum Cycle Length and Cycles
with specific lengths.
7. Chromatic Number is same.
8. If a cycle of length k is formed by the vertices { v1 , v2 ,
….. , vk } in one graph, then a cycle of same length k
must be formed by the vertices { f(v1) , f(v2) , ….. ,
f(vk)
} in the other graph as well.
Sufficient
Conditions
1. Two graphs are isomorphic and only if
if complement graphs are their
isomorphic.
2. Two graphs are isomorphic if their adjacency matrices
are same.

3. Two graphs are isomorphic if their corresponding sub-


graphs obtained by deleting some vertices of one graph
and their corresponding images in the other graph are
isomorphic.
Graph Homomorphism
• Two graphs G and G* are said to homomorphic if they can
be obtained from the same graph or isomorphic graphs.
The graphs (a) and (b) are not isomorphic, but they are
homeomorphic since they can be obtained from the graph
(c) by adding appropriate vertices.
Counting
Counting is the process of determining the number of elements
of a finite set of objects.

Let’s say a person has 3 pants and 2 shirts. How many


different ways are there in which he can dress? There are
three different ways of choosing pants as there are three
types of pants available. Similarly, there are two ways of
choosing shirts.
Let’s see all the different ways of dressing through a
diagram. Considering P1, P2, and P3 as pants and S1, S2 as
shirts. The tree given below lists the range of possibilities
Counting
Let’s say a person has 3 pants and 2 shirts. How many
different ways are there in which he can dress? Let’s see
all the different ways of dressing through a diagram.
Considering P1, P2, and P3 as pants and S1, S2 as shirts.
Pigeon Hole Principle
If there are more pigeons than pigeonholes, then there
must be at least one pigeonhole with at least two pigeons
in it.

Q. A box contains three pairs of socks colored red, blue,


and white, respectively. Suppose I take out the socks
without looking at them. How many socks must I take out
to be sure that they will include a matching pair?

If I take only 2 or 3 socks, it is possible that they are all different. For
example, they may be one red and one blue; or one red, one blue, and
one white. But if I take out 4 socks, these must include a matching pair.
Here the 4 chosen socks are the "objects" and the 3 colors are the
"boxes"; by PP1, it follows that at least two of the four chosen must
have the same color and hence must be a matching pair. Thus the

You might also like