MATPMD2 Notes Session 4 With Additional Notes-1
MATPMD2 Notes Session 4 With Additional Notes-1
4 Traversability
In this section we look at how we can move around a graph. This is relevant to solving puzzles such as
- “can you trace over this picture without lifting your pen from the paper?”,
and “can I get take 12 steps from any starting point and return to the starting point without retracing
my steps?”
Expressing these questions in graph theoretic terms we are asking (a) if we have an Eulerian graph?,
and (b) is this graph Hamiltonian?
Definition 4.1 The graph G is Eulerian if it is connected and has a closed trail containing each edge of
G, called an Eulerian trail.
Theorem
The following are equivalent:
(i) G is Eulerian,
(ii) G is connected and of even degree,
(iii) G is connected and E(G) can be partitioned into cycles.
Proof
(i) =⇒ (ii) G is connected by definition. Each vertex in the Eulerian trail contributes 2 to the degree
count of a vertex v, all edges of G are used and so deg(v) is even.
(ii) =⇒ (iii) If G has no edges then G is K1 and Eulerian. Otherwise each vertex has degree at least
2 and so G contains a cycle Z. Delete edges in Z to obtain another Eulerian graph; repeat until no
edges remain.
(iii) =⇒ (i) Suppose E(G) is partitioned into cycles Z1 , Z2 , . . . If G is Z1 then Z1 is an Eulerian
trail. Otherwise G contains cycle Z2 such that Z1 and Z2 have a common vertex v. Construct a
“figure-of -eight” Eulerian trail using Z1 and Z2 which passes through v twice. Repeat as necessary.
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
Example 4.1
If possible, find the Eulerian trail in the following graph.
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
Examples 4.2
(iii) The following graph G is not Eulerian since it contains a vertex of odd degree.
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
Definition 4.2 A graph is Hamiltonian if it contains a cycle through all its vertices, called a
Hamiltonian cycle.
Example 4.3
Determining whether or not a graph is Hamiltonian is not an easy matter. If G is a graph on n vertices
then we need to consider all possible n-cycles through n vertices and see if one or more of these
cycles is present in the graph.
Suppose we label the n vertices 1, 2, 3, . . . , n, then the number of possible cycles is n!, the number of
permutations of the n labels. However the cycle 1, 2, 3, . . . , n, 1 is the same as cycle 3, 4, . . . , n, 1, 2, 3
and is also the same as cycle 3, 2, 1, n, n − 1, . . . , 4, 3 thus for any given cycle on n vertices we have n
possible starting points and we can go around the cycle two ways. This means that in a worse case
scenario we would need to inspect 2n n!
= (n−1)!
2
possible cycles to see if they gave us a Hamiltonian
cycle.
There are certain strategies which we can use to attempt to show a graph is not Hamiltonian.
(i) A Hamiltonian cycle passes through each vertex precisely once and so uses precisely two edges
incident with each vertex. Mark all edges incident with vertices of degree 2.
(a) If these edges form a cycle smaller than an n cycle then the graph is not Hamiltonian
because an n-cycle does not contain a cycle shorter than an n-cycle.
(b) Inclusion of these edges may exclude other edges from consideration, either to avoid a
cycle of length less than n, or because they use two edges from a vertex of degree greater
than 2. Mark all excluded edges.
Repeat until all edges are either excluded or included. If all the included edges form a
Hamiltonian cycle then the graph is Hamiltonian. If not then the problem may have been
sufficiently simplified to determine by inspection whether or not a Hamiltonian cycle exists.
(ii) Recall that a bipartite graph contains two sets of isolated vertices. If we colour one set black and
the other set white then we have obtained a 2-colouring of the graph; we have coloured the
graph with two colours in such a way that adjacent vertices are of different colours. Any graph
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
with a 2-colouring is bipartite. Also a bipartite graph does not contain an odd cycle since the
vertices in a cycle must be taken from alternate independent sets and in an odd cycle the last
edge would need to be between two non-adjacent vertices. Thus a bipartite graph with an odd
number of vertices is not Hamiltonian. Furthermore, a graph with an odd number of vertices
which has a 2-colouring is not Hamiltonian since bipartite.
Examples 4.4
(iii) Find a Hamiltonian cycle in the following graph which contains the edge (4, 7).
Theorem [Ore]
If |V (G)| = n ≥ 3 and deg v+ deg u ≥ n whenever u 6∼ v then G is Hamiltonian.
A weighted graph has weights assigned to its edges; the weight of the graph W (G) is the sum of the
edge weights. Every connected weighted graph has a minimal spanning tree, i.e. a spanning tree of
least weight; not necessarily unique. There are many algorithms for obtaining a minimal spanning tree.
Prim’s algorithm
Example 4.5
Demonstrate the use of Prim’s algorithm in finding a minimal spanning tree for the following
weighted graph. State the weight of the minimum spanning tree.
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
4.1 Connectivity
Recall that a graph is connected if for every u, v pair of vertices in the graph there exists a uv path. A
connected graph has one component. If a graph is not connected then it is unconnected or
disconnected and consists of more than one component.
Definition 4.1.1 The (vertex) connectivity κ(G) of graph G is the smallest number of vertices whose
removal results in a disconnected or trivial graph. [The trivial graph is K1 .]
Recall that deletion of a vertex results in the deletion of ever edge incident with that vertex. An edge is
a vertex pair and deletion of one vertex from that pair will remove the pair.
Examples 4.1.1
(i) Consider cycle Cn . Removing one vertex will result in a path Pn−1 which is connected.
Removal of two adjacent vertices will result in a path Pn−2 , also connected. Removal of two
non-adjacent vertices will result in a disconnected graph: Pi ∪ Pj , i, j ≥ 1 where i + j = n − 2.
Thus κ(Cn ) = 2.
(iii) Consider the complete graph Kn . Removal of a vertex results in Kn−1 , also connected. Removal
of subsequent vertices will result in a successively smaller complete graphs. Removal of n − 1
vertices will result in K1 , the trivial graph and so κ(Kn ) = n − 1. Note that any complete graph
cannot be disconnected.
Definition 4.1.3 The edge connectivity λ(G) is the smallest number of edges whose removal
disconnects G.
Note that removal of an edge does not remove a vertex. The edge set of a graph is the subset of all
possible unordered vertex pairs so deletion of an edge will remove a vertex pair from the edge set but
will not affect the vertex set.
Examples 4.1.2
(i) Let G be the cycle Cn . Deleting a single edge results in Pn which is connected. Deleting two
consecutive edges will result in the graph K1 ∪ Pn−1 which is disconnected. Deleting any two
edges will result in the (disjoint) union of two paths. Thus λ(Cn ) = 2.
(iii) λ(Kn ) = n − 1. Consider Kn . Deletion of all edges incident with a single vertex will
disconnect that vertex resulting in a disconnected graph. Clearly removing fewer edges would
not disconnect the graph. Since Kn is complete it has all possible edges; the degree of each
vertex is n − 1 so we must remove n − 1 edges to disconnect the graph.
Remark 4.1.1 Always κ(G) ≤ λ(G) ≤ δ(G) where δ(G) = min {deg (v) : v ∈ V (G)}.
Example 4.1.3
Verify that the inequality κ(G) ≤ λ(G) ≤ δ(G) is satisfied for the following graph G.
is satisfied.
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
Definition Two s − t paths are disjoint if they have no vertices in common other than s and t.
Definition 4.2.1 The degree matrix is a diagonal matrix where the diagonal entries are the degrees of
each vertex.
Definition 4.2.2 The Laplacian matrix for a simple graph G is defined as L = D − A(G) where D is
the degree matrix, and A(G) is the adjacency matrix.
Definition 4.2.3 The algebraic connectivity of a graph G, a(G), is the second smallest eigenvalue of
the Laplacian matrix.
[It can be shown that, for a connected graph, the smallest eigenvalue of L is zero with corresponding
eigenvector j.]
Example 4.2.1 Find the eigenvalues of the Laplacian matrix for the graph with adjacency matrix.
State the algebraic connectivity of G.
0 1 1 0 1 0
1 0 1 0 0 0
1 1 0 0 1 0
A=
0 0 0 0 0 1
1 0 1 0 0 0
0 0 0 1 0 0
Solution
The row sums give the degree sequence: 3, 2, 3, 1, 2, 1 in corresponding order and so
3 −1 −1 0 −1 0
−1 2 −1 0 0 0
−1 −1 3 0 −1 0
L=D−A=
0 0 0 1 0 −1
−1 0 −1 0 2 0
0 0 0 −1 0 1
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
0 1 1 0 1 0
1 0 1 0 0 0
1 1 0 0 1 0
A=
0 0 0 0 0 1
1 0 1 0 0 0
0 0 0 1 0 0
Intuitively connectivity should increase with the addition of edges, with the complete graph with all
possible edges having the maximum possible algebraic connectivity.
Example 4.2.2
Let G = Kn with Laplacian matrix L = (n − 1)I − A. The eigenvalues are n with multiplicity n − 1
and 0 with multiplicity 1. Thus the algebraic connectivity a(Kn ) is n.
Since the eigenvalues of L are non-negative we conclude that if G is a graph on n vertices,
0 ≤ a(G) ≤ n.
Some measure of algebraic connectivity between 0 and 1 may be more useful which suggests the idea
of normalizing this measure by dividing by n:
a(G)
0≤ ≤ 1.
n
UNIVERSITY OF STIRLING MATPMD2
Computing Science & Mathematics 2020
a(G) ≤ a(G − Uk ) + k
Example
It can be shown that a(Kr,s ) = min{r, s}. As an example, a(K2,5 ) = 2 ≤ κ(K2,5 ) = 2.
Now K1,4 can be obtained from K2,5 by removing 2 vertices and we have
2 = a(K2,5 ) ≤ 1 + 2 = a(K1,4 ) + k
Further examples