Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Module 6 Graphs (E)

Uploaded by

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

Module 6 Graphs (E)

Uploaded by

shwetak1275
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 59

12/12/24 1

MODULE 6
GRAPH THEORY
Dr. Bhakti palkar
12/12/24 2

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
12/12/24 3

Topics Covered
Graphs and Subgraphs 05 CO4
6.1 Definitions, Paths and circuits,
Types of Graphs,
Eulerian and Hamiltonian
6.2 Planer graphs
6.3 Isomorphism of graphs
6.4 Subgraph
12/12/24 4

Definitions - Graph
A graph G consists of a finite set v of objects called
vertices, a finite set E of objects called edges and a
function  that assigns to each edge a subset {v, w} where
v and w are vertices (and may be the same).
We will write G = (V, E, )
12/12/24 5

Graph
Let V={1, 2, 3, 4}
and E={ e1, e2, e3, e4, e5}.
Let g be defined by
(e1)=  (e5) = {1, 2},
 (e2)={4, 3}, (e3)= {1, 3}, (e4)={2, 4}.
Then G={V, E, ) is a graph as shown in
12/12/24 6

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
12/12/24 7

Definitions
Degree :
The degree of a vertex is the number of edges
having that vertex as an end point.
Loop :
A graph may contain an edge from a vertex to
itself, such an edge is referred to as a loop. A loop
contributes 2 to the degree of a vertex. Since that
vertex serves as both end points of the loop.
Isolated Vertex :
A vertex with degree 0 will be called an isolated
vertex.
Adjacent Vertices :
A pair of vertices that determine an edge are
adjacent vertices.
12/12/24 8

Simple undirected graph


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
12/12/24 9

Directed graph
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
12/12/24 10

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
12/12/24 11

Connected graph
A graph is called connected if there is a path from any
vertex to any other vertex in the graph.
Otherwise, the graph is disconnected. If the graph is
disconnected, the various connected pieces are called the
components of the graph.
12/12/24 12

Problem
Determine whether the graph (shown in Fig. 6.5) is
connected or disconnected. If disconnected find its
connected component.

(a)Graph shown in Fig. 6.5 (a) is not connected its connected


components are {A, D, P, S, C} and {B, Q, R}
(b)Graph shown in Fig. 6.5 (b) is not connected its connected
components are {A, B, Y, Z}, {C, X, Q}, {P, R}
12/12/24 13

Complete Graph
For each integer n 1, let Kn denote the graph with vertices
{v1, v2, … vn } and with an edge {vi, vj} for every i and j.
In other words, every vertex in Kn is connected to every
other vertex. In
12/12/24 14

More Graphs
Linear graph:

Discrete Graph:
12/12/24 15

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.
12/12/24 16

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.
12/12/24 17

Subgraph
(a)

Let G = (V, E, ) is a graph. Choose a subset E1 of the


edges in E and a subset V1 of the vertices in V. So that V1
(b)

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.
12/12/24 18

Spanning Subgraph
A subgraph is said to be spanning subgraph if it contains
all the vertices of G.
12/12/24 19

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.
12/12/24 20

Complement of Subgraph

u u u

v
w v w v

G H1 H2
12/12/24 21

Subgraph Isomorphism
The subgraph isomorphism is a computational task in
which two graphs G and H are given as input, and one
must determine whether G contains a subgraph that is
isomorphic to H.

f : {(A, C1), (B, A1), (C, B1)}


12/12/24 22

Handshaking Lemma
Consider a graph G with e number of edges and n number
of vertices. Since each edge contributes two degrees, the
sum of the degrees of all vertices in G is twice the number
of edges in G i.e.

∑ d( vi) = 2 e
12/12/24 23

Problem
How many nodes are necessary to construct a graph with
exactly 6 edges in which each node is of degree 2.
Soln. : Suppose there are n vertices in the graph with
6 edges. Also, given the degree of each vertex is 2.
Therefore by handshaking lemma,
Σd (vi)=2e = 2  6
 d (v1) + d (v2) + … + d (vn) = 12.
 = 12
 2n = 12
 n = 6
