Lecture 8: Paths, Cycles and Connectedness
Lecture 8: Paths, Cycles and Connectedness
Definition 1.4 A cycle is a closed trail in which the “first vertex = last vertex” is
the only vertex that is repeated.
Figure 1: Graph G1
8-1
Figure 2: Graph G2
Algorithm [2]
8-2
• Idea: Maintain a set R of vertices that have been reached but not searched and a
set S of vertices that have been searched. The set R is maintained as a First-In
First-Out list (queue), so the first vertices found are the first vertices explored.
• Initialization: R = u, S = Φ, d(u, u) = 0
• Iteration: As long as R 6= Φ, we search from the first vertex v of R. The neigh-
bours of v not in S∪R are added to the back of R and assigned distance d(u, v)+1,
and then v is removed from the front of R and placed in S.
e.g. In the graph G3 in Figure 4 one breadth-first search from u finds the vertices
in the order u, a, g, b, f, c, d, e.
Algorithm [4]
Figure 4: Graph G3
8-3
Question: How to find whether a cycle is present in the graph?
Answer: Traverse the graph keeping track of vertices visited. If a vertex is reached again,
a cycle is present.
Definition 1.5 A graph is connected if it has a u-v path for every pair of vertices.
u, v ∈ V (G)
Definition 1.6 The components of a graph are its maximal connected sub-
graphs.
e.g. Figure 5 shows a connected graph with a cut-edge and the components formed
after its removal.
2. Distances in Graphs
Definition 1.8 The distance between a pair of vertices is the length of the shortest
path between them.
Definition 1.9 The diameter of a graph G is the longest shortest path over all the
vertices of G.
Definition 1.11 The radius of a graph G is the minimum of the eccentricities of its
vertices.
8-4
Figure 5: (a) A connected graph with a cut-edge vx vy ; (b), (c) The two components after
removing the cut-edge.
8-5
Figure 7: A graph with radius 2. f has the minimum eccentricity of 2.
2 Proofs
Theorem 2.1 A graph is connected if and only if for every partition of its vertices into
two non empty sets, there is an edge with end points in both sets.
Proof. [3] Let G be a connected graph. Given a partition of V (G) into non empty sets S, T .
Choose u S and v T . Since G is connected, G has a u, v -path P . After its last vertex
in S, P has an edge from S to T .
We show that if G is not connected then for some partition there is no edge across. In
particular, if G is disconnected, then let it be a component of G. Since H is a maximal
connected sub graph of G and the connection relation is transitive, there can not be an
edge with one end point in V (H) and the other end point outside. Thus for the partition of
V (G) into V (H) and V (G) − V (H) there is no edge with end points in both of these sets.
2
Theorem 2.2 An edge of a graph is cut edge if and only if it does not belong to any cycle.
Proof. [2] Let, e be an edge in a graph G with end points x and y, and let H be the com-
ponent containing e. Since definition of e affects no other component, it suffices to prove
that H − e is connected if and only if e belongs to a cycle. See Figure 8
8-6
Figure 8: Theorem 2.2
Theorem 2.3 (König[1936]) A graph is bipartite if and only if it has no odd cycle.
Proof. [2] N ecessity. Let G be a bipartite graph. Every walk alternates between the two
sets of a bipartition, so every return to the original partite set happens after an even number
of steps. Hence G has no odd cycle. See Figure 9
Let, X = vV (H) : f (v) is even and X = vV (H) : f (v) is odd. An edge v, v 0 within
X or Y would create a closed odd walk using a shortest u, v-path, the edge vv 0 , and the
reverse of a shortest u, v-path. Such a walk must contain an odd cycle(because every closed
odd walk contains an odd cycle)which contradicts our hypothesis. Hence X and Y are
independent sets. Also X ∪ Y = V (H), so H is an X − Y - bigraph. 2
Proof. [1] Pick up a random vertex v in G, calculate the length of the shortest simple path
from v to any other node, call this value distance from v, and divide nodes into 2 groups
8-7
according to the parity of their distance to v. If we can prove that nodes belong to the
same group can not be adjacent, then we know that we actually get a partition of the G
that fulfill the definition of bipartite graph.
Now, to introduce contradiction, assume two nodes x, y with both even or odd distance
from v are adjacent, then the shortest simple path < v, x >, < v, y > and edge x, y contains
a cycle with odd length, which is contradictory to that G has no cycles of odd length. In
other words, nodes both with even or odd distance from v can not be adjacent, which is
exactly what we need.
Again to prove that < v, x > and < v, y > together with < x, y > contains a cycle with
odd length is obvious when < v, x > and < v, y > are disjoint. When that’s not the case,
let’s give the last node shared by < v, x > and < v, y > the name v. So the three nodes
v, x, y forms a cycle with length
where len() means the length of the shortest path.As len(< v, x >) and len(< v, y >)
are both even or odd, then L must be odd. Therefore, in both cases, disjoint or not, <
v, x >, < v, y > and < x, y > contains a cycle with odd length, which is again contradictory.
So that concludes our proof that G is bipartite. 2
Theorem 2.5 Suppose G has a vertex set (v1 , v2 ......vn ) with n ≥ 3, if it has at least two
of its sub graphs ( G − v1 , G − v2 , .....G − vn ) are connected then G is connected.
Proof. Let, us say that G is not connected i.e there exist at least one vertex u G from
which there is no path to at least another vertex v G. See Figure 10
Suppose we take two random vertices vi and vj for which we have two different connected
sub graphs (G − vi ) and (G − vj ). Now, in case of the sub graph (G − vi ), there exist a
path from the vertex vj to all other vertices because it is connected. Again, in case of the
sub graph (G − vj ), there exist a path from the vertex vi to all other vertices because it is
also connected.
So, if we take any other common vertices of these two sub graphs (say vk ), then we have
a path from vi to vk and from vk to vj . From that we can conclude that we can also have
a path from vi to vj . As we have chosen vi and vj randomly, so that is also true for all
the other vertices, i.e there exist a path between every pair of vertices. That concludes our
proof that the graph G is connected. 2
8-8
Figure 10: Theorem 2.5
References
[1] StackExchange. If a graph has no cycles of odd length, then it is bipartite:
is my proof correct? http://math.stackexchange.com/questions/61920/
if-a-graph-has-no-cycles-of-odd-length-then-it-is-bipartite-is-my-proof-correc,
[Online, accessed 28 August, 2014].
[2] Douglas B. West. Introduction To Graph Theory. Pearson Prentice Hall, 2 edition.
[3] Douglas B. West. Introduction To Graph Theory Solution Manual. Summer 2005 edition.
8-9