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

Module7 Graph Theory

This document provides an overview of graph theory concepts. It defines basic graph theory terms like vertices, edges, loops, multiple edges, simple graphs, connected graphs, degrees of vertices, and complete graphs. It then gives examples of representing relationships between objects as graphs, such as students in study groups or counties that share borders. Finally, it introduces the concept of graph coloring, which is assigning colors to vertices so that connected vertices have different colors.

Uploaded by

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

Module7 Graph Theory

This document provides an overview of graph theory concepts. It defines basic graph theory terms like vertices, edges, loops, multiple edges, simple graphs, connected graphs, degrees of vertices, and complete graphs. It then gives examples of representing relationships between objects as graphs, such as students in study groups or counties that share borders. Finally, it introduces the concept of graph coloring, which is assigning colors to vertices so that connected vertices have different colors.

Uploaded by

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

MATHEMATICS IN THE MODERN WORLD

MODULE

Mathematics of Graphs
Overview
Welcome to Graph Theory!
In this module, we will discuss the basic terms in graph theory as an introductory
course for students. It will include how to use graph theory in solving problems like
the TSP and other route problems.

Learning Outcomes
By the end of the module, students will be able to:

■ Define basic terms in graph theory.


■ Solve problems using graph coloring.
■ Differentiate Eulerian from Hamiltonian Graphs.
■ Apply Euler paths and circuits to solve problems.
■ Apply Hamiltonian paths and circuits to solve
problems.

References:
[1] Baltazar, E.C, Evangelista, J, & Ragasa, C. (2018). Mathematics in the
Modern World. C&E Publishing
[2] Sobecki, D. (2019). Math in our World. (4th Ed.). McGraw-Hill Education
[3] Leonhard Euler | Biography, Education, Contributions, & Facts | Britannica
[4] Euler Graph | Euler Path | Euler Circuit | Gate Vidyalay
[5] Putting It Together: Graph Theory | Mathematics for the Liberal Arts
[6] Euler’s Map Theorem: a Surprising Activity – Occupy Math
[7] https://www.britannica.com/biography/William-Rowan-Hamilton
[8] Examples of Traveling Salesman Problems
MATHEMATICS IN THE MODERN WORLD
MODULE

Activity 8.1 Share your Weekend Getaway


Instructions
Share and Discuss.
Were you ever included in the planning a weekend getaway with friends or
family members?
Think of your experience in any vacation you went to.
Write a post to describe your experience.

1. Use these questions to guide you as you're reflecting on


your experience:
a. What kind of weekend getaway was it?
b. Where did you go?
c. How did you get there?
2. Share your experience in 4 or 5 sentences on our
discussion board.

Your discussion post will be graded using the rubric below:

Answer a Question Rubrics


Criteria Rating Points
3 pts 2 pts 1 pt
Learners wrote 4-5 Learners wrote 2-3 Learners wrote 1 sentence
Length 3 pts
sentences about their sentences about their about their voting
voting experience. voting experience. experience.
2 pts 1 pt
3 pts
Description Learner was not able to Learner was not able to
Learner was able to
and convey the experience discuss the experience 3 pts
discuss the experience in a
Grammar well, and had some well, with many misuse of
clear, concise manner.
grammar misuse. grammar.

Releva 4 pts 2 pts 1 pt


Learner wrote an Learner wrote an Learner wrote an
nce of
experience that experience that does experience that is not 4 pts
Experie
answered the not really answer the relevant to the
nce questions asked. guide questions. question.
MATHEMATICS IN THE MODERN WORLD
MODULE

Introduction to Graph Theory


The Konigsberg Bridge Problem is one of the most popular problems in
mathematics.The conundrum asked if it is possible to travel across all the seven bridges
to this city exactly once. It was such a great problem that the mayor of the city wrote a
letter to one of the greatest mathematicians of the time, Leonhard Euler[1] (1707 –
1783) to solve the problem.

In response, Euler came up with a new branch of mathematics, the Mathematics


of Graphs, which we now call as Graph Theory. The graph that we will be using is highly
different from the graph discussed in Statistics. So we start this lesson with the
definition of terms.

[1] https://www.britannica.com/biography/Leonhard-Euler
MATHEMATICS IN THE MODERN WORLD
MODULE

Terms to Remember:
A graph consists of a finite set of points called vertices and line segments or
curves called edges connecting the points.

The graph of a social A graph of a


