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

Module 6 Graphs

Uploaded by

aarya.sk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Module 6 Graphs

Uploaded by

aarya.sk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

"Discrete Mathematics and its Applications" Kenneth

Rosen, 5th Edition, McGraw Hill.


Graph Theory

Chapter 8
Varying Applications (examples)

• Computer networks
• Distinguish between two chemical compounds with
the same molecular formula but different structures
• Solve shortest path problems between cities
• Scheduling exams and assign channels to television
stations
Topics Covered
• Definitions
• Types
• Terminology
• Representation
• Sub-graphs
• Connectivity
• Hamilton and Euler definitions
• Isomorphism of Graphs
• Planar Graphs
Definitions - Graph

A generalization of the simple concept of a set of dots, links,


edges or arcs.

Representation: Graph G =(V, E) consists set of


vertices denoted by V, or by V(G) and set of
edges E, or E(G)
Definitions – Edge Type
Directed: Ordered pair of vertices. Represented as (u, v)
directed from vertex u to v.

u v

Undirected: Unordered pair of vertices. Represented as {u, v}.


Disregards any sense of direction and treats both end vertices
interchangeably.

u v
Definitions – Graph Type
Simple (Undirected) Graph: consists of V, a nonempty set
of vertices, and E, a set of unordered pairs of distinct
elements of V called edges (undirected)

Representation Example: G(V, E), V = {u, v, w}, E = {{u, v},


{v, w}, {u, w}} u v

w
Definitions – Graph Type
Directed Graph: G(V, E), set of vertices V, and set of Edges E,

that are ordered pair of elements of V (directed edges)

Representation Example: G(V, E), V = {u, v, w}, E = {(u, v), (v,


w), (w, u)}
u v

w
• Degree of a vertex: Number of edges having that
vertex as an end point
• Loop: A graph may contain an edge from a vertex to
itself referred to as a loop
Isolated vertex: Vertex with degree 0
• Adjacent vertices : A pair of vertices that determine
an edge
• For V = {u, v, w} ,
E = { {u, w}, {u, w}, (u, v) },
deg (u) = 2, deg (v) = 1, deg (w) = 1, deg (k) = 0,
• k is isolated

u v
k

w
Terminology – Directed graphs
• In-degree (u): number of in coming edges

• Out-degree (u): number of outgoing edges

Representation Example: For V = {u, v, w} , E = { (u, w), ( v, w), (u, v) },


indeg(u) = 0, outdeg (u) = 2,

indeg(v) = 1, outdeg(v)= 1

indeg(w) = 2, outdeg (w) = 0

u v

w
Types of Graphs
L2 L3
• Linear Graph
• Discrete Graph (only vertices , no edges )

D2 D4
c c c c c c

• Complete Graph
• Connected Graph
COMPLETE GRAPH
• Complete graph: Kn, where every vertex is connected to
every other vertex

• Kn is called a complete graph for n vertices if the


number of edges are n(n-1)/2

• DRAW COMPLETE GRAPH K6

K1 K2 K3
K4
Representation Example: K1, K2, K3, K4
CONNECTED GRAPH
• If there is a path from any vertex to any other
vertex in the graph
• Otherwise it is a disconnected graph(various
connected pieces are called components of
graph)
u

v w
Problem
Determine whether the graph is connected or
disconnected. If disconnected find its connected
component.

(a)Graph shown in (a) is not connected its connected components are


{A, D, P, S, C} and {B, Q, R}

(b)Graph shown in (b) is not connected its connected components are


{A, B, Y, Z}, {C, X, Q}, {P, R}
11/11/2022 16
Multigraph
Directed graph having multiple edges between two vertices is
called as multigraph. Undirected graph having more than one
edge between two vertices is also called as Multigraph.

11/11/2022 17
Labelled and weighted graph
A graph G is called a labelled graph it its edges and /or vertices
are assigned data of one kind or another. In particular, G is called
a weighted graph if each edge 'e' of G is assigned a non–
negative number called the weight or length of V.

11/11/2022 18
Subgraphs

u u u

v w v w v

G H1 H2
Subgraph
Let G = (V, E, ) is a graph. Choose a subset E1 of the edges in E and a subset V1 of the
(a) vertices in V. So that V1 contains all the end points of edges in E1. Then H = (V1, E1, 1)
is also a graph, where 1 is  restricted to edges in E1. Such a graph H is called a
subgraph of G.

(b)

11/11/2022 20
Spanning Subgraph
A subgraph is said to be spanning subgraph if it
contains all the vertices of G.

