chapter 4
chapter 4
2
Introduction to Graph Theory
Graph Theory is originated from Konigsberg Bridge
Problem (Euler 1736). The problem is described as
follows.
The river Pregel is flowing through the middle of
Konigsberg town. There were two islands in the river,
denoted by I1 & I2, both of which were also part of the
town and seven bridges each joining a pair of land areas
of the town as in figure below:
Pregel
b6
3
Konigsberg Bridge Question
Question: Is there a route which begins at a place in
one of the land areas, passing through every bridges
once and only once, and returning to the starting
place?
Specify the route or proof that such a route doesn’t
exist C
D
A
B
4
4.1 Definition and examples of a graph
Definition: A graph G is a pair of sets (𝑉, 𝐸) consisting of
two things
i. A set 𝑉 = 𝑉(𝐺) which is a nonempty set of vertices,
Points or node of 𝐺
ii. A set 𝐸 = 𝐸(𝐺) of unordered pairs of distinct
elements of 𝑉 called edges𝐺.
V is called a vertex set and E is called an edge list.
Vertices u and v are said to be adjacentif there is an edge
𝑒 = *𝑢, 𝑣+between them. In such a case u and v are
called the end points of e.
Two edges are said to be adjacent if they are incident
with a common vertex.
5
Note:
If G is a finite:
An edge should not pass through more than two vertices.
9
Example 2
Example 2: State the nature of following graph G'.
12
Example
Example1: Determine the degree of each vertex of the
graph given below.
Solution:
deg(𝑣1) = 2
deg(𝑣2) = 3
deg(𝑣3) = 2
deg(𝑣4) = 3
13
Even, Odd, Isolated & Pendant vertex
Definition
i. A vertex is said to be even if its degree is even
number and odd if its degree is odd number.
ii. A vertex of degree zero is called isolated vertex.
iii. A vertex of degree one is called pendant vertex.
Example 2: Consider the following graph G.
deg 𝑣1 = 1 = deg(𝑣3),
deg(𝑣2) = 2,deg(𝑣4) = 0
V2 and V4 are even vertices
V1 and V3 are odd vertices
Moreover,
V3 and V4 are not adjacent
V2 and V3 are adjacent
14
Minimum and maximum degree
Let G be a graph. The minimum and maximum degrees
of G are denoted by δ(𝐺)and ∆(𝐺) respectively and
given by:
δ 𝐺 = Min*𝑑𝑖𝑔 𝑣 : 𝑣 ∈ 𝑉(𝐺)+ and
∆ 𝐺 = Max 𝑑𝑖𝑔 𝑣 : 𝑣 ∈ 𝑉 𝐺
Example: Find the minimum and maximum degree of G
given below.
δ 𝐺 = 2and ∆ 𝐺 = 4
15
The hand shaking lemma
In any graph:
Each edge has two ends and thus contributes 2 to the sum of
vertices degrees.
In a group of people shaking hands in a party, exactly two
hands are involved in each hand shakes.
The hand shaking lemma: Let G be a graph with vertex set
𝑉 = *𝑣1, 𝑣2, 𝑣3, … . 𝑣𝑛+ then
𝑛
deg(𝑣𝑖) = 2𝑒
𝑖=1
This is so because each edge contributes the count of two to the
sum since both end of each edge is counted in the sum
16
Example
Example : If a graph G has 10 edges with 2 vertices of
degree 4 each and all others are of degree 3 each, and
then find the number of vertices .
Solution 𝐸 = 10 and 2 vertices have degree 4. Let the
other vertices which are of degree 3 each be k in number
𝑛
𝑖=1 deg(𝑣𝑖) = 2 𝐸 , 𝑛 = 2 + 𝑘
⇒ 2(4) + 𝑘(3) = 2(10)
⇒ 8 + 3𝑘 = 20
⇒ 3𝑘 = 12
⇒𝑘 = 4
𝑇𝑒𝑟𝑒𝑓𝑜𝑟𝑒, 𝑛 = 2 + 𝑘 = 2 + 4 = 6
17
Consequences of the hand shaking lemma
I. In any graph the sum of all the vertex-degrees is an even number.
18
Graphs have proven to be an extremely useful tool for
analyzing situations involving a set of elements in which
various pairs of elements are related by some property.
The following are some examples dealing with real life
situations.
Electrical network: Transistors(vertices) and Wire (edges).
Telephone communication: Telephones and switching
(vertices) center Telephone lines(edges)
Computer flow chart: Instructions(vertices) & Logical flow-
(edge)
Organization chart People:-People(vertices) & Link between
the people(edge)
19
4.2 Matrix representation of Graphs
The essential features of a graph are:
i. The adjacency relationships between vertices
ii. The incidence relationships between vertices and
edges
Thus graphs can be represented by any one of the
following types of matrices.
I. Adjacency matrix :-a matrix that describes the
adjacency relationships between vertices of a graph.
II. Incidence Matrix:-A matrix that describes the
incidence relationships between vertices and edges of
a graph.
20
Adjacency matrix
n, if *𝑣𝑖 , 𝑣𝑗 + ∈ 𝐺(𝐸)
𝐴 = ,𝑎𝑖𝑗 - =
0 , 𝑜𝑡𝑒𝑟𝑤𝑖𝑠𝑒
21
Adjacency Matrix Example
c
To
a b c d e f
b d From
f a 0 1 0 0 1 1
b 1 0 1 0 0 1
a e c 0 1 0 1 0 1
d 0 0 1 0 1 1
W5 e 1 0 0 1 0 1
f 1 1 1 1 1 0
{v1,v2}
row column
22
Examples
Draw the adjacency matrix for:
A)
B) G:
23
Note
i. If the entries in a vertex are all zero, then the vertex is
isolated.
ii. In the adjacency matrix of any graph G, the degree of
each vertex 𝑣𝑖 is:
a) The sum of all the entries in the ith row (or jth
column) if there is no loop at 𝑣𝑖 .
b) Row (or column) sum plus number of loop(s) if there
is (are) loop(s) at 𝑣𝑖 .
iii. If G is a simple graph, then the adjacency matrix A(G)
a) Has leading diagonal entries all zero, 𝑎𝑖𝑖 = 0 for all 𝑖.
b) Is a Boolean matrix or a (0,1) matrix.
24
Examples
Let G be a graph with adjacency matrix
Then
i. Find the degree of each vertex.
ii. Find the cardinal number of the edge list.
iii. Draw the graph.
25
Incidence Matrix
Definition(Incidence Matrix):Le 𝐺 = (𝑉, 𝐸) be
undirected graph. Suppose v1,v2,v3,….,vn are the vertices
and e1,e2,e3,….,em are edges of G, then the incidence
matrix is the 𝑛𝑥𝑚 matrix 𝑀 = ,𝑚𝑖𝑗 - where
0 if 𝑣𝑖 ∉ 𝑒𝑗 .
𝑀 = 𝑚𝑖𝑗 = 1 if 𝑣𝑖 ∈ 𝑒𝑗 𝑎𝑛𝑑𝑒𝑗
26
Incidence Matrix Example
Represent the graph shown with an
incidence matrix.
e1 e2 e3 e4 e5 e6 edges
v1 v2 v3
e6 v1 1 1 0 0 0 0
e3 v2 0 0 1 1 0 1
e1 e4 v3
e5 0 0 0 0 1 1
e2 v4 1 0 1 0 0 0
v4 v5 v5 0 1 0 1 1 0
vertices
27
4.3 Isomorphic graphs (optional)
It is possible for two graph diagrams two look different but to
represent the same graph. On the other hand, it is possible to look
similar but to represent different graphs.
Consider the following diagrams which connects three houses
H1,H2,H3 to three utilities tel., water and electricity.
u3 u4 v3 v4
G H
Are G and H isomorphic?
f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2
30
Invariants
Invariants – properties that two simple graphs must
have in common to be isomorphic
Same number of vertices
Same number of edges
Degrees of corresponding vertices are the same
If one is bipartite, the other must be; if one is
complete, the other must be; and others …
Example Are G and H isomorphic?
b b
a c a c
e d e d
G H 31
Example
Are these two graphs isomorphic?
u1 u2 v1 v2
v5
v3
u5 u3
u4 v4
G H
– They both have 5 vertices
– They both have 8 edges
– They have the same number of vertices with
the same degrees: 2, 3, 3, 4, 4.
32
4.4 Path and connectivity of a graph
Definition:A path from v1 to 𝑣𝑡 (or between 𝑣1&𝑣𝑡) in a
graph G is the sequence of adjacent edges
*𝑣1, 𝑣2},{𝑣2, 𝑣3},…, {𝑣𝑡−1 , 𝑣𝑡 } where no edge and also no
intermediate vertex is repeated.
Its is denoted by: v1-v2-v3- …. – vt. (v1 is initial &vt is
terminal vertex of the path; all other vertices are called
intermediate vertices.) b
Example:
a-b-c-d-f is a path from vertex a to f. d
33
Cycle & Connected graph
b
c e
d
G f
34
4.5 Complete, regular and bipartite graphs
35
Regular graph
Regular graph: A graph G is said to be regular of degree
k or K-regular if every vertex
has degree k. In other words, a graph is regular if every
vertex has the same degree.
36
Con’t
37
Cycle and Wheel
Definition The cycle Cn (n 3), consists of n vertices v1,
v2, …, vn and edges {v1,v2}, {v2,v3}, …, {vn-1,vn}, and
{vn,v1}.
Examples (cycle)
C3 C4 C5 C6
Definition When a new vertex is added to a cycle Cn and
this new vertex is connected to each of the n vertices in
Cn, we obtain a wheel Wn.
38
Examples (Wheel)
W3 W4 W5 W6
39
Definition: (Bipartite Graphs)
f c
e d
41
4.6 Eulerian and Hamiltonian graphs
The Seven bridges of Königsberg
C
c
D
A
a d
B
b
42
Euler Paths and Circuits
44
Solution
Solution: The graph G1 has an Euler circuit, for
example, a, e, c, d, e, b, a. Neither of the graphs G2
or G3 has an Euler circuit. However, G3 has an Euler
path, namely, a, c, d, e, b, d, a, b. G2 does not have
an Euler path.
45
Necessary and Sufficient Conditions
A connected multigraph has a Euler circuit iff
each of its vertices has an even degree.
A connected multigraph has a Euler path but
not a Euler circuit iff it has exactly two vertices
of odd degree.
46
Example
Which of the following graphs has an
Euler circuit?
a b a b a b
e e
d c d c c d e
yes no no
(a, e, c, d, e, b, a)
47
Example
Which of the following graphs has an
Euler path?
a b a b a b
e e
d c d c c d e
yes no yes
a-e- c- d- e- b-a a- c- d- e- b- d-a-b
48
Hamilton Paths and Circuits
49
Hamilton Circuits
53
Properties to look for ...
55
4.7 Trees and forests (Rooted and Binary trees)
Definition: Let T = (V,E) be a graph. T is said to be a tree
iff it is a connected graph and contains no cycle
A vertex u on a tree is called a leaf if deg(u)=1.
Definition: A rooted tree is a connected diagraph D with no
cycles and with a unique vertex r which has zero indegree.
The vertex r is called the root of the tree.
Remark:
i. A rooted tree has unique root.
ii. An undirected tree can be made into a rooted tree by
choosing one vertex as the root and then directing all
edges away from the root.
56
Definitions:
57
Example
Example:- Consider the rooted tree T.
The root of the tree is vertex a.
Vertex a is at level 0.
Vertex b and c are at level 1.
Vertices d, e, f, g and h are at level 2.
Depth of T is 4 which is level of k.
The vertices d, k, j, f, g, and h with out degree zero are
called leaves of the tree.
Definition: If there is a directed edge from a vertex U to
V, we say that U is the parent of V and that V is the child
of U 58
Note
We say that a is a parent of d and d is a child of a since
there is a direct edge from a to d.
Vertices of the same parent are called siblings.
e.g:- d&e, a, b&c, i&j are siblings.
Vertices which have children are called internal
vertices. e.g. a, b, c, f, e, r are internal vertices.
Binary tree
M-ary tree: A rooted tree is called an m-ary tree if
every internal vertex has not more than m-children.
The tree is called a full-m-ary if every internal vertex
has exactly m children.
59
Definition: An 𝑚 −ary tree with 𝑚 = 2 is called a Binary
tree.
Note: A tree T is a full binary tree if there is only one
vertex with degree 2(sum of in degree & out degree) and
the remaining vertices are of degree 1 or 3.
Example: Consider the following two rooted trees
rooted at r.
60
Properties of Trees
61
The numbers of edges, leaves and vertices of various
types in trees.
THEOREM 6.3.2 : A tree with n vertices has n − 1 edges.
THEOREM 6.3.3 : A full m-ary tree with i internal vertices
contains n = mi + 1 vertices.
THEOREM 6.3.4 : A full m-ary tree with
(i ) 𝑛 vertices has 𝑖 = (𝑛 − 1)/𝑚 internal vertices and
𝑙 = ,(𝑚 − 1)𝑛 + 1-/𝑚 leaves,
(ii ) 𝑖 internal vertices has 𝑛 = 𝑚𝑖 + 1 vertices and
𝑙 = (𝑚 − 1)𝑖 + 1 leaves,
(iii ) 𝑙 leaves has 𝑛 = (𝑚𝑙 − 1)/(𝑚 − 1) vertices and 𝑖 = (𝑙 −
1)/(𝑚 − 1) internal vertices.
Example: 1. How many internal vertices & leaves do have a full 5-
ary tree with 2,001 vertices?
2. How many vertices & leaves do have a full 5-ary tree with 100
internal vertices? 62
4.8 Planar graphs
The House-and-Utilities Problem
63
Planar graphs …
Consider the previous slide. Is it possible to join the
three houses to the three utilities in such a way that
none of the connections cross?
Phrased another way, this question is equivalent to:
Given the complete bipartite graph K3,3, can K3,3 be
drawn in the plane so that no two of its edges cross?
K3,3
64
Planar graphs …
Definition A graph is called planar if it can be drawn in
the plane without any edges crossing.
A crossing of edges is the intersection of the lines or arcs
representing them at a point other than their common
endpoint.
Such a drawing is called a planar representation of the
graph.
Remark: A graph may be planar even if it is usually drawn
with crossings, since it may be possible to draw it in
another way without crossings
65
Planar graphs …
Note:
We can prove that a particular graph is planar by
showing how it can be drawn without any crossings.
However, not all graphs are planar.
It may be difficult to show that a graph is non planar.
We would have to show that there is no way to draw the
graph without any edges crossing.
66
Planar graphs …
67
Planar graphs …
Euler showed that all planar
representations of a graph split the plane
into the same number of regions,
including an unbounded region.
Example:-
R4 R3 R2
R1
68
Planar graphs …
Example (non-planar graph):-In any
planar representation of K3,3, vertex v1 must
be connected to both v4 and v5, and v2 also
v
must be v
connected
v
to both v 4 and v5.
1 2 3
v4 v5 v6 69
Planar graphs …
The four edges {v1, v4}, {v4, v2}, {v2, v5},
{v5, v1} form a closed curve that splits the
plane into two regions, R1 and R2.
v1 v5
R2 R1
v4 v2 70
Planar graphs …
Next, we note that v3 must be in either R1 or R2.
Assume v3 is in R2. Then the edges {v3, v4} and {v4, v5}
separate R2 into two subregions, R21 and R22.
v1 v5 v1 v5
R21
R2 R1 → v3
R22
v4 v2 v4 v2
71
Planar graphs …
Now there is no way to place vertex v6
without forcing a crossing:
If v6 is in R1 then {v6, v3} must cross an edge
If v6 is in R21 then {v6, v2} must cross an edge
If v6 is in R22 then {v6, v1} must cross an edge
v1 v5
R21
v3 R1
R22
v4 v2 72
Planar graphs …
Alternatively, assume v3 is in R1. Then the
edges {v3, v4} and {v4, v5} separate R1 into
two subregions, R11 and R12.
v1 v5
R11
R2 R12 v3
v4 v2
73
Planar graphs …
Now there is no way to place vertex v6 without forcing a
crossing:
If v6 is in R2 then {v6, v3} must cross an edge
If v6 is in R11 then {v6, v2} must cross an edge
If v6 is in R12 then {v6, v1} must cross an edge
v1 v5
R11
R2 R12 v3
v4 v2
74
Planar graphs …
Consequently, the graph K3,3 must be
non-planar.
K3,3
75
Euler’s Formula
Euler devised a formula for expressing the
relationship between the number of
vertices, edges, and regions of a planar
graph.
These may help us determine if a graph can
be planar or not.
76
Euler’s Formula …
R4 R3 R2 # of edges, e = 6
R1 # of vertices, v = 4
# of regions, r = e - v + 2 = 4
77
Euler’s Formula …
K5
78
Euler’s Formula …
K5
79
Euler’s Formula …
80
Euler’s Formula …
81
Euler’s Formula …
K3,3 has 6 vertices and 9 edges.
Obviously, v 3 and there are no circuits of length 3.
If K3,3 were planar, then e 2v – 4 would have to be true.
2v – 4 = 2*6 – 4 = 8
So e must be 8.
But e = 9.
So K3,3 is nonplanar.
K3,3
82
Ex:- Suppose that a connected planar simple graph has
20 vertices, each of degree 3. Into how many regions
does a representation of this planar graph split the
plane?
Solution : deg 𝑣𝑖 = 2𝑒
20𝑥3 = 2𝑒 ⟹ 60 = 2𝑒 ⟹ 𝑒 = 30
𝑟 = 𝑒 − 𝑣 + 2 ⟹ 𝑟 = 30 − 20 + 2 = 12
Exercise: a connected planar graph has 17 edges,
dividing the plane into 9 regions. How many vertices
does the graph have? Answer 10.
83