Chapter 5
Graph Paths and Circuits
2/1/2013
ITCP 213 - Discrete Structure 1
An Euler path in graph G:
◦ Is a path that includes exactly once all the edges of G.
An Euler circuit in graph G:
◦ Likewise, but with same starting and ending vertices
2/1/2013
ITCP 213 - Discrete Structure 2
Def. 11.15 Let G=(V,E) be an undirected graph or multigraph with no isolated vertices. Then G is said to have an Euler circuit
if there is a circuit in G that traverses every edge of the graph exactly once. If there is an open trail from a to b in G and this trail traverses each edge in G exactly once, the trail is called an
Euler trail.
Euler Paths and Circuits
2/1/2013
ITCP 213 - Discrete Structure 3
Vertex Degree: Euler Trails and Circuits
Corollary 11.2 An Euler trail exists in G if and only if G is connected and has exactly two vertices of odd degree.
two odd degree vertices
a b add an edge
Theorem 11.4 A directed Euler circuit exists in G if and only if G is connected and in-degree(v)=out-degree(v) for all vertices v.
one in, one out
Can you think of an algorithm to construct an Euler circuit?
2/1/2013
ITCP 213 - Discrete Structure 4
Examples:
◦ The path a, b, c, d in (a) is an Euler circuit since all edges are included exactly once.
◦ The graph (b) has neither an Euler path nor circuit.
◦ The graph (c) has an Euler path a, b, c, d, e, f but not an Euler circuit.
2/1/2013
ITCP 213 - Discrete Structure 5
Historical note
◦ In Europe: Konigsberg 7-bridge problem
Konigsberg, originally in Prussia, now in Russia
Four sections, two rivers, seven bridges
Euler solved this problem in 1736; the origin of graph theory
2/1/2013 ITCP 213 - Discrete Structure
Problem: Draw a path (or circuit) with a pencil in such a way that you trace over each bridge once and only once and you complete the 'plan' with one continuous pencil stroke
2/1/2013
ITCP 213 - Discrete Structure 7
Problem 2
Suppose they had decided to build one fewer bridge in Konigsberg, so that the map looked like this:
Problem 3
Does it matter which bridge you take away? What if you add bridges? Come up with some maps on your own, and try to 'plan your journey' for each one
2/1/2013
ITCP 213 - Discrete Structure 8
Problem: Draw a path (or circuit) with a pencil in such a way that you trace over each bridge once and only once and you complete the 'plan' with one continuous pencil stroke
2/1/2013
ITCP 213 - Discrete Structure 9
Theorem:
◦ A connected multigraph has an Euler circuit if and only if the degree of each vertex is even.
Why ?
2/1/2013
ITCP 213 - Discrete Structure 10
Theorem:
◦ A connected multigraph has an Euler circuit if and only if the degree of each vertex is even.
Proof (Basic idea) :
◦ For each vertex, if there is one “in”, there must be one “out”, because this is a circuit.
2/1/2013
ITCP 213 - Discrete Structure 11
All degrees are odd. Hence no Euler circuit
for the Konigsberg bridges problem.
2/1/2013
ITCP 213 - Discrete Structure 12
Examples:
◦ Construct an Euler circuit for the following graph.
◦ Solution:
The graph is connected and the degree of each vertex is even. So, it has an Euler circuit.
2/1/2013
ITCP 213 - Discrete Structure 13
◦ Procedure for constructing an Euler circuit:
Select any vertex u, and construct a path P
1from u to u by randomly selecting unused edges for as long as
possible.
e.g. if we start at G, we may construct the path:
P1: G, h, E, d, C, e, F, g, E, j, H, k, G
2/1/2013
ITCP 213 - Discrete Structure 14
◦ Procedure (continued):
Since the multigraph is connected, there must be a vertex in P
1that is incident with an edge not in P
1.
In this case, the vertices E and H are such vertices.
Arbitrarily choose one of these, say E, and construct a path P
2from E to E.
P2: E, c, B, a, A, b, D, f, E
2/1/2013
ITCP 213 - Discrete Structure 15
◦ Procedure (continued):
Enlarge P
1to include the path P
2by replacing any one occurrence of E in P
1by P
2.
e.g. replace the first occurrence of E in P1:
P1: G, h, E, c, B, a, A, b, D, f, E, d, C, e, F, g, E, j, H, k, G
Repeat the above process.
Construct a path P3 from H to H and enlarge P1 by P3, we obtain the Euler circuit.
P1: G, h, E, c, B, a, A, b, D, f, E, d, C, e, F, g, E, j, H, m, J, l, H, k, G
2/1/2013 ITCP 213 - Discrete Structure
Theorem:
◦ A connected multigraph has an Euler path but not an Euler circuit if an only if it has exactly two
vertices of odd degree.
Why ?
2/1/2013
ITCP 213 - Discrete Structure 17
Theorem:
◦ A connected multigraph has an Euler path but not an Euler circuit if an only if it has exactly two
vertices of odd degree.
Proof:
◦ If: add one edge connects the two vertices of odd degree
2/1/2013
ITCP 213 - Discrete Structure 18
K2
K3
K4
K5
K6
K8
K2: Euler path – ? Euler cycle – ? K3: Euler path – ? Euler cycle – ? K4: Euler path – ? Euler cycle – ? K5: Euler path – ? Euler cycle – ? K6: Euler path – ? Euler cycle – ? K8: Euler path – ? Euler cycle – ?
2/1/2013
ITCP 213 - Discrete Structure 19
K2
K3
K4
K5
K6
K8
K2: Euler path – Yes Euler cycle – No K3: Euler path – No Euler cycle – Yes K4: Euler path – No Euler cycle – No K5: Euler path – No Euler cycle – Yes K6: Euler path – No Euler cycle – No K8: Euler path – No Euler cycle – No
2/1/2013
ITCP 213 - Discrete Structure 20
Planar Graphs
Def. 11.17 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.
2/1/2013
ITCP 213 - Discrete Structure 21
Complete graphs - K
n:
◦ How many edges of Kn? n(n-1)/2
K
1K
2K
3K
4K
5Planar Graphs
Ex. 11.14,11.15 K1,K2,K3,K4 are planar, Kn for n>4 are nonplanar.
2/1/2013
ITCP 213 - Discrete Structure 22
Planar Graphs
Ex. 11.14,11.15 K1,K2,K3,K4 are planar, Kn for n>4 are nonplanar.
K5 is nonplanar
K4
2/1/2013
ITCP 213 - Discrete Structure 23
Planar Graphs
2/1/2013
ITCP 213 - Discrete Structure 24
Planar Graphs
K4,4
K3,3 is not planar.
Therefore, any graph containing K5 or K3,3 is nonplanar.
Def. 11.18 bipartite graph and complete bipartite graphs (Km,n)
2/1/2013
ITCP 213 - Discrete Structure 25
Planar Graphs
Def. 11.19 elementary subdivision (homeomorphic operation)
u w u v w
G1 and G2 are called homeomorphic if they are isomorphic or if they can both be obtained from the same loop-free undirected graph H by a sequence of elementary subdivisions.
a b
c
d e
a b
c
d e
a b
c
d e
a b
c
d e
Two homeomorphic graphs are simultaneously planar or nonplanar.
2/1/2013
ITCP 213 - Discrete Structure 26
2/1/2013
ITCP 213 - Discrete Structure 27
Planar Graphs
Theorem 11.5 (Kuratowski's Theorem) A graph is nonplanar if and only if it contains a subgraph that is homeomorphic to
either K5 or K3,3. Ex. 11.17 Petersen graph
a
b
d c
e f
g h
i j
a subgraph homeomorphic to K3,3 j a
d
e f b
g h
i c
Petersen graph is nonplanar.
2/1/2013
ITCP 213 - Discrete Structure 28
Planar Graphs
2/1/2013
ITCP 213 - Discrete Structure 29
2/1/2013
ITCP 213 - Discrete Structure 30
Planar Graphs
K4
R1 R2
R3
R4
A planar graph divides the plane into several regions (faces), one
of them is the infinite region.
Theorem 11.6 (Euler's planar graph theorem) For a connected planar graph or multigraph:
v – e + r = 2
number
of vertices number of edges
number of regions
V = 4 ,e = 6 , r = 4 , v – e + r = 2
2/1/2013
ITCP 213 - Discrete Structure 31
Planar Graphs
degree of a region (deg(R)): the number of edges traversed in a shortest closed walk about the boundary of R.
R1 R2
R3
R4
R5 R6
R7
R8 two different embeddings
deg(R1)=5,deg(R2)=3 deg(R3)=3,deg(R4)=7
deg(R5)=4,deg(R6)=3 deg(R7)=5,deg(R8)=6
deg( R
i) deg( R ) | | E
i i
i
1 4
5 8
18 2 9 2
abghgfda
a b
c
d f
g h
2/1/2013
ITCP 213 - Discrete Structure 32
Planar Graphs
. 6 - 3 or
, - 3 6 so 3, 3
+ 2 - +
-
= 2
theorem, Eulers
From .
3 2
and by
determined regions
the of
degrees the
of sum the
|=
| 2
= 2 ly, Consequent
3.
degree has
region each
Hence, edges.
e least thre at
contains region)
infinite the
(including region
each of
boundary
the , multigraph a
not is
and free
- loop a
is Since
: Proof
. 6 - 3
and 2
3 Then regions.
and 2,
>
|=
| ,
|=
| graph w ith
planar connected
free -
loop a
be ) , (
= Let 11.3
Corollary
v e
e e v
e v e
v r e v
r e
G
r E
e G v
e
e r
r e
E v V
E V G
Only a necessary condition, not sufficient.
2/1/2013
ITCP 213 - Discrete Structure 33
Planar Graphs
Ex. 11.18
For K5 , e =10, v = 5 , 3v – 6 = 9 < 10 = e.
Therefore, by Corollary 11.3, K5 is nonplanar.
Ex. 11.19
For K3,3, each region has at least 4 edges, hence 4r 2e. If K3,3 is planar, r = e - v + 2 = 9 – 6 + 2 = 5.
So 20=4r 2e = 18, a contradiction.
. 6 - 3
and 2
3 Then regions.
and 2,
>
|=
| ,
|=
| graph with
planar connected
free - loop a
be ) , (
= Let
v e
e r
r e
E v V
E V G
2/1/2013
ITCP 213 - Discrete Structure 34
Dual graph
2/1/2013
ITCP 213 - Discrete Structure 35
2/1/2013
ITCP 213 - Discrete Structure 36
Planar Graphs
A dual graph of a planar graph
a b
c d
e f
g 1
2
3 4 6 5
1
6 5
4 2
3
An edge in G corresponds with an edge in Gd.
2/1/2013
ITCP 213 - Discrete Structure 37
2/1/2013
ITCP 213 - Discrete Structure 38
Planar Graphs
Def. 11.20 cut-set: a subset of edges whose removal increase the number of components
Ex. 11.21
a
b
c
d
e f
g
h
cut-sets: {(a,b),(a,c)}, {(b,d),(c,d)},{(d,f)},...
a bridge
For planar graphs, cycles in one graph correspond to cut-sets in a dual graphs and vice versa.
2/1/2013
ITCP 213 - Discrete Structure 39
A Hamilton path in graph G:
◦ Is a path that includes each vertex once and only once.
2/1/2013
ITCP 213 - Discrete Structure 40
Examples:
◦ G
1has a Hamilton path: a, b, c, d, e, and cycle.
◦ G
2has only a Hamilton path: a, b, c, d.
◦ G
3has no.
◦ In general, no efficient method to find such a path
2/1/2013
ITCP 213 - Discrete Structure 41
2/1/2013
ITCP 213 - Discrete Structure 42
2/1/2013
ITCP 213 - Discrete Structure 43
Hamilton Paths and Cycles
a path or cycle that contain every vertex Unlike Euler circuit, there is no known necessary and sufficient condition for a
graph to be Hamiltonian.
Ex. 11.24
a b c
d e f
g h
i
There is a Hamilton path, but no Hamilton cycle.
2/1/2013
ITCP 213 - Discrete Structure 44
Hamilton Paths and Cycles
Ex. 11.25
x
y
y y y
x x
x y
y
start labeling from here
4x's and 6y's, since x and y must interleave in a Hamilton path (or cycle),
the graph is not Hamiltonian
The method works only for bipartite graphs.
2/1/2013
ITCP 213 - Discrete Structure 45
Hamilton Paths and Cycles
Ex. 11.26 17 students sit at a circular table, how many sittings are there such that one has two different neighbors each time?
Consider K17, a Hamilton cycle in K17 corresponds to a seating arrangements. Each cycle has 17 edges, so we can have
(1/17)17(17-1)/2=8 different sittings.
1 2
3
4
5
6
17 16 15
1,2,3,4,5,6,...,17,1
1 2
3
4
5
6
17 16 15
1,3,5,2,7,4,...,17,14,16,1
1 2
3
4
5
6
17 16 15
1,5,7,3,9,2,...,16,12,14,1 14
2/1/2013
ITCP 213 - Discrete Structure 46
2/1/2013
ITCP 213 - Discrete Structure 47
Hamilton Paths and Cycles
Theorem 11.7 Let be a complete directed graph, i. e. ,
has vertices and for any distinct pair , of vertices, exactly one of the edges ( , ) or ( , ) is in Such a graph (called a
) always contains a directed Hamilton path.
Proof: Let 2 with a path containing -1 edges
( If = , we' re finished. If
not, let be a vertex that doesn' t appear in
* *
*
K K
n x y
x y y x K
tournament
m p m
v v v v v v m n
v p
n n
n m
m m
m
. , ), ( , ), , ( , ).
.
1 2 2 3
1case 1. v v1 v2 ...vm
case 2. v1 v2 ...vk v vk+1 ...vm case 3. v1 v2 ...vm v
2/1/2013
ITCP 213 - Discrete Structure 48
Hamilton Paths and Cycles
Ex. 11.27 In a round-robin tournament each player plays every other player exactly once. We want to somehow rank the players
according to the result of the tournament.
not always possible to have a ranking where a player in a certain position has beaten all of the opponents in later positions
a b c
but by Theorem 11.7, it is possible to list the players such that each has beaten the next player on the list
2/1/2013
ITCP 213 - Discrete Structure 49
Hamilton Paths and Cycles
Theorem 11.8 Let = ( , ) be a loop - free graph with
| |= 2. If deg( ) + deg( ) -1 for all , , , then has a Hamilton path.
G V E
V n x y n x y V x y
G
2/1/2013
ITCP 213 - Discrete Structure 50
Hamilton Paths and Cycles
Corollary 11.4. If deg( ) -
for all vertices, then the graph has a Hamilton path.
Theorem 11.9 Let = ( , ) be a loop - free undirected graph with | |= 3. If deg( ) + ( ) for all nonadjacent
, , then contains contains a Hamilton cycle.
v n
G V E
V n x y n
x y V G
1 2
deg
2/1/2013
ITCP 213 - Discrete Structure 51
Hamilton Paths and Cycles
Corollary 11.6 If = ( , ) is a loop - free unirected graph with
| |= 3, and if | | -
then has a Hamilton cycle.
Proof: Let , where ( , ) . Remove all edges connected either to or and then , . Let = ( ' , ' ) denote the resulting subgraph. Then | |=| ' |+ ( ) + ( ). Since | ' |= - ,
| ' | -
Consequently, -
| ' |+ ( ) + ( ) -
G V E
V n E n
G
a b V a b E
a b a b H V E
E E a b V n
E n n
E E a b
n
1
2 2
2 2
2
1
2 2
2
,
deg deg
. | | deg deg
2 1
2 2 2
2
+ ( ) + ( ). Therefore, ( ) + ( )
- -
and has a Hamilton cycle.
deg a deg b deg a deg b
n n
n G
2/1/2013
ITCP 213 - Discrete Structure 52
Hamilton Paths and Cycles
A related problem: the traveling salesman problem a
b
c
d e 3
4 1
3
5 4
3
2
Find a Hamilton cycle of shortest total distance.
2
For example, a-b-e-c-d-a with total cost=
1+3+4+2+2=12.
2/1/2013
ITCP 213 - Discrete Structure 53
Other Types of Graphs:
◦ Multigraphs : Section 11.1.
◦ Directed Graphs : Section 11.1.
◦ Directed Multigraphs : Section 11.1.
Paths and Circuits:
◦ Euler Paths and Circuits : Section 11.3.
◦ Planer graph : Section 11.4.
◦ Hamilton Paths and Circuits : Section 11.5.
2/1/2013
ITCP 213 - Discrete Structure 54