DSLec 14
DSLec 14
By
Syed Ijaz Hussain Bukhari
PATHS AND CIRCUITS
DEFINITIONS:
Let G be a graph and let v and w be vertices in graph G.
1. WALK
A walk from v to w is a finite alternating sequence of adjacent vertices and edges
of G.
Thus a walk has the form
v0e1v1e2 … vn-1envn
where the v’s represent vertices, the e’s represent edges v0=v , vn=w, and for all
i = 1, 2 … n, vi-1 and vi are endpoints of ei.
2. CLOSED WALK
A closed walk is a walk that starts and ends at the same vertex.
3. CIRCUIT
A circuit is a closed walk that does not contain a repeated edge.
Thus a circuit is a walk of the form
v0e1v1e2 … vn-1 en vn
where v0 = vn and all the ei, s are distinct.
4. SIMPLE CIRCUIT
A simple circuit is a circuit that does not have any other
repeated vertex except the first and last.
Thus a simple circuit is a walk of the form
v0e1v1e2 … vn-1envn
where all the ei,s are distinct and all the vj,s are distinct except that v0 = vn
5. PATH
A path from v to w is a walk from v to w that does not contain a repeated
edge.
Thus a path from v to w is a walk of the form
v = v0e1v1e2 … vn-1envn = w
where all the ei,s are distinct (that is ei ek for any i k).
6. SIMPLE PATH
A simple path from v to w is a path that does not contain a
repeated vertex.
Thus a simple path is a walk of the form
v = v0e1v1e2 … vn-1envn= w
where all the ei,s are distinct and all the vj,s are also distinct (that is, vj vm for any
j m).
Repeated Repeated Vertex Starts and Ends at Same Point
Edge
closed walk allowed Allowed yes(means, where it starts also ends at that point)
simple path no no No
EXERCISE
In the graph below, determine whether the
following walks are paths, simple paths, closed
walks, circuits, simple circuits, or are just walks.
(a) v 1e 2v 2e 3v 3e 4v 4e 5v 2e 2v 1e 1v 0
(b) v 1v 2v 3v 4v 5v 2 v1 v3
e1 e2 e3
(c) v 4v 2v 3v 4v 5v 2v 4 e10
v0
e9
v2
e4
e7 e5
(d) v 2v 1v 5v 2v 3v 4v 2 e8
(e) v 0v 5v 2v 3v 4v 2v 1 v5 e6 v4
(f) v 5v 4v 2v 1
(a)
• SOLUTION: e1
v1
e2
v2
e3
v3
v0 e4
(a) v1e2v2e3v3e4v4e5v2e2v1e1v0 e5
v5 v4
v0 v2
v5 v4
In this graph vertex v2 is repeated twice. As no edge is
repeated so the graph is a path
v v 3
(c) v4v2v3v4v5v2v4
1
v
v0 2
v5 v4
v0 v2
v5 v4
In this graph, vertex v2 is repeated and the graph starts and end at the
same vertex (i.e. at v2) and no edge is repeated, hence the above
graph is a circuit v1 v3
(e) v0v5v2v3v4v2v1 v2
v0
v5 v4
v2
v0
v5 v4
v8
v9
SOLUTION:
As deg (v1) =5, an odd degree so the graph
has not an Euler circuit.
EXERCISE:
Determine whether the following graph has Euler circuit.
c d
b
h g
a
f e
i
SOLUTION:
From above clearly deg(a)=2, deg(b)=4, deg(c)=4, deg(d)=4,
deg(e)=2, deg(f)=4, deg(g)=4, deg(h)=4, deg(i)=4
Since the degree of each vertex is even, and the graph has Euler Circuit.
One such circuit is:
abcdefgdfihcghbia
EULER PATH
DEFINITION:
Let G be a graph and let v and w be two vertices of G. An
Euler path from v to w is a sequence of adjacent edges and
vertices that starts at v, and end at w, passes through every
vertex of G at least once, and traverses every edge of G exactly
once.
COROLLARY
Let G be a graph and let v and w be two vertices of G. There is
an Euler path from v to w if, and only if, G is connected, v and w
have odd degree and all other vertices of G have even degree.
HAMILTONIAN CIRCUITS
DEFINITION:
Given a graph G, a Hamiltonian circuit for G is a
simple circuit that includes every vertex of G. That is,
a Hamiltonian circuit for G is a sequence of adjacent
vertices and distinct edges in which every vertex of G
appears exactly once.
EXERCISE:
Find Hamiltonian Circuit for the following graph.
b d
c
a h e
g f
SOLUTION:
The Hamiltonian Circuit for the following graph is:
abdefcgha
Another Hamiltonian Circuit for the following graph
could be:
abcdefgha