11/11/2022 21
Complement of Subgraph
The complement of a subgraph G' = (V', E') with respect to the
graph G = (V, E) is another subgraph
G" = (V", E") such that E" is equal to E – E' and V" contains only
the vertices with which the edges in E" are incident.

11/11/2022 22
Complement of Subgraph

u u u

v
w v w v

G H1 H2

11/11/2022 23
Find Sub graphs of G
Compliment of Sub Graph

u u u

v w v w v

G H1 H2
Handshaking Lemma
Consider a Graph G with e nos of edges and n
nos of vertices , the sum of the degrees of all
vertices in G is twice the nos of edges in G
n
∑ d( vi) = 2 e
i=1
Problems
• Determine the number of edges in a graph with 6 nodes in
which 2 of degree 4 and 4 of degree 2. Draw two such graphs

• Is it possible to construct a graph with 12 nodes such that 2 of


the nodes have degree 3 and the remaining nodes have
degree 4

• Is it possible to draw a simple graph with 4 vertices and 7


edges . Justify ?
• Path : A path is a sequence of vertices where
no edge is chosen more than once
– A path is called simple if no vertex repeats more than once

• Length of Path : Number of edges in a path is


called as length of path

• Circuit: A circuit is a path that begins and ends


with the same vertex
EULER PATH AND EULER CIRCUIT

• EULER PATH
– A path in a graph G is called an Euler path if it
includes every edge exactly once

• EULER CIRCUIT
– A Euler path that is a circuit
Theorem: EULER CIRCUIT

A) If graph G has a vertex of odd degree , then there can be no


Euler circuit in G

B) If G is a connected graph and every vertex has an even degree


then there is a Euler circuit in G

Theorem: EULER PATH

A) If a graph G has more than two vertices of odd degree then


there can be no Euler path in G

B) If G is connected and has exactly two vertices of odd degree


then there is a Euler path in G
All vertices
have even
degree

All vertices
have odd
degree

Two vertices
have odd
degree
HAMILTONIAN PATH AND CIRCUIT

• A Hamiltonian path contains each vertex


exactly once

• A Hamiltonian circuit is a circuit that contains


each vertex exactly once except for the first
vertex which is also the last
Theorem: HAMILTONIAN CIRCUIT

A) G has a Hamiltonian circuit if for any two vertices u and v of G


that are not adjacent ,degree(u)+degree(v) ≥ nos of vertices

B) G has a Hamiltonian circuit if each vertex has degree greater


than or equal to n/2
Problem
Determine the Eulerian and Hamiltonian path, if
exists, in the following graphs.
Hamiltonian path : p, u, v, q, s, t, r
Hamiltonian circuit : r, p, u, v, q, s, t, r
Eulerian path : (p, u, v, q, s, v, u, r, t, s, r, p, q)

Hamiltonian path : c, d, e, b, a
Hamiltonian circuit : c, d, e , b, a, c
Eulerian path : (e, d, b, a, d, c, a, e, b)

11/11/2022 41
Identify Euler path, circuit,
Hamiltonian path and circuit

(a) two vertices b and d have odd degree.


Hence there is an Euler path.
: b, a, g, f, e, d, c, b, g, c, f, d

(a)

(b)6 vertices have odd degree, 3 and 1


vertex of even degree, 6.
So Euler path does not exist in this graph.

(b)
11/11/2022 42
Identify Euler path, circuit,
Hamiltonian path and circuit
Number of vertices is 6. Each vertex has
degree greater than equal to 6/2. So there
is an Hamiltonian circuit.
 : 1, 4, 5, 6, 3, 2, 1

There is no Hamiltonian circuit.


But there is an Hamiltonian path
: 3, 1, 2, 4, 6, 7, 5.

11/11/2022 43
Identify Euler path, circuit,
Hamiltonian path and circuit
(i) Eulerian Path : : a, b, c, d, b, f, d, a, f, e, d
G has 2 vertices of odd degree.
Hamiltonian Circuit : a, b, c, d, e, f, a.
Hamiltonian Path : a, b, c, d, e, f

(ii) Eulerian Circuit : -


Eulerian Path : g, d, b, a, e, f, g, c, b.
Hamiltonian Path : d, b, a, e, f, g, c

11/11/2022 44
• Function f is called isomorphism
• Same nos of vertices
• Same nos of edges
• Equal nos of vertices with a given degree
• Adjacency of vertices
Graph - Isomorphism

Representation example: G1 = (V1, E1) , G2 = (V2, E2)


f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2,

u1 u2 v1 v2

u3 u4 v4
v3
Isomorphism of Graphs
•Example I: Are the following two graphs isomorphic?
a
a

