You are on page 1of 108

THE MATHEMATICS

OF GRAPHS
Day 4 – AM
December 13, 2017

Joseph G. Taban
University of Northern Philippines

1
WHY STUDY GRAPH?

O Graphs are excellent


modeling tools.

2
1. THE KONIGSBERG
BRIDGE PROBLEM
O Is it possible to start a walk at any point and
cross each bridge exactly once, without retracing
your steps?

3
R R

D
A D A

L L

4
Determine if the following is traversable or
not.

5
An odd vertex is defined as one that has an
odd number of arcs (line segments) that come
to that point.
An even vertex has an even number of
arcs.
Euler proved that network s can be traced if
one of the following conditions is met:
a. There are only even vertices in the figure.
b. There are exactly two odd vertices in the figure.
6
2. UTILITIES PROBLEM

It shows how this problem can be


represented by a graph – the conduits are
shown as edges while the houses and utility
supply centers are vertices. 7
3. SEATING PROBLEM
Nine members of a new club meet each day for lunch
at a round table they decide to sit such that every members
has different neighbors at each lunch.

8
Arrangements at a dinner table
Preliminaries

9
GRAPHS consist of
Example 1: The following
 points called
picture is a graph. List its
vertices vertices and edges.
 lines called edges A
D

1. Edges connect two


C
vertices.
2. Edges only intersect
at vertices.
3. Edges joining a
E
vertex to itself are
called loops. B 10
Example 2:
This is also a graph. The vertices just happen to
have people’s names.
Such a graph could represent friendships (or any
kind of relationship).

John Ben Leila

Zaldy

Fred Amy Kian

11
Now check out the graph below.
What can we say about it in comparison to the previous
figure?

Leila Fred

John

Amy
Ben
Kian Zaldy

12
Moral of the Story

O One graph may be drawn in (infinitely)


many ways, but it always provides us
with the same information.
O Graphs are a structure for
describing relationships between
objects.

13
Some Applications
O Transactions
O Routes
O Work Distribution
O Networks

14
Constructing a Graph
Graphs Can represent many different scenarios
such as:
O Computer network of a small business
O Flights available on a particular airline between
selection of cities
O Game match in a particular game
O Etc.

15
The following table lists five students at a
college. An “X” indicates that the two students
participate in the same study group this semester.

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. 16
Use your graph to answer the following
questions:
O Which student is involved in the
most study groups with the others?
O Which student has only one study group in
common with the others?
O How many study groups does Laura have
in common with the others?

17
Solution:
We draw five vertices (in any configuration we wish)
to represent the five students, and connect vertices
with edges according to the table.

18
Answers:
O 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.
O Kayla is the only student with one study group
in common, as her vertex is the only one
connected to just one edge.
O Laura’s vertex is connected to two edges, so
she shares two study groups with the others.
19
The table below lists five mobile phone companies and
indicates whether they have agreements to roam onto each
other’s networks.
Draw a graph that represents this information, where
each vertex represents a phone company and an edge connects
two vertices if the corresponding companies have a roaming
agreement.

20
O Then use the graph to answer the
questions:
1. Which phone company
has roaming agreements with the
most carriers?
2. Which company can roam with only
one other network?

21
Terminologies
O A loop is an edge connecting a vertex to
itself
O If two vertices are connected by more
than one edge, these edges are called
multiple edges. The graph is called a
multigraph.
O A graph with no loops and no multiple
edges is called a simple graph.
O Graph with vertices but no edges is
called a Null Graph.
22
Examples

A B C

Which is a simple graph? Multigraph? and null graph?


23
Equivalent Graphs

Edges form the same connections of vertices.


24
1. Determine whether the following two graphs
are equivalent.

25
2. Determine whether the following two graphs
are equivalent.

26
EULER CIRCUITS
OA path is an alternating
sequence of vertices and
edges.
O If a path begins and ends
with the same vertex, it is a
closed path or a circuit/cycle.
27
A circuit that uses every edge, but never uses
the same edge twice, is CALLED AN EULER
CIRCUIT.

B–D –F –G–H–E–C–B–A–D–G–E–B
is an EULER Circuit. 28
Exercise
Which of the following graphs has
an Euler circuit?

29
▼ Eulerian Graph Theorem
A connected graph is Eulerian if
and only if every vertex of the
graph is of even degree.

30
Exercise
1. 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.

31
Application
A subway map shows the tracks that
subway trains traverse as well as the
junctions where one can switch trains.
Suppose an inspector needs to travel the
full length of each track. Is it possible to
plan a journey that traverses the tracks and
returns to the starting point without
traveling through any portion of a track more
than once?
32
33
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.
34
Application of Euler Path
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?

