Lesson 9 The Mathematics of Graphs

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

The Mathematics of

Graphs

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
The Mathematics of Graphs

 The mathematics of graphs can be used to analyze


and solve a variety of problems, such as
 how to find the least expensive route of travel on a
vacation,
 how to determine the most efficient order in which
to run errands, and
 how to schedule meetings at a conference so that
no one has two required meetings at the same
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg

time.
Königsberg Problem

In the early eighteenth century, a river in a city called


Königsberg which was located in modern-day Russia had
seven bridges crossed the river connecting four
different areas, similar to the map drawn below. People
at the time would attempt to take a stroll that would
lead them across each bridge and return them
to the starting point without passing
the same bridge twice.
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Leonhard Euler (1707–1783)

 In 1736 the Swiss mathematician


Leonhard Euler proved that it is, in fact,
impossible to walk such a path.
His analysis of the challenge has lead to
the study of graph theory.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Introduction to Graphs
A graph is a set of points called vertices and line segments
or curves called edges that connect vertices.

 The graph represents the flights available on a particular


airline between a selection of cities; each vertex represents
a city, and an edge connecting two cities means that there
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg

is a direct flight between the two cities.


Example

 The following table lists fi ve students at a college. An “X” indicates that the
two students participate in the same study group this semester.
a) Draw a graph that represents this information where each vertex represents a
student and an edge connects two vertices if the corresponding students study
together.
b)Use your graph to answer the following questions: Which student is involved in
the most study groups with the others? Which student has only one study group in
common with the others?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Graph of the previous example

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Connected Graphs

Connected graphs are graphs in which any vertex can be reached from any other
vertex by tracing along edges.

This is a connected graph in which every possible edge is drawn between vertices
(without any multiple edges). Such a graph is called a complete graph.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
This is a connected graph that has a pair of multiple edges.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 This graph has five vertices but no edges and is referred to as a null graph. It
is also an example of a disconnected graph.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 This graph is not connected. It consists of two different sections. It also
contains a loop.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Question

 Is the following graph a complete graph?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Equivalent Graphs

 Graphs are said to be equivalent graphs if the edges form the same
connections of vertices.
 The following are equivalent graphs.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Determine whether the following two graphs are equivalent.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
The Graph of Königsberg bridges

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 A path in a graph can be thought of as a movement from one vertex to
another by passing through the edges.
 For example, in the Konigsberg graph, one path would be A–B–A–C.
 If a path ends at the same vertex at which it started, it is considered a closed
path, or circuit.
 The path A–D–F–G–E–B–A is a
circuit because it begins and
ends at the same vertex.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Euler Circuit

 A circuit that uses every edge, but never uses the same edge twice, is called
an Euler circuit. The path may cross through vertices more than once.
 The path B–D–F–G–H– E–C–B–A–D–G–E–B is an Euler circuit.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 The Konigsberg problem which is finding a path that crosses each bridge
exactly once and returns to the starting point is equivalent to finding an Euler
circuit for its corresponding graph.
 Euler essentially proved that the Konigsberg graph could not have an Euler
circuit.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Eulerian Graph Theorem

 The number of edges that meet at a vertex is called the degree of a vertex.
 A connected graph is Eulerian if and only if every vertex of the graph is of
even degree.
 The Eulerian Graph Theorem guarantees that when all vertices of a graph
have an even degree, an Euler circuit exists, but it does not tell us how to
find one.
 Because the graphs we will examine here are relatively small, we will rely on
trial and error to find Euler circuits.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Which of the following graphs has an Euler circuit?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 There is a systematic method, called Fleury’s algorithm, that can be used to
find Euler circuits in graphs with large numbers of vertices.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Determine whether the graph shown below is Eulerian. If it is, find an Euler
circuit. If it is not, explain how you know. The number beside each vertex
indicates the degree of the vertex.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Euler Path Theorem

 A path (not necessarily a circuit) that uses every edge once and only once is
an Euler path.
 A connected graph contains an Euler path if and only if the graph has two
vertices of odd degree with all other vertices of even degree. Furthermore,
every Euler path must start at one of the vertices of odd degree and end at
the other.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Dijkstra’s Algorithm

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example
 A photographer would like to travel across all of the roads shown on the following map. The
photographer will rent a car that need not be returned to the same city, so the trip can begin in
any city. Is it possible for the photographer to design a trip that traverses all of the roads exactly
once?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Hamiltonian Circuit

 A Hamiltonian circuit is a path that uses each vertex of a graph exactly once.
A graph that contains a Hamiltonian circuit is called Hamiltonian.
 The path A–B–C–D–E–F–G–A
visits each vertex once and returns
to the starting vertex without visiting
any vertex twice. This path is
a Hamiltonian circuit.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Dirac’s Theorem

 Consider a connected graph with at least three vertices and no multiple


edges. Let n be the number of vertices in the graph. If every vertex has
degree of at least n/2, then the graph must be Hamiltonian.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example
 The graph below shows the available flights of a popular airline. (An edge between two vertices
in the graph means that the airline has direct flights between the two corresponding cities.)
Apply Dirac’s theorem to verify that the following graph is Hamiltonian. Then find a Hamiltonian
circuit. What does the Hamiltonian circuit represent in terms of flights?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Exercises

 use Dirac’s theorem to verify that the graph is Hamiltonian. Then find a
Hamiltonian circuit.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Weighted Graphs

 A weighted graph is a graph in which each edge is associated with a value,