A graph of a
network of Computer Network
Molecular Structure
neurological patients.
Vertex – each
Vertex – each person Vertex – the unit
element
Edge – Relationship Edge – the
Edge – the bond
between people connection
between elements

A loop is an edge connecting a


vertex to itself.

If two vertices are connected by


more than one edge, these edges
are called multiple edges.
MATHEMATICS IN THE MODERN WORLD
MODULE

A graph with no loops and no


multiple edges is called a simple
graph.

A graph is connected if there is a


path connecting all the vertices.

A graph is disconnected if there is


a vertex / vertices separated from
the graph.

Two vertices are adjacent if there


is an edge joining them.

A bridge on a connected graph is


an edge, which if removed, makes
the graph disconnected.
MATHEMATICS IN THE MODERN WORLD
MODULE

The degree of a vertex is the


number of edges attached to it.
An odd vertex has an odd number
of edges that intersect it.

An even vertex has an even


number of edges that intersect it.
Loops are considered to be two
edges emanating from the vertex.

If every pair of vertices of a graph are adjacent, the graph is complete. A complete
graph with n vertices is denoted by Kn.

These are most of the definitions that we need to remember when dealing
with graph theory. One is expected to be familiar with the terms so that one can
follow the discussion being presented.
Now that we know that the graph is not the usual graph that presents
statistical data. Instead it represents relationships between people, places, even
things and other matters. We start the discussion on how to represent any
relationship as a graph.
MATHEMATICS IN THE MODERN WORLD
MODULE

Representing Relationships as Graphs


The following table lists five students at a university.
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.
Rene Madz Allan Norma Kiko

Rene --- X X X

Madz X --- X X

Allan X X --- X

Norma X ---

Kiko X X ---

We represent each student as the vertex, and the edge between them
represents the fact that they study together and come up with this graph.
MATHEMATICS IN THE MODERN WORLD
MODULE

Represent the floor plan of the house shown


in the figure below by a graph.
The room has a vertex, and the door as the
edges.

The map shown in the figure shows five counties in central Pennsylvania.
Draw a graph that shows the counties that share a common border.
The county is the vertex and the border as the edge.

Graph Coloring
One of the uses of graph theory is in coloring maps as shown in a previous
example.
A coloring for a graph is a method of coloring all the vertices so that any pair
of vertices joined by an edge have different colors.
The smallest number of colors that can be used for coloring a graph is called
its chromatic number.
MATHEMATICS IN THE MODERN WORLD
MODULE

Graph coloring started in the mid-1800’s when Francis Guthrie tried to color
the map of England to easily distinguish countries with the same border by making
sure that countries with the same border have different colors.
Several attempts later, he found out that a maximum of four colors is needed
to color a map.
We have a theorem for this one:

Four-Color Theorem
The chromatic number of a planar graph is at most 4.

A planar graph is a graph that can be drawn so that no edges intersect each
other (except at vertices).
Graph coloring is used
mostly in scheduling, so a
person attending several
meetings will not meet a conflict
of time.
Airlines also use this, to
avoid conflict of air space for
planes using the same terminal.

Examples: Graph Coloring


Six college accreditation committees need to hold meetings on the same
day, but some teachers belong to more than one committee.
In order to avoid members missing meetings, the meetings need to be
scheduled during different time slots.
An “X” in the table indicates that the two corresponding committees share at
least one member.
Use graph coloring to determine the minimum number of time slots
necessary to ensure that all faculty members can attend all meetings.
MATHEMATICS IN THE MODERN WORLD
MODULE

Faculty Faculty Outreach Physical Library Student


Committee Instruction Development Program Facility Facility Welfare
(FI) (FD) (OP) (PF) (LF) (SW)
Faculty
- X X X
Instruction
Faculty
X - X X X
Development
Outreach
X - X X X
Program
Physical
X X - X
Facility
Library
X X X - X
Facility
Student
X X X X -
Welfare

Represent this as a graph with the committee as vertices and members as edges.
Then color with a minimal number.
In this case, the chromatic number is 3.
MATHEMATICS IN THE MODERN WORLD
MODULE

Use graph coloring to find the number of different colors that would be necessary
to color the map at the right so that no states with a common border are the same color.
Then color the map using what you learned from your graph.

Then we color the graph, with no adjacent vertices having the same color.
And use that idea to color the map.
The chromatic number for this is 4.
MATHEMATICS IN THE MODERN WORLD
MODULE

Activity 8.2: Graph Coloring