35
36
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?

37
HAMILTONIAN CIRCUITS
▼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.

38
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.
39
Example
The graph below shows the available flights of a
popular airline. 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?

40
A large law firm has offices in seven major cities.
The firm has overnight document deliveries scheduled
every day between certain offices. In the graph below, an
edge between vertices indicates that there is delivery
service between the corresponding offices.
Use Dirac’s theorem to answer the following
question: Using the law firm’s existing delivery service, is it
possible to route a document to all the offices and return
the document to its originating office without sending
it through the same office twice?

41
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 we
desire.

42
Find Hamiltonian Circuits
in a Weighted Graph

43
Solution

By trial and error, identify the routes


44
O Is there a way we can find the
very best route to take?
O Unfortunately, there is no known
shortcut for finding the optimal
Hamiltonian circuit in a weighted
graph.

45
Algorithms in Complete Graph
Complete Graphs are graphs in which every
possible edge is drawn between vertices (without
any multiple edges).
ALGORITHMS
1. The greedy algorithm
2. The edge-picking algorithm
The circuits found by the algorithms are not
guaranteed to have the smallest total weight
possible, but they are often better than you would
find by trial and error. 46
1.The Greedy Algorithm
The Greedy Algorithm
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.)
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.
Return to the starting vertex. 47
Example:
Use the greedy algorithm to find a Hamiltonian circuit
in the weighted graph shown. Start at vertex A.

48
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

49
Example
Use the greedy algorithm to find a Hamiltonian
circuit starting at vertex A in the weighted graph
shown.

50
2. The Edge –Picking Algorithm
▼ 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. 51
Example:
Use the edge-picking algorithm to find a
Hamiltonian circuit of the previous graph.

52
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 53
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.

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. 54
Planarity and the Euler’s Formula

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

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

56
Show that the graphs below are planar
or not planar

57
EULER’s FORMULA

58
O ▼ 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.

59
Verify the Euler’s Formula

60
The Five Regular Convex
Polyhedra

61
The tetrahedron consists of four faces,
each of which is an equilateral triangle.
Draw the graph that results from a
projection of the tetrahedron.

62
Possible Exercises
1. Show the planar graphs
for each platonic solid.
2. Verify the Euler's Formula
for each of these

63
GRAPH COLORING
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. 64
There is a connection between
coloring maps and graph theory.
This connection has many
practical applications, from
scheduling tasks, to designing
computers, to playing
Sudoku.
65
66
Our map-coloring question
then becomes:
1. Can we give each vertex of the graph
a color such that no two vertices
connected by an edge share the
same color?
2. How many different colors will be
required?

67
The graph is actually 3-colorable; only
three colors are necessary.

68
▼ Four-Color Theorem
Every planar graph is 4-colorable.
The graph shown at the right
requires five colors if we wish
to color it such that no edge
joins two vertices of the same
color. Does this contradict the
four-color theorem? 69
Using a Graph to Color a Map
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.

70
71
Exercise
Represent the fictional map of countries below as a
graph, and determine whether the graph is 2-colorable,
3-colorable, or 4-colorable by finding a suitable coloring
of the graph. Then color the map according to the graph
coloring.

72
The Chromatic Number of a
Graph
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.

73
▼ 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.

74
Find the chromatics number

Thus the Utilities Graph


has a chromatic number
of 2. 75
Determine whether the
following graph is 2-colorable.

76
APPLICATION
A Scheduling Application of Graph Coloring

Eight different school clubs want to schedule


meetings on the last day of the semester.
Some club members, however, belong to more than
one of these clubs, so clubs that share
members cannot meet at the same time. How
many different time slots are required so
that all members can attend all meetings? Clubs
that have a member in common are
indicated with an “X” in the table. 77
78
Solution
We can represent the given information by a graph.
Each club is represented by a vertex, and an edge
connects two vertices if the corresponding clubs have
at least one common member.

79
Each color corresponds to a time slot, so
one scheduling is
O First time slot: ski club, debate club,
student newspaper
O Second time slot: student government,
community outreach
O Third time slot: honor society, campus
Democrats, campus Republicans 80
GROUP ACTIVITY

81
QUIZ

82
PROBLEM SET

83
Integrating
project

