0% found this document useful (0 votes)
10 views

Week 11.3 Graphs02

The document discusses graphs and graph theory concepts like paths, circuits, connectivity, Euler paths and circuits, and Hamilton paths and circuits. It provides definitions, examples, theorems and proofs related to determining if a graph has an Euler or Hamilton path/circuit based on its properties.

Uploaded by

Ayusha Patra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Week 11.3 Graphs02

The document discusses graphs and graph theory concepts like paths, circuits, connectivity, Euler paths and circuits, and Hamilton paths and circuits. It provides definitions, examples, theorems and proofs related to determining if a graph has an Euler or Hamilton path/circuit based on its properties.

Uploaded by

Ayusha Patra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

CS 182: Graphs 2 (Week 11.3 – KR 10.4, 10.

5)

Elisha Sacks and Sarah Sellke


Announcements and Reminders

Homework
▶ Homework 8: Grades released on Gradescope and Solution
posted on Brightspace
▶ Statistics: Mean=84.27, Median=89, Std Dev=15.3
▶ Regrade requests open until Tuesday April 2nd at 11:00pm
▶ Homework 9: Due Friday April 5th at 11:00pm EST on
Gradescope
Connectivity

▶ Paths, Circuits, and Connectivity


▶ Euler Paths and Circuits
▶ Hamilton Paths and Circuits
Paths in Undirected Graphs and Multigraphs

▶ A path is a sequence of edges that begins at a vertex and


travels from vertex to vertex along edges.
▶ Numerous problems can be modeled with paths such as:
▶ determining whether a message can be sent between two
computers.
▶ efficiently planning routes for mail delivery.
Paths

▶ A path of length k from vertex u to vertex v is a sequence of


k edges e1 , · · · , ek with
e1 = (u, x1 ), e2 = (x1 , x2 ), · · · , ek−1 = (xk−1 , xk ) and xk = v
▶ When the graph is simple, we denote this path by its vertex
sequence u, x1 , x2 , · · · , xk−1 , v .
▶ The path is a circuit (cycle) if it begins and ends at the same
vertex (i.e., u = v).
▶ A path or circuit is simple if it does not contain the same
edge more than once.
Example: Paths

▶ a, d, c, f, e is a simple path of length 4.


▶ d, e, c, a is not a path because e is not connected to c.
▶ b, c, f, e, b is a circuit of length 4.
▶ a, b, e, d, a, b is a path of length 5, but it is not a simple path.
Connectedness
▶ Vertices a and b are connected if there is a path from a to b.
▶ A graph is called connected if every pair of vertices are
connected.
Example:
▶ G1 is connected.
▶ G2 is not connected (no path between vertices a and f).
Connected Components 1

b h z
u v
y g
d c
a
x w f
e
▶ Connection is an equivalence relation.
▶ Reflexive: trivial.
▶ Symmetric: If there is a path from u to v , then there is a path
from v to u.
▶ Transitive: If there is a path from u to v and a path from v to
w , then there is a path from u to w .
▶ The equivalence classes are called connected components.
▶ The example has three connected components.
Connected Components 2

Figure: Graph H with three connected components.

▶ The graph H is the union of three disjoint subgraphs


H1 , H2 , and H3 .
▶ H1 , H2 , and H3 are the three connected components of H.
The Seven Bridges of Konigsberg
The town of Konigsberg, Prussia (now Kalingrad, Russia) was
divided into four sections by the branches of the Pregel river. In
the 18th century seven bridges connected these regions. Is it
possible to start at some location in the town, travel across each
bridge exactly once and returns to the starting point?

Figure: The seven bridges of Konigsberg and its multigraph model.


Euler Paths and Circuits 1
▶ An Euler circuit in a graph or multigraph G is a simple circuit
containing every edge of G.
▶ An Euler path is a simple path containing every edge of G.

The Seven Bridges of Konigsberg:


▶ Is it possible to start at some location in the town, travel
across each bridge exactly once and returns to the starting
point?
▶ Is there an Euler circuit in this multigraph?
Euler Paths and Circuits 2

▶ If G has a vertex of odd degree, then G cannot have a Euler


circuit. Why?
▶ What is the contrapositive of the above statement?
Condition for the Existence of Euler Circuits

[Theorem 1] A connected multigraph G has an Euler circuit


if and only if each of its vertices has even degree.
Condition for the Existence of Euler Circuits

[Theorem 1] A connected multigraph G has an Euler circuit


if and only if each of its vertices has even degree.

