Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Topic 11 Path and Cycle

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Topic X Path and Cycle

11
LEARNING OUTCOMES
By the end of this topic, you should be able to:
1. Explain the concept of path and cycle; and
2. Identify the graphs with EulerÊs path and cycle and graphs with
HamiltonÊs path and cycle.

X INTRODUCTION
Many problems involve determining whether there is a path within a graph that
connects a vertex to another vertex. For example, if we model a computer
network as a graph, we may need to find the best route to deliver a message from
one computer to another computer. In this topic, we are going to discuss about
the concept of path in a graph. Another related concept, that is cycle will also be
discussed in this topic.

11.1 PATH

SELF-CHECK 11.1

Which type of graph is the best to calculate the shortest path


in software engineering?
TOPIC 11 PATH AND CYCLE W 137

The definition of path in a graph is given as follows.

Definition 11.1a: Let v0 and v n be vertices in a graph. A path from v0 to v n of


length n is an alternating sequence of n+1 vertices and n edges beginning with
vertex v0 and ending with vertex v n ,

(v0, e1, v1, e2, v2, . vn-1, en, vn)


in which edge ei is incident on vertices vi-1 and vi for i = 1, .. , n

Example 11.1a

In the graph below, (1, e1, 2, e2, 3, e3, 4, e4, 2) is a path of length 4 from vertex 1 to vertex 2.

Figure 11.1: Example 11.1a

Definition 11.1b: A path that begins and ends at the same vertex is called a
cycle.

Definition 11.1c: A path or cycle is called simple if it does not contain the
same edge more than once.

Example 11.1b
Consider the graph in example 11.1a.

Path (1, e1, 2, e2, 3) is a simple path.


Path (2, e2, 3, e3, 4, e4, 2) is a simple cycle.

We can simplify the notation for a path by just stating the vertices or
edges. For example, the path (2, e2, 3,e3, 4, e4, 2) can also be stated as path
(2,3,4) or path (e2, e3, e4).
138X TOPIC 11 PATH AND CYCLE

ACTIVITY 11.1
1. Determine whether the given path in the graph is a simple path, a
cycle or a simple cycle

(a) (b, b)
(b) (e, d, c, b)
(c) (b, c, d, a, b, e, d, c, b)
(d) (a, d, c, b, e)
(e) (d)

2. Draw a graph having the given properties or explain why no such


graph exists.
(a) 6 vertices each of degree 3
(b) 5 vertices each of degree 3
(c) 4 vertices each of degree 1
(d) 6 vertices; 4 edges
(e) 4 edges; 4 vertices having degree 1, 2, 3, 4
(f) Simple graph; 6 vertices having degree 1, 2, 3, 4, 5, 5
(g) Simple graph; 5 vertices having degree 2, 2, 4, 4, 4

3. For each of the following graphs, state one of its path, simple path,
cycle and simple cycle.

(a) (b)

(c) (d)
TOPIC 11 PATH AND CYCLE W 139

11.2 CONNECTED GRAPH

Definition 11.2a: A graph G is connected if given any vertices v and w in G,


there is a path from v to w.

Example 11.2a

The graph G as shown in figure 11.2 is connected since, given any vertices v
and w in G, there is a path from v to w. For example, there is a path from
vertex 1 to vertex 7, that is (1,2,6,7).

Figure 11.2: Example 11.2a

Example 11.2b

The graph G as shown in figure 11.3 is not connected since, for example, there is
no path from vertex v2 to vertex v5.

Figure 11.3: Example 11.2b


140X TOPIC 11 PATH AND CYCLE

ACTIVITY 11.2
Determine whether the graphs below are connected or not connected:
(a) (b)

(c)

11.3 COMPONENTS

Definition 11.3a: Let G be a graph and let v be a vertex in G. The subgraph


GÊ of G consisting of all edges and vertices in G that are contained in
some path beginning at v is called the component of G containing v.

Example 11.3a

A connected graph has one component, namely itself.

Example 11.3b

Let G be the graph below

Figure 11.4: Example 11.3b


TOPIC 11 PATH AND CYCLE W 141

The component of g containing v3 is the subgraph


G1 = (V1, E1), V1 = {v1, v2, v3}, E1 = { e1, e2, e3}

The component of G containing v4 is the subgraph


G2 = (V2, E2), V2 = {v4}, E1 = { }

The component of G containing v5 is the subgraph


G3 = (V3, E3), V3 = {v5, v6}, E1 = { e4}

ACTIVITY 11.3
Try to think how we can interact with the computer.

11.4 EULER PATH AND CYCLE