Instructions
Do the activity as indicated.

The quiz is not timed, so you can pause it and resume at any time.
If you cancel the quiz, your answers are discarded and they are not counted as a submission.

Eulerian Graphs
The Euler Circuit is named after Leonhard Euler[1].
This graph is his response to the question “Is it possible to cross all bridges
of Konigsberg exactly once?”.
He came up with a graph, represented by vertices for each town of
Konigsberg and an edge for the seven bridges and tried to find a path that would
allow him to use each exactly once.
The answer was NO, and he had a theorem to prove it. Before discussing
the theorem, let’s have some definitions that are also important in the study of
Euler paths and circuits.
A path is an alternating sequence of vertices and edges. It can be
seen as a trip from one vertex to another using the edges of the graph.
If a path begins and ends with the same vertex, it is a closed path or a
circuit/cycle.
[1] Leonhard Euler | Biography, Education, Contributions, & Facts |
Britannica
MATHEMATICS IN THE MODERN WORLD
MODULE

Example:
Can you trace a path here that uses each of the edges exactly once? Is it a
path or a circuit?

An Euler path is a path that passes through each edge exactly once.
A circuit that uses every edge, but never uses the same edge twice, is called
an Euler circuit.
With these new definitions, was the path or circuit Eulerian?

Example: Eulerian Graphs


This is an example of an Euler
path: There are no edges left
unmarked.
Remember that in tracing a path,
a direction is being followed, and if there
are no other edges, like say from B to A
once we have used AB, we can no
longer go back to A.
MATHEMATICS IN THE MODERN WORLD
MODULE

This is an example of an Euler circuit:


There are no edges left unmarked also. A path
has also been traced using the directions the
arrows are pointing to.
Remember that in tracing a circuit, the beginning
point should also be the ending point.

Using the graphs below, can you identify which is a path or circuit?

The Euler Path Theorem


Eulerian Graphs are usually used in situations that involve using all edges or
paths without doing any backtracking.
Example is in mail delivery, or in bills delivery.If you are the mailman, I don’t think
you want to pass a street twice to deliver mail. One usually delivers all mail to one place
at once.
MATHEMATICS IN THE MODERN WORLD
MODULE

During the establishment of Google Maps, aside from satellite views, there were
also street views that were put up. We don’t want to think that the Google people in
charge of those worked with Asia first, then jump to the US, and back again to Asia
because they forgot a nation. We like to think that they have done methodically, street
by street.
But if one is working on their own, how do we know that we are on the right track,
or in this case path, of doing a correct Eulerian graph. For that, we need the Euler Path
Theorem.

The Euler Path Theorem


For any connected graph:
1. If all vertices are even, the graph has at least one Euler circuit (which is by
definition also an Euler path). An Euler circuit can start at any vertex.
2. If exactly two vertices are odd, the graph has no Euler circuits but at least one
Euler path. The path must begin at one odd vertex and end at the other odd
vertex.
3. If there are more than two odd vertices, the graph has no Euler paths and no
Euler circuits.

Now, work on these again, keeping the theorem in mind.

Was it easier to identify which one is the Euler Path? Or the Euler Circuit?
Hopefully, your answer is YES.
MATHEMATICS IN THE MODERN WORLD
MODULE

Fleury’s Algorithm
Another way to find an Eulerian graph is through a process known as the Fleury’s
Algorithm.

Fleury’s Algorithm
To find an Euler path or Euler circuit:
1. If a graph has no odd vertices, start at any vertex. If the graph has
two odd vertices, start at either odd vertex.
2. Number the edges as you trace through the graph making sure not to
traverse any edge twice.
3. At any vertex where you have a choice of edges, choose one that is
not a bridge for the part of the graph that has not yet been numbered.

Example: A mail carrier has the neighborhood pictured in the figure on his route. He
wants to cover each street
exactly once without retracing
any street. Find an Euler path to
accomplish this.

Following the steps in


the previous discussion,
transform this into a graph
using each crossroad as a
vertex and the paths as edges.
Then using Fleury’s
Algorithm, trace a path.
MATHEMATICS IN THE MODERN WORLD
MODULE

If you did understand, your answer should be similar to this one.

Or a reverse, which starts at H.

Activity 8.3 Euler Graphs


Instructions
Identify if the given graph in each question is an Euler Circuit or NOT.

Images from 1Line Connect the Dots App.