84
85
86
87
Exercise
Six friends are taking a film history course
and, because they have procrastinated, need
to view several films the night before the final
exam. They have rented a copy of each film on
DVD, and they have a total of three DVD
players in different dorm rooms. If each film is
two hours long and they start watching at 8:00
p.m., how soon can they all be finished
watching the required films? Create a viewing
schedule for the friends. 88
89
O Film A needs to be viewed by Brian, Chris,
and Damon.
O Film B needs to be viewed by Allison and
Fernando.
O Film C needs to be viewed by Damon, Erin,
and Fernando.
O Film D needs to be viewed by Brian and Erin.
O Film E needs to be viewed by Brian, Chris,
and Erin.
90
The Eulerian problem was also similar to the
CHINESE POSTMAN PROBLEM.

O HAMILTONIAN PATH is a path that passes


a vertex only once. It is possible not to
pass through all the edges.
O If a path is closed, it is a HAMILTONIAN
CYCLE. If a graph has a hamiltonian cycle,
it is called a HAMILTONIAN GRAPH.
O Unlike the Eulerian graphs, there is no
condition for determining a hamiltonian
graph 91
92
The graph above shows that the total number of
vertices is 7 and only 1 has a vertex whose degree
is more than half of the total number of vertices but
it is a Hamiltonian, 93
SPANNING TREE
O Let G be a connected graph. A spanning tree of
G is a tree with the same vertex set as G and
edges containing in the edge set of G.

O A tree of which not all the edges of graph G be


contained in the graph of the spanning tree.
O to find spanning tree, visit a vertex once. But
you can go back to the vertex you came from.

94
Application
For example, in a computer laboratory, the
spanning tree could be used to make sure that
every computer is connected.
OPTIMIZATION (MINIMIZATION)

In any tree with n vertices, the number of


edges is always n-1 edges.

95
O If the edges of the graph G are weighted, we
are often interested in finding the spanning
tree of minimum total weight.
O KRUSKAL'S algorithm adds the edges in
order of minimum weight so that no cycles
form and so that every vertex belongs to
some edge added.

96
O PLANAR GRAPH
O A graph is planar if it can be drawn in such a
way that no edges cross. This means that
any two edges can meet only at an endpoint.

O K4 is a planar graph
O K5 and K(3,3) are not planar graphs

97
O Euler's Formula
O In a planar graph is drawn with no crossing
edges, if the number of vertices (v), the
number of edges € and the number of faces
(f),
O v+f=e+2

Proof can be shown by mathematical induction

98
Platonic SOLIDS
O Tetrahedron
O Hexahedron ( CUBE)
O Octahedron
O Dodecahedron
O Icosahedron

99
Showed the planar graphs for each platonic
solid. (see notes)
Verify the Euler's Formula for each of these

100
GRAPH COLORING
O One of the subjects studies by
mathematicians is graph coloring. The idea
is to color the vertices of a graph in such a
way that adjacent vertices or consecutive
edges are given different colors.

101
O Chromatic number is the smallest number of
colors required to color the vertices of a graph.

O In a cycle if the number of vertices is even, 2


colors is needed, otherwise, 3 colors.

O Four-Color Theorem. The chromatic number of a


planar graph is at most 4.

O The chromatic number of a graph is if and only


if it has no cycles with

102
MAP COLORING
O A map can be represented by a graph with
the different regions as vertices. Two regions
are adjacent if they share edges.

O Exercise: Color a map.

103
Application
A film class is making movies in
groups. Three digicams are
available and each movie has to
be shot for a whole day. Each
student can work on only one
movie at a time. Make a
scheduling the least number of
shooting days. 104
O Movie 1. Brian, Angela, Kate
O Movie 2. Jessica, Vince, Brian
O Movie 3; Corey, Brian and Vince
O Movie 4. Ricardo, Sarah, Lupe
O Movie 5. Sarah, Kate, Jessica
O Movie 6. Angela, Corey and Lupe

105
SOLUTION
O The vertices: MOVIES
O The colors: DAYS

O The vertices are connected if there are students in the


same movies.

O Three colors (days) will be needed only.

O Day 1: Movie 1 and 4


O Day 2: Movie 2 and 6
O Day 3: Movie 3 and 5

Another example on your notes 106


Map Coloring The map shows
eight states in the central time
zone of the United States. Four
colors have been used to color
the states such that no two
Bordering states are
the same color.
a. Can this map be colored,
using only three colors, such
that no two bordering states
are the same color? Explain.
b. Can this map be colored, using only two colors, such
that no two bordering states are the same color? Explain.
107
Exercise
1. You need to buy groceries at the supermarket, deposit a
check at the credit union, and purchase a book at the
bookstore. You can complete the errands in any order;
however, you must start and end at your home.
The driving time in minutes between each of these locations
is given in the following figure.

Suppose that you need to go to the supermarket


after you have completed the other two errands. What route
should you take to minimize your travel time? 108

You might also like