SELF-CHECK 11.2
By using Euler path and cycle, how can you solve the problem
if Malaysia would like to add more bridges connection from Johor
Bahru and Singapore?
142X TOPIC 11 PATH AND CYCLE

The concept of Euler Path and Euler Cycle was introduced by Leonhard
Euler in order to solve the famous Konigsberg bridge problem. In the
eighteenth century, there were seven bridges connecting the four regions
that were divided by the branches of Pregel River, as shown in the Figure
11.5 below.

Figure 11.5: Konigsberg bridge problem

The problem was: Is it possible to start at some location in the town, travel across
all the bridges without crossing any bridge twice, and return to the starting
point?

Euler solved the problem by modeling the four regions as vertices and the seven
bridges as edges of a graph, as shown below. The problem was then rephrased
into: Is there a simple cycle in this graph that contains every edge?

Figure 11.6: Solution to problem in figure 11.5


TOPIC 11 PATH AND CYCLE W 143

Definition 11.4a: An Euler path in a graph G is a simple path containing every


edge in G. An Euler cycle in G is a simple cycle containing every edge in G.

The problem of finding an Euler path and cycle can be solved by using these
three theorems.

Theorem 11.4a: If a graph G has an Euler path not an Euler cycle if and only if it
has exactly two vertices of odd degree.

Theorem 11.4b: If a graph G has an Euler cycle, then G is connected and every
vertex has even degree.

Theorem 11.4c: If G is a connected graph and every vertex has even degree,
then G has an Euler cycle.

Example 11.4a

Let G be the graph as shown in figure 11.7. Use theorem 11.4a and 11.4b to verify
that G has an Euler cycle. Find an Euler cycle for G

Figure 11.7: Example 11.4a

We observe that G is connected and the degree of every vertex is even. So by


theorem 11.4b, G has an Euler cycle.
144X TOPIC 11 PATH AND CYCLE

By inspection, we find the Euler cycle.

(v6, v4, v7, v1, v3, v4, v1, v2, v5, v4, v2, v3, v6)

Example 11.4b

The graph below has an Euler path but not an Euler cycle.

Figure 11.8: Example 11.4b

ACTIVITY 11.4

1. Let G be a connected graph with four vertices v1, v2, v3 and v4 of odd
degree. Show that there are paths with no repeated edges from v1 to v2
and from v3 to v4 such that every edge in G is in exactly one of the paths.

2. Let G be a directed graph and let v be a vertex in G. The indegree of


v, in (v), is the number of edges of the form (w, v). The outdegree of
v, out (v), is the number of edges of the form (v, w). A directed Euler
cycle in G is a sequence of edges of the form

(v0, v1), (v1, v2), .. (vn - 1, vn)

where v0 = vn edge in G occurs exactly one time, and all vertices appear.

Show that a directed graph G contains a directed Euler cycle if and only
if the undirected graph obtained by ignoring the directions of the edges
of G is connected and in (v) = out (v) for every vertex v in G.
TOPIC 11 PATH AND CYCLE W 145

11.5 HAMILTON PATH AND CYCLE


The concept of Hamilton path and cycle was named in the honour of Sir William
Rowan Hamilton who has marketed a puzzle in the 1980s in the form of a
dodecahedron.

Definition 11.5a: A Hamilton path in a graph G is a simple path that contains


every vertex in G exactly once.

Definition 11.5b: A Hamilton cycle is a cycle in a graph G that contains each


vertex in exactly once, except for the starting and ending vertex that appears
twice.

Example 11.5a

The cycle (a, b, c, d, e, f, g, a) is a Hamilton cycle for the graph as shown in figure
11.9

Figure 11.9: Example 11.5a

The problem of finding a Hamilton cycle in a graph sounds similar to the


problem of finding an Euler cycle in a graph. However, the problem is actually
quite distinct. For example, the graph G in Example 11.5a does not have an Euler
cycle since there are vertices of odd degree. However, it has a Hamilton cycle.

Furthermore, unlike the situation for Euler cycle, no easily verified necessary and
sufficient conditions are known for the existence of a Hamilton cycle in a graph.
146X TOPIC 11 PATH AND CYCLE

ACTIVITY 11.5
1. Show that none of the graphs contains a Hamilton cycle

2. Give an example of a graph that has an Euler cycle but contains no


Hamilton cycle.
3. Give an example of a graph that has an Euler cycle that is also a
Hamilton cycle.
4. Give an example of a graph that has an Euler cycle and a Hamilton
cycle that are not identical.

The following website has a 32 pages of PDF file format. You can download and
read it offline. The notes are short but comprehensive.
URL: http://appsrv.cse.cuhk.edu.hk/~csc3190/csc3190_lecture12.pdf

You might also like