You are on page 1of 46

Graphs

In this chapter, you will learn how 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 time
The methods we will use to study these problems can be traced
back to an old recreational puzzle, the Königsberg bridge problem.
Introduction to Graphs

Think of all the various connections we experience in


our lives—friends are connected on Facebook, cities are
connected by roads, computers are connected across the
Internet.
A branch of mathematics called graph theory
illustrates and analyzes connections such as these.
Example:

Facebook Friends

Each dot represents a person, and a line segment connecting two dots
means that those two people are friends on Facebook. This type of
diagram is called a graph.
What is a graph?

A graph is a set of points called vertices and line segments or


curves called edges that connect vertices.
Constructing a Graph
The following table lists five students at a college. An “X” indicates that
the two students participate in the same study group this semester.

Solution:

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? How many study groups does Laura
have in common with the others?

Graph from the solution in a.

Solution:
The vertex corresponding to Amber
is connected to more edges than the others,
so
she is involved with more study groups
(three) than the others. Kayla is the only
student with one study group in common, as
her vertex is the only one connected to just
one edge. Laura’s vertex is connected to two
edges, so she shares two study groups
with the others.
Complete Graph
Equivalent Graphs

 the three graphs are considered equivalent graphs because the


edges form the same connections of vertices in each graph.
Equivalent Graphs

Determine whether the two graphs are equivalent.


1.

2.
Euler Circuits
Definitions:
A path in a graph can be thought of as a movement from one
vertex to
another by traversing edges.
If a path ends at the same vertex at which it started, it is
considered a closed path, or circuit.

A circuit that uses every edge, but never uses the same edge
twice, is called an Euler circuit.

▼Eulerian Graph Theorem


A connected graph is Eulerian if and only if every
vertex of the graph is of even degree.
Example:

Since all vertices are of even degree. By the Eulerian Graph Theorem,
this graph has an Euler circuit. Then, the graph is also known as Eulerian.

The path B–D–F–G–H–E–C–B–A–D–G–E–B is an example of Euler circuit in the


graph given.
Euler Paths

▼Euler Path Theorem


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.
Application of Euler Path:

The floor plan of an art gallery is pictured below. Draw a graph that represents
the floor plan, where vertices correspond to rooms and edges correspond to
doorways. Is it possible to take a stroll that passes through every doorway
without going through the same doorway twice? If so, does it matter whether we
return to the starting point?
Solution:
We can represent the floor plan by a graph if we let a vertex represent each
room. Draw an edge between two vertices if there is a doorway between the two
rooms.

If we would like to tour the gallery and pass through every doorway once, we must
find a path in our graph that uses every edge once (and no more). Thus we are
looking for an Euler path. In the graph, two vertices are of odd degree and the others
are of even degree. So we know that an Euler path exists, but not an Euler circuit.
Therefore, we cannot pass through each doorway once and only once if we want to
return to the starting point, but we can do it if we end up somewhere else.
Furthermore, we know we must start at a vertex of odd degree—either room C or
room D. By trial and error, one such path is C–B–F–B–A–F–E–D–C–F–D.
Weighted Graphs
Hamiltonian Circuits
Definition:

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.
Hamiltonian Circuits
Example: Find a Hamiltonian circuit from this graph.
Dirac’s Theorem
Consider a connected graph with at least three
vertices and no multiple edges. Let be the number of
vertices in the graph. If every vertex has a degree of
at least then the graph must be Hamiltonian.
Example:
Dirac’s Theorem
Note:

 Ifthe graph does not meet the requirements of the


Dirac’s Theorem, it still might be Hamiltonian.

Example:
Weighted Graph
Definition:

A weighted graph is a graph in which each edge is


associated with a value, called a weight.

Example:
Traveling salesman problem

The traveling salesman problem consists of a


salesman and a set of cities. The salesman has to
visit each one of the cities starting from a certain
one (e.g. the hometown) and returning to the
same city. The challenge of the problem is that the
traveling salesman wants to minimize the total
length of the trip.
Traveling salesman problem
Example: (Example 2, p 250, Aufmann)

