Professional Documents
Culture Documents
Chapter 7
At present, graph theory finds many applications in the social sciences (social
network sites), computer science (networks of communication), chemistry (chemical
structure). Communication arts (networks of communication), and operations research
(network analysis).
Learning Objectives
Duration
1.1 Graph
A graph is a collection of points called vertices or nodes and line segment or
curves called edges that connect the vertices.
The position of the vertices, the lengths of the edges, and the shape of the edges
do not matter in a graph. Sometimes the edges are given orientations and are presented
by arrows or are given values (weights). But it is the number or vertices and which of
them ae joined by edges that matter most.
Graphs can be used to illustrate huge connections such as social networks in
Facebook, flight destinations of airlines, the simple community garbage collection
route, or even the computer system connectivity in a school.
Example: Constructing a Graph
The following table lists eleven cities connected by Cebu Pacific airline flights.
The symbol indicates that the cities have direct flights.
Ho Chi Minh
Hog Kong
Singapore
Bangkok
Lumpur
Manila
Macau
Brunei
Tokyo
Taipei
Kuala
Seoul
Manila
Tokyo
Seoul
Taipei
Hong Kong
Macau
Bangkok
Ho Chi Minh
Kuala Lumpur
Singapore
Brunei
Draw a graph that presents this information where each vertex represents a city
and an edge connects two vertices if the two cities have a direct flight.
Use your graph to determine which city has the most and least number of direct
flights.
Solution:
a. Draw eleven vertices (in any configuration you wish) to represent the eleven
cities, and connect the vertices with edges according to the table.
b. The Manila vertex has nine edges attached to it; hence, Manila has the most
number of direct flights. On the other hand, the Macau vertex is connected
to only one node; hence, Macau has the least number of direct flights. It is
important to note also that the vertex of Brunei is not connected to any node;
hence, Brunei does not have a direct flight to any of the ten cities.
Some Definitions
A loop is the edge connecting a vertex to itself.
If two vertices are connected by more than one edge, these edges are called
multiple edges.
A graph with no loops and no multiple edges is called a simple graph.
A path is an altering sequence of vertices and edges. It can be seen as a trip
from one vertex to another using the edges of the graph.
A graph is connected if there is a path connecting all the vertices.
If a path begins and end s with the same vertex, it is called a closed path or a
circuit or cycle.
Two vertices are adjacent if there is an edge joining them.
If every pair of vertices of graph are adjacent, the graph is complete. A complete
graph with n vertices is denoted by Kn.
The degree of a vertex is the number of edges attached to it.
Examples of Graph:
Null or Disconnected Graph. The graph below is a null or disconnected graph
since it has four vertices but no edges. The degree of each vertex is 0.
Graph with a Loop. The loop connects vertex A to itself. The degree of a
loop is 2.
B
Graph with Multiple Edges. Both graphs G1 and G2 on the next page are
connected and have multiple edges connecting vertices A and B. The degrees of vertices
of A and B in G1 are both equal to 3 while that of G2 are both equal to 4.
A
G1: G2:
B A B
Complete Graph. A complete graph is a connected graph in which every
edge is drawn between vertices. It should not contain multiple edges.
K1: One Vertex:
Let e be the number of edges in a complete graph. From the results above, we
find that for:
K1: e = 0, degree of the vertex is 0.
K2: e = 1, degree of the vertex is 1.
K3: e = 3, degree of the vertex is 2.
K4: e = 6, degree of the vertex is 3.
K5: e = 10, degree of the vertex is 4.
What about Kn, a complete graph with n vertices? How many edges could we
possibly get and what is the degree of each vertex in the graph? The number of edges
is equal to:
𝑛(𝑛 − 1)
𝑒𝑛 =
2
for n ≥ 3 while the degree of each vertex is obviously equal to n – 1.
1.2 Euler Paths and Circuits
Euler Circuits
An Euler circuit is a closed path that uses every edge, but
never uses the same edge twice. The path may cross through
vertices more than once.
In the Konigsberg bridges problem, finding a path crosses
each bridge exactly once and returning to the starting point is
the same as finding an Euler circuit in the graph below.
Leonhard Euler
Euler proved that the graph does not have an Euler circuit because for an Euler
circuit to exist, the degree of each vertex in the graph must be even. Apparently, all the
vertices in the Konigsberg bridges problem have odd degrees; hence not Eulerian.
Consequently, he formulated the following theorem:
Note that the Eulerian Graph Theorem only guarantees that if the degrees of all
the vertices in a graph are even, an Euler circuit exists, but it does not tell us how to
find one.
Example 1: Determine whether the following graph is Eulerian. If it is, find an Eulerian
circuit. If it is not, explain why.
A
E B
D C
Solution:
The degree of each of the vertices is 4 (even); hence, the graph is Eulerian. The
path A – D – B – E – C – A – E – D – C – B – A starts at vertex A and ends at vertex
A; hence it is circuit. Moreover, it uses all the edges all the edges only once; hence it is
an Euler circuit.
Euler Path
An Euler path is a path that uses every edge in the graph exactly once but it
does not start and end at the same vertex.
Example 2: Determine whether the following graph is Eulerian. If it is, find a Eulerian
circuit. If it is not, can you find an Euler path?
B C
A D
L E
K F
J G
I H
Solution:
Using the Eulerian Graph Theorem, this graph is not Eulerian since vertices A
and J both have odd degrees. But the path A – B – C – D – E – F – G – H – I – J – D –
G – A – L – K – J uses every edge without duplication, hence the graph contains an
Euler path. Furthermore, it can be noted that the path starts at A but ends at J, the
vertices having odd degrees.
C
D E
G
F
Solution:
a. By the Euler Path Theorem, the map shows an Euler path since the graph has
two vertices of odd degree with all other vertices of even degree. By trial and
error, the path A – B – E – F – D – B – C – F – G – C – A – G uses every edge
without duplication, hence an Euler path. Thus, it is possible for the biker to
plan a trip that traverses all the trails exactly once. The trip starts at point A, a
vertex with an odd degree and ends at point G, the other vertex with an odd
degree.
b. Using the Eulerian Graph Theorem, this graph is not Eulerian since vertices A
and G both have odd degrees. Thus, it is not possible for the biker to traverse
all the trails and return to the starting point without repeating any trail in the
trip.
In Euler circuits, closed paths use every edge exactly once, possibly visiting a
vertex more than once. On the contrary, in Hamiltonian circuits, paths visit each vertex
exactly once, possibly not passing through some of the edges. But unlike the Euler
circuit, where the Eulerian Graph Theorem is used to determine whether it contains an
Euler circuit or not, there is no straightforward criterion to determine whether or not a
Hamiltonian circuit exists in a graph. Fortunately, the following theorem can help:
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 2 , then the graph must be Hamiltonian.
Example 1:
Determine whether the graph below is Hamiltonian or not. If it is, find a
Hamiltonian circuit. If it is not, explain why.
Solution:
𝑛
There are seven vertices, hence 2 = 3.5. Since vertex A is a degree 2, less than
3.5, Dirac’s Theorem does not apply here. But it does not necessarily follow that the
graph is not Hamiltonian. In fact, it is. Consider the path A – B – C – E – D – F – G –
A. This path visits each vertex only once in the graph and returns to its starting point,
therefore, it is Hamiltonian
Solution:
𝑛
There are ten vertices in the graph, so n = 10 and = 5. Now, vertex Manila has
2
nine edges, Tokyo has five, Seoul has six, Teipei has six, Hong Kong has seven, Macau
has nine, Bangkok has six, Ho Chi Minh has five, Kuala Lumpur has five, and
𝑛
Singapore has five. Using Dirac’s Theorem, if each vertex has a degree of at least 2 =
5, then the graph is Hamiltonian. This means that the graph contains a circuit that visits
each vertex and returns to its starting point without visiting a vertex more than once.
By trial and error, one Hamiltonian circuit is Manila – Tokyo – Seoul – Hong Kong –
Macau – Bangkok – Ho Chi Minh – Kuala Lumpur – Singapore – Manila.
In example 2, there is a number of different paths which are Hamiltonian. For
example, Manila – Tokyo – Seoul – Hong Kong – Macau – Bangkok – Ho Chi Minh –
Kuala Lumpur – Singapore – Taipei – Manila is another Hamiltonian circuit that
represents a sequence of flights that visits each city and returns to the starting city
without visiting any city twice. Although generally the lengths of the edges do not
matter in the graph, there is now concern over the route that minimizes the distance
travelled. In other words, there is a need to know which of these Hamiltonian routes is
the cheapest. Hence, it is but important that one focuses on the distances between cities.
These distances can be presented using weighted graphs.
Weighted Graphs
A weighted graph is a graph in which each edge is associated with a value,
called weight.
Palawan
Ozamis
Manila
de Oro
Davao
Cebu
a. Draw a graph that represents this information where each vertex represents a
city and an edge connects two vertices if the two cities have a direct flight with
their corresponding weights.
b. Find two different routes that visit each of the places and return to its starting
point without visiting any city twice. Compare the total number of miles
travelled by each of these routes.
Solution:
a. The graph along with the weights of the edges is shown on the next page.
b. One Hamiltonian circuit is Ozamis – Cagayan de Oro – Cebu – Palawan
–Manila – Davao – Ozamis. The total distance travelled is 64 + 137 +
354 + 358 + 589 + 133 = 1,635 miles. Another node route is Ozamis –
Davao – Cagayan de Oro – Palawan – Cebu – Manila – Ozamis. This
circuit has a total distance of 133 + 118 + 414 + 354 + 355 + 477 = 1,851
miles. Obviously, the first node route is shorter than the second.
148
477 354
455
589 358
Ozamis 363 Palawan
64
240
414
133
137
495
Davao 118 Cagayan de Oro
In Example 3, we computed two Hamiltonian routes. But these results do not
guarantee that one of them is the shortest distance travelled. From the solution in
Example 3, is Ozamis – Cagayan de Oro – Cebu – Palawan –Manila – Davao – Ozamis
the shortest route? There is no guarantee. If this is the case, how can the shortest route
be determined after visiting all the cities exactly once and going back to the origin city?
One method is to down all the Hamiltonian circuits, compute the total weight, and
choose the smallest total weight. Unfortunately, this is tedious especially when the
number of possible circuits is too large. However, there are two algorithms, the greedy
algorithm and the edge-picking algorithm, that can help in finding a good solution.
The Greedy Algorithm
1. Choose a vertex to start at, and 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 an edge of the 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.
Note that both of these algorithms apply only to complete graphs.
Example 4:
Aaron, Belle, Carol, Donna, Eric, and Fe are best of friends. The figure below
shows the distances (in kilometers) from a friend’s place to another. If Aaron wants to
visit each of his friend’s houses exactly once, what is the shortest route that he must
take?
Solution: Using the Greedy Algorithm
To find the least route that Aaron can take, one can find a Hamiltonian circuit
using the greedy algorithm. By trial and error, one Hamilton circuit is from Aaron’s
house – Belle’s house – Carol’s house – Donna’s house – Eric’s house – Fe’s house –
Aaron’s house. The total weight of the circuit is 1 + 2 + 3 + 9 + 6 + 12 = 33. But there
are other Hamiltonian circuit from Aaron’s house. Consider the Hamiltonian circuit
from Aaron’s house – Eric’s house – Fe’s house – Carol’s house – Donna’s house –
Belle’s house and back to Aaron’s house. The total weight of this circuit is 5 + 6 + 7 +
3 + 10 + 1 = 32. Ironically, this circuit has a weight lesser than the weight of the circuit
derived using the greedy algorithm. Thus, the greedy algorithm only attempts to give a
circuit of minimal total weight, although it does not always succeed.
Planar Graph
A planar graph is a graph that can be drawn so that no edges intersect
each other (except at vertices)
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.
Four-Color Theorem
The chromatic number of a planar graph is at most 4.
Example 1:
Consider the complete graphs K4 and K5. Determine their chromatic number.
Solution:
First, assign vertex A with one color, say red, then vertex B with another color,
say blue. Since you cannot color two adjacent vertices using the same color, use green
to color the vertex C, and finally, yellow to color the vertex D. Thus, K4 is four-
colorable. It is important to note that K4 is planar, hence the Four-Color Theorem is
satisfied.
Previously, it is seen that K5 is not planar so the Four-Color Theorem does not
hold here. Now, assign each vertex of the graph with one color in such a way that no
two adjacent vertices have the same color as shown below. Thus, the chromatic number
of K5 is 5. Can you find the chromatic number of K8?
Example 2:
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 at different time slots. An “X” in
the table on the next page 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.
Library Facility
Physical Facility
Student Welfare
Instruction (FI)
Program (OP)
Development
Outreach
Committee
Faculty
Faculty
(SW)
(FD)
(LF)
(PF)
Faculty Instruction - X X X
Faculty Development X - X X X
Outreach Program X - X X X
Physical Facility X X - X
Library Facility X X X - X
Student Welfare X X X X -
Solution:
First, draw a graph representing the six committees using six vertices or nodes
in any configuration. An edge connects two committees that share at least one member.
Then assign each vertex of the graph with one color in such a way that no two adjacent
vertices have the same color.
Obviously, the graph is not 2-colorable because there are circuits of odd length,
but the graph is 3-colorable. Hence, the minimum number of time slots necessary to
ensure that all faculty members can attend all meeting is 3.
First time slot: Faculty Instruction, Student Welfare
Second slot: Faculty, Outreach Program
Third slot: Library Facility, Physical Facility
Example 3:
The fictional map on the next page shows the boundaries of barangays on
a rectangular town.
a. Represent the map of a graph
b. Find a coloring of the graph using the fewest possible number of colors
c. Color the map according to the graph coloring theorem.
Solution:
First, represent each barangay using vertices A, B, C, D, E, F, G, H, I, and J.
A H G
J I
F
B
D
C E
Second, connect two vertices with an edge if the two barangays share the same
boundary.
Third, color the vertices of the resulting graph so that no edge connects two
vertices with the same color. Coloring is not unique.
Finally, color each barangay in the map according to the color of its assigned
vertex in the previous step.
H G
A
J I F
B
D
C E
1.5 Trees
A tree is a mathematical structure which is a type of graph which has the
following properties:
1. undirected;
2. connected (each of the vertices is connected or linked to at least one other
vertex); and
3. acyclic (there is only on route from any vertex to any other vertex or has no
cycle).
An example of a tree is the Philippine Judiciary Organization Chart as shown
in the figure below.
Some common terminologies related to the graph of trees are illustrated in the
following diagram.
A full m-ary tree is a tree in which all external vertices are at the same time
depth or has exactly m children. Tree T1 in the following figure has exactly two children
per vertex and hence is called a full binary tree. Tree T 2 is a full ternary tree because
each vertex has three child vertices.
The height of a rooted tree is the number of edges along the longest path from
the root vertex to the farthest child vertex. Given a full m-ary tree T of height h, T has:
𝑚ℎ+1 −1
i. 𝑣= vertices;
𝑚−1
𝑚ℎ −1
ii. 𝑖= internal vertices; and
𝑚−1
The most common application of the tree is determining the number of matches
that must be played to determine the champion in a single elimination tournament.
Example 1:
A local basketball league implements a new ruling of single-elimination
wherein a team is eliminated after a single loss. If there are 16 teams to compete in the
tournament, how many matches must be played to determine the champion?
Solution:
The number of teams represent the terminal vertices so t =16. It is a binary tree
since there are two teams competing in each ball-game, thus m = 2.
Substituting the values of t and m to determine the number of internal vertices,
we get:
𝑚ℎ − 1 16 − 1
𝑖= = = 15.
𝑚−1 2−1
Thus, there will be 15 matches before a champion will be declared.
References/Additional Resources/Readings
Baltazar, E. C. et al. (2013). Mathematics in the Modern World. Quezon City: C&E
Publishing, Inc.
Nocon, R.C. & Nocon, E.G. (2018). Essential Mathematics for the Modern World. Quezon
City: C&E Publishing, Inc.
Quintos, R.T. et al. (2018). Mathematics in the Modern World. St. Andrew Publishing
House
Activity Sheet 28
Charles
Gladys
Aileen
David
Erica
Fred
Bien
Aileen X X X
Bien X X X X
Charles X X X
David X X X X
Erica X X X
Fred X X X X
Gladys X X X
2. Draw a graph that represents the information given in the table below involving
teachers and subjects that are assigned to them in a semester.
2. For each of the networks below, determine whether it has an Euler path. If it
does, find one.
Activity Sheet 30
2. A school bus driver would like to bring the kids back to their homes along a
least expensive route. Is this an Eulerian or Hamiltonian problem? Explain why?
3. Eight senior high-school student clubs need to hold meetings on the first day of
school. However, some students 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? An “X” in the
table below indicates that the two corresponding clubs share at least one
member. Use graph coloring concepts to solve the minimum number of time
slots necessary to ensure that all members can attend all meetings.
Publication
Math Club
Arts Club
Council
Student
Student
Science
Society
Fitness
Debate
Club
Honor
Club
Club
Club
Honor Society X X X X
Math Club X X
Student Council X X X
Science Club X X
Arts Club X X
Debate Club X X X
Student
X X X X
Publication
Fitness Club X X
Activity Sheet 32
2. The PBA League also plans to follow the new NBA ruling of single-elimination.
If there are 2 teams to compete in the tournament, how many matches must be
played to determine the champion? To help the participants understand the
scheduling of the games, draw a full binary tree and explain how your proposed
scheduling will work until the champion is proclaimed.
Learner’s Feedback Form
In what particular portion of this learning packet, you feel that you are struggling or
lost?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Did you raise your concern to you instructor? □ Yes □ No
To further improve this learning packet, what part do you think should be enhanced?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
NOTE: This is an essential part of course module. This must be submitted to the subject
teacher (within the 1st week of the class).