called a weight.
 The value can represent any quantity.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 The table below lists the distances in miles between six popular cities that a particular airline
flies to. Suppose a traveler would like to start in Chicago, visit the other five cities this airline
flies to, and return to Chicago. Find three different routes that the traveler could follow, and
find the total distance flown for each route.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

 A route that visits each city just once corresponds to a Hamiltonian circuit.
Chicago–New York–Dallas–
Philadelphia–Atlanta– Washington,
D.C.–Chicago
713 +1374 + 1299 + 670
+ 544 +597 = 5197

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 Chicago–Philadelphia– Dallas–Washington, D.C.–Atlanta–New York–Chicago. The
total weight of the circuit is
 665 + 1299 +1185 + 544 +748 + 713 = 5154

 A third route is Chicago–Washington,


D.C.–Dallas–New York–Atlanta–Philadelphia–
Chicago. The total mileage is
 597 +1185 +1374 +748 +670 +665 = 5239

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Algorithms in Complete Graphs

The Greedy Algorithm


1. Choose a vertex to start at, then travel along the connected edge that has the smallest weight.
(If two or more edges have the same weight, pick any one.)
2. After arriving at the next vertex, travel along the edge of smallest weight that connects to a
vertex not yet visited. Continue this process until you have visited all vertices.
3. Return to the starting vertex.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Use the greedy algorithm to find a Hamiltonian circuit in the weighted graph
shown in the Figure. Start at vertex A.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

 Begin at A. The weights of the edges from A are 13, 5, 4, 15, and 8, The
smallest is 4. Connect A to D.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

 The Hamiltonian circuit is A–D–B–F– E–C–A. The weight of the circuit is 4 +2 +5


+10 +6 + 15 = 42

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Exercises
 Use the greedy algorithm to find a Hamiltonian circuit starting at vertex A in the weighted
graph.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
The Edge-Picking Algorithm

 1. Mark the edge of smallest weight in the graph. (If two or more edges have
the same weight, pick any one.)
 2. Mark the edge of next smallest weight in the graph, as long as it does not
complete a circuit and does not add a third marked edge to a single vertex.
 3. Continue this process until you can no longer mark any edges. Then mark
the final edge that completes the Hamiltonian circuit.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Use the edge-picking algorithm to find a Hamiltonian circuit in the Figure.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

 We first highlight the edge of smallest weight, namely BD with weight 2.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Solution

 Beginning at vertex A, the Hamiltonian circuit is A–D–B–F–C–E–A. (In the


reverse direction, an equivalent circuit is A–E–C–F–B–D–A.) The total weight of
the circuit is 4 +2 +5 +14 +6 +5 = 36

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Exercise

 Susan needs to mail a package at the post office, pick up several items at the grocery store,
return a rented video, and make a deposit at her bank. The estimated driving time, in minutes,
between each of these locations is given in the table below.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 Use both of the algorithms from this section to design routes for Susan to
follow that will help minimize her total driving time. Assume she must start
from home and return home when her errands are done.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Planarity

 A planar graph is a graph that can be drawn so that no edges intersect each
other (except at vertices).

 Is this a planar drawing of a graph? Is the graph planar?

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 The drawing is not planar because two edges cross. The graph is planar
because we can make an equivalent planar drawing of it as shown at the left.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 Show that the graph below is planar.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 The graph is planar.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Graph Coloring
 There is a connection between coloring maps and graph theory.
 Other practical applications are found from scheduling tasks, to designing computers, to playing
Sudoku.
 Here is a map of the contiguous
states of the United States colored
similarly. Note that the map has only
four colors and that no two states that
share a common border have the same color.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Coloring Maps

 Suppose the map shows the countries, labeled as letters, of a continent.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Our map-coloring question then
becomes:
 Can we give each vertex of the graph a color such that no two vertices
connected by an edge share the same color?
 How many different colors will be required?
 If this can be accomplished using four colors, for instance, we will say that
the graph is 4-colorable.
 The graph is actually 3-colorable; only three colors are necessary.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Four-Color Theorem

 Every planar graph is 4-colorable.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example

 The fictional map below shows the boundaries of countries on a rectangular


continent. Represent the map as a graph, and find a coloring of the graph
using the fewest possible number of colors. Then color the map according to
the graph coloring.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Exercises
 A fictional map of the countries of a continent is given. Represent the map by a graph and find a
coloring of the graph that uses the fewest possible number of colors. Then color the map
according to the graph coloring you found.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
The Chromatic Number of a Graph

 The four-color theorem guarantees that we need only four colors to color a
planar graph.
 If we wish to color a nonplanar graph, we may need more than four colors.
 The minimum number of colors needed to color a graph so that no edge
connects vertices of the same color is called the chromatic number of the
graph.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
2-Colorable Graph Theorem

 A graph is 2-colorable if and only if it has no circuits that consist of an odd


number of vertices.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
Example
 Find the chromatic number of the Utilities Graph.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg
 Note that no edge connects vertices of the same color.
 Note that the graph contains circuits such as A–Y–C–Z–B–X–A with six vertices and A–Y–B–X–A with
four vertices.
 A little trial and error confirms this if we simply color vertices A, B, and C one color and the
remaining vertices another. Thus the Utilities Graph has a chromatic number of 2.

Mathematical Excursions, Third Edition Richard N. Aufmann, Joanne S. Lockwood, Richard D. Nation, Daniel K. Clegg

You might also like