The quiz is not timed, so you can pause it and resume at any time.
If you cancel the quiz, your answers are discarded and they are not counted as a submission.
MATHEMATICS IN THE MODERN WORLD
MODULE

Hamiltonian Graphs
The Hamiltonian Graph is named after William Rowan Hamilton[1].
A Hamilton Graph is usually used in problems involving Shortest Path
Algorithms.
How fast can we visit all places in one go is typically the question asked.
Problems like the Travelling Salesman problem, is one of the most famous
problems dealt with in Hamiltonian Graphs.
Before discussing the different methods in finding a Hamiltonian Graph, let’s
have some definition.
A Hamiltonian path is a path that visits each vertex of the graph exactly once.
A Hamiltonian circuit is a path that uses each vertex of a graph exactly once
and returns to the starting vertex.
[1] Sir William Rowan Hamilton | Irish Mathematician, Astronomer & Physicist |
Britannica

Examples: Hamiltonian Graphs


This is an example of a Hamiltonian path.
Each vertex has been visited once, and the
edges used when visiting vertices cannot be used
twice.
Remember though, that not visiting all edges
is alright.
The Hamiltonian path is A –B – C – D – E.
MATHEMATICS IN THE MODERN WORLD
MODULE

This is an example of a Hamiltonian circuit.


Each vertex has been visited once, and formed a close
circuit.
The Hamiltonian circuit is A –E – D – F – C – B – A.

A Complete Graph
Please keep in mind always that unlike the Euler Theorem that guarantees the
existence of an Eulerian graph, Hamilton graphs have no such method.
Though, there is a condition that guarantees the existence of a Hamiltonian
circuit.
That is if a graph is complete.
In case, you need a reminder: A complete graph[1] is a graph that has an edge
connecting every pair of vertices.
Since we now have an assurance that there is a Hamiltonian circuit, how many
circuits are there?

There are exactly Hamiltonian circuits in any complete graph, where n


is the number of vertices for the graph and n > 2.

See, if we have these complete graphs.


MATHEMATICS IN THE MODERN WORLD
MODULE

As the number of vertices increases, so does the number of possible Hamiltonian


Circuits.
That’s one of the reasons why there is not a single algorithm efficient enough to
actually solve the shortest path in any traveling salesperson problem.
But we can always try.
[1] Review the first part of the module on complete graphs examples.

The Travelling Salesperson Problem (TSP)


Before we discuss three methods that solve TSPs, we need to be familiar with
another set of definitions.
A complete weighted graph is a
graph with numbers assigned to each
edge called weights.
People who travel for business
are interested in the most efficient way
to visit all of their accounts.
MATHEMATICS IN THE MODERN WORLD
MODULE

The graph shows the distances in miles between four cities that a saleswoman
needs to visit in one day.
Let A = Adamsburg, I= Irwin, P=Penn, and T=Trafford

The shortest route found in this graph is called the optimal solution.
The optimal solution for a traveling salesperson problem is a Hamilton circuit for
a complete weighted graph for which the sum of the weights of the edges traversed is
the smallest possible number.
In solving TSPs, it is always assumed that we are dealing with Hamiltonian
circuits, we assume two things, 1) they are complete graphs, and 2) they are weighted
or have values assigned to them.
Let’s start the discussion on the three methods, and how the process of finding
the optimal solution differs in the following sections.

The Brute Force Method


As the name suggests, the Brute Force Method is an inefficient way of finding the
optimal solution for a Hamilton circuit.
It involves listing down all Hamilton circuits.
And as shown previously, as the number of vertices increases, so does the
number of Hamiltonian circuits and thus it takes a long, long time to find the optimal
solution.
Though, once you find it, you are actually confident that it is the correct one.

Steps in the Brute Force Method:


1. Draw a complete weighted graph for the problem.
2. List all possible Hamilton circuits.
3. Find the sum of the weights of the edges for each circuit.
4. The circuit with the smallest sum is the optimal solution.
MATHEMATICS IN THE MODERN WORLD
MODULE

Let A = Adamsburg, I= Irwin, P=Penn, and T=Trafford


Using the problem above, since there are 4 vertices, then we have 6 Hamilton
circuits.

So either Circuit 2 (AITPA) or 4 (APTIA) is the shortest path, both with 51 miles.
Hence, the optimal solution.

The Greedy Algorithm or the Nearest Neighbor Method