b e e
b
c d
c d

Solution: Yes, they are isomorphic, because they can be arranged to look identical.
You can see this if in the right graph you move vertex b to the left of the edge {a, c}.
Then the isomorphism f from the left to the right graph is: f(a) = e, f(b) = a,
f(c) = b, f(d) = c, f(e) = d.
Isomorphism of Graphs
•Example II: How about these two graphs?
a
a
b
e e

c c
d d

Solution: No, they are not isomorphic, because they differ in the degrees of their
vertices.
Vertex d in right graph is of degree one, but there is no such vertex in the left
graph.
• A is adjacent
to: B, C, D
• B is adjacent
to: A, C, E
C is adjacent
to: A, B
D is adjacent
to: A, E
E is adjacent
to: B, D
Both graphs contain
8 vertices and 10 edges
Nos of vertices of degree 2 = 4
Nos of vertices of degree 3 = 4
Adjacency : There exists no
vertex of degree 3 whose
adjacent vertices have same
degree in both graphs
So its not ISOMORPHIC
Isomorphism of Graphs
Example IV: Are the following two graphs isomorphic?

Solution: Both graphs have 5 vertices and 5 edges. All vertices


have degree 2.

11/11/2022 51
Isomorphism of Graphs
Example V: Are the following two graphs isomorphic?

Solution: Here G1 and G2 both have 4 vertices but G1 has 4 edges


and G2 has 5 edges. Hence G1 is not isomorphic to G2.

11/11/2022 52
Isomorphism of Graphs
Example VI: Are the following two graphs isomorphic?

Solution: G1 and G2 both have 5 vertices but G1 has 6 edges while


G2 has 7 edges. Hence G1 ≇ G2. That is G1 is not isomorphic to G2.

11/11/2022 53
Planar Graphs
• A graph (or multigraph) G is called planar if G can be drawn
in the plane with its edges intersecting only at vertices of G,
such a drawing of G is called an embedding of G in the plane.

Application Example: VLSI design (overlapping edges requires extra layers),


Circuit design (cannot overlap wires on board)
Representation examples: K1,K2,K3,K4 are planar, Kn for n>4 are non-planar

K4
Planar Graphs

• Representation examples: Q3
Planar Graphs
Theorem : Euler's planar graph theorem

For a connected planar graph or multigraph:


v–e+r=2

number
number number of regions
of vertices of edges
Planar Graphs

R1
K4 R4
R2
A planar graph divides the plane
into several regions (faces), one
R3 of them is the infinite region.

v=4,e=6,r=4, v-e+r=2
Examples

11/11/2022 60
Planar Graphs Example

11/11/2022 61
Q. 1) By drawing the graph, show that following graphs are planar graphs

11/11/2022 62
Q. 2 : How many edges must a planar graph have if it has 7 regions and 5 nodes.
Draw one such graph.
Soln. :
According to Euler's formula, in a planar graph
v–e+r = 2
where v, e, r are the number of vertices, edges and regions in a planar graph.
Here v = 5, r =7, e = ?
v – e + r =2
5 – e + 7=2
e=10
Hence the given graph must have 10 edges.

11/11/2022 63
Q. 3 : Determine the number of regions defined by a connected planar graph with
6 vertices and 10 edges. Draw a simple and a multi-graph.
Soln. :
Given v = 6, e = 10
Hence by Euler's formula for a planar graph
v – e + r =2
6 – 10 + r=2
r=6
Hence the graph should have 6 regions.

(a) Simple Graph


(a) Multi-Graph
11/11/2022 64
Q. 4 : A connected planar graph has 9 vertices having degrees 2, 2, 2, 3, 3, 3,
4, 4 and 5. How many edges are there ?
Soln. :
By handshaking lemma
Σd (vi) =2e
where d (vi) = degree of ith vertex
e = number of edges
For given graph
2 + 2 + 2 + 3 + 3 + 3 + 4 + 4 + 5 = 2.e
28 = 2e
e = 14
\ There are 14 edges.

11/11/2022 65
Ex. 5 : Suppose that a connected planer graph has 20 vertices, each of degree 3
into how many regions does a representation of this plan graph split the plane ?
Soln. :
| V |=20 = number of vertices
degree of each vertex = 3
By hand shaking Lemma
Σ d(Vi) = 2e
20  3 = 2e
 e = 30

By Euler's theorem,
| V | – | E | + | R |=2
20 – 30 + | R |=2
| R |=12

Planar graph will split the plane in 12 regions.

11/11/2022 66

You might also like