[Proof]
▶ G has an Euler circuit → each of its vertices has even degree.
▶ by tracing the graph
▶ each time the circuit passes througth a vertex, it contributes
two to the vertex’s degree.
▶ Each of the vertices of G has even degree → G has an Euler
circuit.
▶ by constructing an Euler circuit (Hierholzer’s Algorithm).
Hierholzer’s Algorithm

1. Choose a starting vertex u. (u = a in the figure.)


2. Form a circuit c by following edges from u until returning to
u. (colored in red)
3. While there exists an edge vw with v ∈ c and w ̸∈ c
3.1 Form a circuit d starting from vw using edges not in c.
(circuit d colored in pink in the first iteration, then in green)
3.2 Append d to c.
The running time is O(e) for a graph with e edges.
Euler Paths

[Theorem 2] A connected multigraph has an Euler path but not an


Euler circuit if and only if it has exactly two vertices of odd degree.

[Example] Which graphs shown in Figure 7 have an Euler path?

[Solution]
▶ G1 and G2 have Euler paths.
▶ G3 does not have an Euler path.
Applications

Finding a path or circuit that traverses


▶ each street in a neighborhood exactly once
▶ each road in a transportation network exactly once
▶ each connection in a utility grid exactly once
▶ each link in a communications network

[Chinese Postman Problem (Guan, 1962)] Let G be a graph that


represents the streets the postman needs to cover. Find a circuit in
G with the fewest edges that traverses every edge at least once.
▶ if a postman can find an Euler path in the graph, this path
produces a route that traverses each street of the route
exactly once.
▶ If no Euler path exists, some streets will have to be traversed
more than once.
Hamilton Paths and Circuits
▶ A simple path in a graph G that passes through every vertex
exactly once is called a Hamilton path.
▶ A simple circuit in a graph G that passes through every vertex
exactly once is called a Hamilton circuit.

Figure: Hamilton’s “A Voyage Round the World” puzzle

[Hamilton’s Puzzle] start at a node and travel along the edges of


the dodecahedron, visiting each of the other 19 nodes exactly
once, and end back at the starting node.
Solution to Hamilton’s Puzzle
Example
Show that Kn has a Hamilton circuit whenever n ≥ 3.
Example
Show that Kn has a Hamilton circuit whenever n ≥ 3.

▶ begin at any vertex


▶ visit vertices in any order and ensure
▶ visit each vertex only once
▶ end at the same vertex
This is possible because there are edges between any two vertices.
Condition for the Existence of Hamilton Circuits

▶ No known simple necessary and sufficient criteria for the


existence of Hamilton circuits.
▶ Many theorems are known that give sufficient conditions for
the existence of Hamilton circuits.
▶ Dirac’s Theorem
▶ Ore’s Theorem
▶ The best algorithms known for finding a Hamilton circuit in a
graph or determining that no such circuit exists have
exponential worst-case time complexity (in the number of
vertices of the graph).
Two Theorems
[Intuition] The more edges a graph has, the more likely it is to
have a Hamilton circuit.

[DIRAC’S THEOREM]
If G is a simple graph with n vertices with n ≥ 3 such that the
degree of every vertex in G is at least n/2, then G has a Hamilton
circuit.

[ORE’S THEOREM]
If G is a simple graph with n vertices with n ≥ 3 such that
deg (u) + deg (v ) ≥ n for every pair of nonadjacent vertices u and
v in G , then G has a Hamilton circuit.

[Note]
▶ Graph C5 has a Hamilton circuit but does not satisfy the
hypotheses of either theorems.
▶ These theorems do not provide necessary conditions for the
existence of a Hamilton circuit.
Examples

[KR 10.5 Exercises 45]: For which values of m and n does the
complete bipartite graph Km,n have a Hamilton circuit?

Answer: m = n ≥ 2
Application of Hamilton Circuits

Relation to the traveling salesperson problem (TSP)


▶ TSP asks for the shortest route for visiting a set of cities.
▶ TSP reduces to finding a Hamilton circuit in a complete graph
such that the total weight of its edges is as small as possible.

Other applications: Finding a path or circuit that visits


▶ each intersection of streets in a city exactly once
▶ each node in a communications network exactly once
Recommended Exercises

KR 10.5:
▶ 1, 3, 5, 7, 9
▶ 11, 13, 15, 17, 19
▶ 21, 23, 25, 27, 29
▶ 31, 33, 35, 37, 39
▶ 41, 43, 45, 47

You might also like