When there are more than 4 vertices, using the Brute Force Method is really
inefficient.
We will discuss two more methods that may not produce the ‘true’ optimal
solution, but will at least approximate one without spending too much time listing all
possible Hamilton circuits.
MATHEMATICS IN THE MODERN WORLD
MODULE

Steps in the Nearest Neighbor Method:


1. Draw a complete weighted graph for the problem.
2. Choose a vertex to start at, then travel along the connected edge that has the
smallest weight.
3. After arriving at the next vertex, travel along the edge of the smallest weight that
connects to a vertex not yet visited.
4. Continue this process until you have visited all vertices.
5. Continue until the circuit is completed by returning to the starting vertex.
6. The sum of the weights is an approximation to the optimal solution.

NOTE: If there is a tie on the smallest weight from the same vertex, pick either
or any of the tie/s.

Example: Aaron, Belle, Carol, Donna, Eric, and Fe are best of friends.
The figure below shows the distances (km) from a friend’s place to another.
If Aaron wants to visit each of his friends’ houses exactly once to drop off gifts,
what is the shortest route that he must take?
MATHEMATICS IN THE MODERN WORLD
MODULE

1. Starting from Aaron’s house to deliver the gifts,


we stop at Belle’s house since there is only 1
mile to it.
2. Then from Belle to Carols since that’s 2 miles,
from Carol to Donna’s since there are 3 miles.
3. Then to Eric’s for 9 miles instead of Aaron’s 4
miles as Aaron has not dropped off Fe’s or Eric’s
gifts yet, so he cannot go home.
4. Then from Eric’s to Fe’s which is 6 miles,
instead of Aaron’s 5 miles as Aaron has not yet
dropped off her gift.
5. And since after Fe’s, Aaron has delivered all the
gifts, he can now go home the 12 miles.

Aaron – Belle – Carol – Donna – Eric – Fe – Aaron

So Aaron has to travel 33 miles to drop off all his gifts, and this is the shortest
path he can take.
This is the graph of the circuit taken if one is starting from Aaron’s.
A new circuit may be formed if a different friend is off dropping gifts.
MATHEMATICS IN THE MODERN WORLD
MODULE

The Edge – Picking Algorithm or the Cheapest Link Method


When there are more than 4 vertices, using the Brute Force Method is really
inefficient.
We will discuss two more methods that may not produce the ‘true’ optimal
solution, but will at least approximate one without spending too much time listing all
possible Hamilton circuits.

Steps in the Cheapest Link Method:


1. Draw a complete weighted graph for the problem.
2. Mark the edge of the smallest weight in the graph.
3. 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.
4. Continue the process until you can no longer mark any edges. Then mark the
final edge that completes the Hamiltonian circuit.
5. The sum of the weights is an approximation to the optimal solution.

NOTE: If there is a tie on the weights of edges, pick either or any of the tie/s.

Using this graph and employing the cheapest link method, we find the optimal
solution to travel through the following towns.
MATHEMATICS IN THE MODERN WORLD
MODULE

1. So the smallest weight is 200, so we mark AB.


2. Then 240, AE, followed by 310 which is BC.
3. Then 350, but since marking this will form the circuit
ABE, and also add a third edged mark to B, this is
not marked.
4. Then we have 375, ED.
5. 390, marks A for the 3rd time. 410, marks E thrice,
415 also marks A thrice, so these are not marked.
6. Leaving us with 425, for CD. And since we cannot
mark anymore, or we have created a circuit, then this
must be the optimal solution.
A–B–C–D–E–A.

Then this must be the shortest path, to go round


these cities.
For the visual, this is the Hamilton circuit.|
You can select any vertex as a starting point.

For further practices, use the 3 different problems and solve them on your own
using the different methods and compare the optimal solution for each.

Activity 8.4 Hamilton Graphs


Instructions
Create a group of 5 members.
Inform your teacher who your group mates are in
the comment section.
Answer the following problem using the 2 different
Traveling Salesperson Problem methods. (Nearest
Neighbor Method and Cheapest Link Method)
MATHEMATICS IN THE MODERN WORLD
MODULE

Brochure Blues
Instructions

Tourist Spots or Medical Facilities Brochure


Create a proposed brochure for tourist spots in Panay (or any region of the
country).
Use any traveling salesperson method to determine the shortest route from one
tourist spot to another.

Create a proposed brochure for hospitals/quarantine areas in Panay (or any


region of the country).
Use any traveling salesperson method to determine the shortest route from one
facility to another when delivering supplies (i.e personnel, medical equipment).

You might also like