The table below lists the distances in miles between six popular cities
that a particular airlines flies to. Suppose a traveller would like to
start in Chicago, visit the other five cities this airlines flies to, and
return to Chicago. Find three different routes that the traveller could
follow, and find the total distance flown fro each route.
Chicago New York Washington Philadelphia Atlanta Dallas
Chicago - 713 597 665 585 803
New York 713 - No flights No flights 748 1374
Washington 597 No flights - No flights 544 1185
Philadelphia 665 No flights No flights - 670 1299
Atlanta 585 748 544 670 - No flights
Dallas 803 1374 1185 1299 No flights -
Traveling salesman problem
Example: (Example 2, p 250, Aufmann)
Chicago New York Washington Philadelphia Atlanta Dallas
Chicago - 713 597 665 585 803
New York 713 - No flights No flights 748 1374
Washington 597 No flights - No flights 544 1185
Philadelphia 665 No flights No flights - 670 1299
Atlanta 585 748 544 670 - No flights
Dallas 803 1374 1185 1299 No flights -

Note:
There are many equivalent
ways to draw the graph.
Greedy Algorithm

A method of finding the a Hamiltonian circuit in a


complete weighted graph is given by the following
greedy algorithm.
1. Choose a vertex to start at, then travel along the
connected edge that has the smallest weight.
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.
Greedy Algorithm

Note:

The greedy algorithm attempts to give a circuit of


minimal total weight, although it does not always
succeed.
Greedy Algorithm

Example: Use the greedy algorithm to find a


Hamiltonian circuit in the given weighted graph.
Edge-Picking Algorithm

Another method of finding a Hamiltonian circuit in


a complete weighted graph is given by the
following edge-picking algorithm.
1. Mark the edge of smallest weight in the graph.
2. Mark the edge of the 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 the process until you can no longer
mark any edges. Then mark the final edge that
completes the Hamiltonian circuit.
Edge-Picking Algorithm

Note:

The edge-picking algorithm attempts to give a


circuit of minimal total weight, although it does
not always succeed.
Greedy Algorithm

Example: Use the edge-picking algorithm to find a


Hamiltonian circuit in the given weighted graph.
Applications of Weighted Graphs
Example: (27, p.262 Aufmann)
Route Planning: Brian needs to visit the pet store, the shopping
mall, the local farmers market and the pharmacy. His estimated
driving times (in minutes) between the locations are given the
table below. Use the greedy algorithm and the edge-picking
algorithm to find two possible routes, starting and ending at
home, that will help Brian minimize his total travel time.

Home Pet store Shopping mall Farmers market Pharmacy


Home - 18 27 15 8
Pet store 18 - 24 22 10
Shopping mall 27 24 - 20 32
Farmers market 15 22 20 - 22
Pharmacy 8 10 32 22 -
Planarity and Euler’s Formula
Planar Graph

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

 If the graph is drawn in such a way that no edges cross, we say that we have a
planar drawing of the graph.
Planar Graph

 Is this a planar drawing of a graph?


Is the graph planar?
Planar graph

 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.
Planar graph

 One strategy we can use to show that a graph is not planar is to find a
subgraph, a graph whose edges and vertices come from the given graph, that
is not planar.
Subgraph Theorem

 If a graph G has a subgraph that is not planar, the G is also not planar. In
particular, if contains the Utilities Graph or K_5 as a subgraph, G is not planar.
Subgraph Theorem

 We can expand this strategy by considering contractions of a subgraph. A


contraction of a graph is formed by “shrinking” an edge until the two vertices
it connects come together and blend into one. If, in the process, the graph is
left with any multiple edges, we merge them into one.
Nonplanar Graph Theorem

A graph is nonplanar if and only if it has the Utilities Graph or K5 as a subgraph,


or it has a subgraph that can be contracted to the Utilities Graph or K5.
Euler’s Formula

 In a connected planar graph drawn with no intersecting edges, let v be the


number of vertices, e the number of edges, and f the number of faces. Then
v + f = e + 2.
Explorations

 Dual Graph
Every planar graph has what is called a dual graph. To form the dual graph, start
with a planar drawing of the graph. With a different-color pen, draw a dot in
each face (including the infinite face). These will be the vertices of the dual
graph. Now, for every edge in the original graph, draw a new edge that crosses
over it and connects the two new vertices in the faces on each side of the
original edge. The resulting dual graph is always itself a planar graph. (Note that
it may contain multiple edges.)
Graph Coloring

Coloring Maps
In the mid-1800s, Francis Guthrie was trying to color a map of the counties of
England. So that it would be easy to distinguish the counties, he wanted counties
sharing a common border to have different colors. After several attempts, he
noticed that four colors were required to color the map, but not more. This
observation became known as the four-color problem. (It was not proved until
over 100 years later; see the Math Matters on page 278.)
Graph Coloring

Coloring Maps
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.

There is a connection between coloring maps and graph theory. This connection
has many practical applications,
Graph Coloring

Coloring Maps

TFCMT video.
Graph Coloring

Coloring Maps

You might also like