Hence, 6 nodes are required to construct a graph with 6
edges in which each node is of degree 2.
12/12/24 24

Problem
Determine the number of edges in a graph with 6 nodes, 2
of degree 4 and 4 of degree 2. Draw two such graphs.
12/12/24 25

Problem
Determine the number of edges in a graph with 6 nodes, 2
of degree 4 and 4 of degree 2. Draw two such graphs.
Soln: Suppose the graph with 6 vertices has e number of
edges. Therefore, by handshaking lemma.
Σd (vi) = 2e
 d (v1) + d (v2) + d (v3) + d (v4) + d (v5) + d (v6 ) = 2e
Now, given 2 vertices are of degree 4 and 4 vertices are of
degree 2.
Hence from the above equation
 (4 + 4) + (2 + 2 + 2 + 2) = 2e
 16 = 2e
 e = 8
12/12/24 26

Path & Circuit


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
12/12/24 27

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
12/12/24 28

Example
12/12/24 29

Identify Euler path and circuit


12/12/24 30

Theorem: EULER CIRCUIT

A)If graph G has a vertex of odd degree ,


All vertices
then there can be no Euler circuit in G have even
degree
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 All vertices


have odd
A)If a graph G has more than two vertices
degree
of odd degree then there can be no Euler
path in G

B)If G is connected and has exactly two


Two
vertices of odd degree then there is a vertices
Euler path in G have odd
degree
12/12/24 31

Hamiltonian Path & 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
12/12/24 32

Example
12/12/24 33

Examples

Hamiltonian Hamiltonian Hamiltonian


Circuit:ADCBA Path:no Path:no
Euler path: Euler Euler path:NO
B,A,C,D,A,B,C path:D,D,E,B,A,B,
C
12/12/24 34

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


12/12/24 35

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)
12/12/24 36

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)
12/12/24 37

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.
12/12/24 38

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
12/12/24 39

Isomorphic Graph

Function f is called isomorphism


1. Same no. of vertices
2. Same no. of edges
3. Equal no. of vertices with a given degree
4. Adjacency of vertices
12/12/24 40

Graph - Isomorphism
Representation example: G1 = (V1, E1) , G2 = (V2, E2)
f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2
No. of vertices:4
No. of edges:4
All vertices have degree 2

u1 u2 v1 v2

u3 u4 v4
v3
12/12/24 41

Isomorphism of Graphs
Example I: Are the following two graphs isomorphic?
a a

e
b b
e

c c d
d

Solution: No. of vertices: 6, No. of edges: 6


3 vertices with degree 2, 2 vertices with degree 3
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.
12/12/24 42

Isomorphism of Graphs
Example II: How about these two graphs?
a a
b
e
e
b

c c
d
d

Solution: No. of vertices: 5, No. of edges:6


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.
12/12/24 43

Isomorphism of Graphs
Example III: Are the following two graphs isomorphic?
Solution:
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
12/12/24 44

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.
12/12/24 45

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.
12/12/24 46

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.
12/12/24 47

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
12/12/24 48

Examples
12/12/24 49

Planar Graphs Example


12/12/24 50

Planer Graph
• Theorem : Euler's connected planar graph theorem

v–
e+r=2

number number
number of regions
of vertices of edges
12/12/24 51

Q. 1) By drawing the graph, show that following graphs are planar graphs
12/12/24 52
12/12/24 53

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.
12/12/24 54

3 : Determine the number of regions defined by a connected planar graph with


vertices and 10 edges. Draw a simple and a multi-graph.
oln. :
12/12/24 55

3 : Determine the number of regions defined by a connected planar graph with


vertices and 10 edges. Draw a simple and a multi-graph.
oln. :
ven v = 6, e = 10
ence 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
12/12/24 56

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. :
12/12/24 57

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.
12/12/24 58

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. :
12/12/24 59

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.

You might also like