You are on page 1of 31

GEC 3

Mathematics in the
Modern World

Course
Modules

Special Topic: Mathematics of Graphs


A MODULE IN
Mathematics of Graphs

Introduction

There are many connections we experience in our daily lives. Perhaps the one
that we can relate the most is our Facebook connections. How many friends
do we have? How many mutual friends do we have with another Facebook
user? Still there are many connections we can think of and these are
illustrated and analyzed by a branch of mathematics called GRAPH THEORY.

In this module, you will be oriented to this branch of mathematics. First, you
must know what a graph is. A graph in graph theory is different from graphs
of functions you already learned in your algebra subjects.

Learning Outcomes

After completing this module, you are expected to

1. construct graphs from a given situation.


2. identify whether or not two graphs are equivalent.
3. tell whether or not a given graph is Eulerian and find an Euler circuit.
4. apply Dirac’s Theorem to decide whether or not a given graph is
Hamiltonian and find a Hamiltonian circuit.
5. identify planar and non-planar graphs
6. apply graph coloring in map coloring and scheduling tasks.

What You Need to Know

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


called edges that connect vertices.

Graphs can be used to represent many different situations. The two


graphs in Figure 1 uses the same graphs that are used in different contexts.

Page 1 of 30
Figure 1
Examples of Graphs

Each vertex in Figure 1(a) represents a person in a Facebook connection


and each edge indicates that the persons are friends in Facebook. From this
graph, we can say that PJ has the most number of friends in Facebook. Figure
1(b) shows cities that are connected by available flight schedules. It can be
noted that the only to reach Cauayan City in this situation is through Manila.

Graphs may be constructed using a tabular representation as a guide.


An example is given below.

Example 1.

The following table lists five students at a college. An “X” indicates that
the two students belong to the same student organization in the current
semester.

Charice Jason Judith Jaymar Jade


Charice X X
Jason X X X
Judith X X
Jaymar X X
Jade X

a. Draw a graph that represents this information where each vertex


represents a student and an edge connects two vertices if the
corresponding students belong to the same student organization.
b. Use your graph to answer the following questions: Which student is
involved in most organizations? Which student has only one
membership in common with others? How many organizations does
Judith have in common with others?

Page 2 of 30
Solution.

a. We draw five vertices to represent the five students, and connect


vertices with edges according to the table.

Figure 2
A graph of students and their common organization

b. The vertex corresponding to Jason is connected to more edges than the


others. This means that he has the most number of memberships to
organizations in common with other students. Jade has only one
membership in common with others. Judith has two organizations in
common with others.

There are many types of graphs based on how the edges are connected.

Type of Graph Example/s


Null graph
A graph where vertices are not connected
by edges, that is, no edge connects the
vertices.

Simple graph
A graph that does not contain loops and
multiple edges.

Page 3 of 30
Non-simple
A graph that contains two or more edges
that connect the same vertices called
multiple edges or an edge that loops to
the same vertex

Connected graph
A graph where any vertex can be reached
from any vertex by tracing along edges.

Complete graph
A graph where all possible edges are
drawn between vertices with no multiple
edges is called.

Bipartite Graph
A graph where vertices are split into two
sets such that no two vertices within the
same set are adjacent.

Tree
A connected graph in which any two
vertices are connected by exactly one
path. It contains no cycle and any edge
you take out, the graph becomes
disconnected

In a graph, edges may be straight or curved, and the lengths and


positions are not important. Even the exact placement of the vertices is
not important. The graph simply illustrates connections between vertices.

Page 4 of 30
The three graphs shown in Figure 4 are considered equivalent graphs
because the edges form the same connections of vertices in each graph.

Figure 4
Equivalent graphs

If we prepare the table for the graphs in Figure 4, all will have the
same representation as shown in the table below.

A B C D E
A X
B X X X
C X
D X
E X

Euler Circuits

Before we discuss Euler circuits, we need to familiarize with some


terminology. Consider the graph in Figure 5.

Figure 5
A graph containing different paths

Page 5 of 30
 A path contained in a graph can be thought of as a walk through the
graph from one vertex to another. One path in the graph would be A-
B-C-D.
 If a path ends at the same vertex at which it started is called a closed
path or circuit. The path A-B-C-D-A is a closed path since it started
and ended at A.

Figure 6
A graph containing a closed path

Consider the path C-B-A-D-F-G-H-E-G-D-B-E-C of the graph in Figure


6. Since it started and ended at C, we know that it is a closed path or a circuit.
Moreover, if we trace the path we see that the circuit uses every edge but never
uses the same edge twice. If this is the case, then the closed path is called an

Euler proved that the graph in Figure 5 could not have an Euler circuit.
He examined the number of edges that met at each vertex. The number of
edges that meet at a vertex is called the degree of a vertex. He made the
observation that every time you approached a vertex you would need to leave
that vertex in order to complete the desired path. If you traveled through that
vertex again, you would again need an approaching edge and a departing
edge. This means that for an Euler circuit to exist, the degree of every vertex
must be an even number. Also, he was able to show that any graph whose
every vertex has an even degree must have an Euler circuit. Such graphs are
called Eulerian.

Eulerian Graph Theorem

A connected graph is Eulerian if and only if every vertex of the


graph is of even degree.

Page 6 of 30
The Eulerian Graph Theorem guarantees that when all vertices of a graph
have even degree, an Euler circuit exists, but it does not tell us how to find
one. Because we deal with graphs which are relatively small, we will rely on
trial and error in finding Euler circuits.

Example 2.

Determine whether the graph shown in Figure 7 is Eulerian. If it is, find an


Euler circuit. If it is not, explain how you know.

Figure 7

Solution.

Each vertex has a degree 4, so by Eulerian Graph Theorem, the graph is


Eulerian. There are many possible Euler circuits. By trial and error, one
Euler circuit is A-B-D-E-C-A-D-C-B-E-A.

Euler Paths

In this case, what we are looking for is a path that uses every edge once
and only once. We call such path an Euler path.

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.

Page 7 of 30
Example 3.

The floor plan of a gallery is given in Figure 8. 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?

Figure 8
Floor plan of a gallery
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, as shown in Figure 9.

Figure 9
Graph of the floor plan of the gallery
The graph in Figure 9 is equivalent to our floor plan. 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. Thus we are looking for an Euler path.
In the graph, two vertices are of odd degree and the rest of the vertices 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 E. By trial and error, one such path is E-D-A-B-C-G-F-E-A-
E-B-F-C.

Page 8 of 30
Weighted Graphs and Hamiltonian Circuits

In some situations, we may be interested in paths that visit each vertex once,
instead of edges. The path that visits each vertex once and returns to the
starting vertex without visiting any vertex twice is called a Hamiltonian
circuit.

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.

Unlike Euler circuits, no theorem would guarantee that a graph has a


Hamiltonian circuit. However, a theorem may help in identifying Hamiltonian
graphs.

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.

Example 4.

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

Figure 10
Graph which may contain a Hamiltonian circuit

Page 9 of 30
Solution.

There are six vertices in the graph, so 𝑛 = 6, and every vertex has a degree
𝑛
of at least 2 = 3. So, by Dirac’s theorem, the graph is Hamiltonian. This
means that the graph contains a Hamiltonian circuit. The circuit A-B-F-D-E-
C-A is one Hamiltonian circuit.

We may represent graphs with associated values, called weights. Such a


graph is called a weighted graph. The value can represent any quantity we
desire.

Example 5.

For the weighted graph below, find three different Hamiltonian circuits
and find the total weights for each circuit.

Figure 11
A weighted graph

Solution.

There are six vertices in the graph, so 𝑛 = 6, and every vertex has a degree
𝑛
of at least 2 = 3. We have verified that the graph is Hamiltonian. Three
Hamiltonian circuits are A-C-E-B-D-F-A, A-B-D-E-C-F-A, and A-F-C-E-D-B-
A. The total weights are as follows:

A − C − E − B − D − F − A: 5 + 5 + 7 + 10 + 12 + 8 = 47
𝐴 − B − D − E − C − F − A: 5 + 10 + 6 + 5 + 13 + 8 = 47
A − F − C − E − D − B − A: 8 + 13 + 5 + 6 + 10 + 7 = 49

Page 10 of 30
Algorithms in Complete Graphs

There is no known shortcut for finding an optimal Hamiltonian circuit in a


weighted graph. There are, however, two algorithms, the greedy algorithm
and the edge-picking algorithm, that can be used to find solutions. Both these
algorithms apply only to 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.

Example 6.

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

Figure 12
A weighted graph

Page 11 of 30
Solution.

Begin at A. The weights of the edges from A


are 1, 5, 10, and 9. We choose 1 since it
has the least value. Connect A to C.

From C, the remaining edges have weights


2, 4, and 6. So we choose 2 and connect C
to D.

From D, the weights of the remaining edges


are 8, 10, and 7. Thus we choose 7 and
connect D to E.

The weights from E are 4, 3, and 9. We


then choose 3 and connect E to B.

Finally, we connect B to A to complete the


Hamiltonian circuit. The Hamiltonian
circuit is A-C-D-B-A and its total weight is
1 + 2 + 7 + 3 + 5 = 18.

Page 12 of 30
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 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 this process until you can no longer mark


any edges. Then mark the final edge that completes the
Hamiltonian circuit.

Example 7.

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

Solution.

We start by highlighting the edge with the


smallest weight. In this case, the smallest
weight is 1 and so we connect A to C.

We then highlight the next smallest weight


which is 2. This time, we connect C to D.

Page 13 of 30
The next weight we highlight is 3 which
connects B and E.

The next smallest weight is 4. However,


highlighting 4 would add a third edge from C.
Thus, we are forced to choose 5 which
connects B and A.

The next weight would be 6. However,


highlighting this edge will result to a circuit
that contains only 3 vertices. A, B, and C.
Hence, we choose the edge with a weight of 7,
connecting D and E. Finally, the Hamiltonian
circuit is A − C − D − E − B − A with a total
weight of 18.

We see that using different algorithms would lead to the same Hamiltonian
circuit. Thus, resulting too an equal total weight. It is left for you to verify if
this situation is true for all weighted complete graphs.

Application of Weighted Graphs

An edge of the graph may be labeled with different measures, say time or cost.
Because of this, an application of the algorithms earlier presented is possible.
We look at some of these applications.

Example 8.

Jamie needs to mail a package at the post office, pick up several items at the
grocery store, return a rented clothing, and make a deposit at her bank. The

Page 14 of 30
estimated driving time, in minutes, between each of these locations is given
in the table below.

Home Post office Grocery Boutique Bank


store
Home - 14 12 20 23
Post office 14 - 8 12 21
Grocery store 12 8 - 17 11
Boutique 20 12 17 - 18
Bank 23 21 11 18 -

Use both the algorithms to design routes for Jamie to follow that will help
minimize her total driving time. Assume that she must start at home and
return home when her errands are done.

Solution.

We first represent the information by a graph as shown in Figure 13.

Figure 13
Graph of Jamie’s activities

We then apply the algorithms and see which of the two yields a better result.

Page 15 of 30
(a) Resulting Hamiltonian circuit when (b) Resulting Hamiltonian circuit using
Greedy algorithm is applied the Edge-Picking algorithm
Figure 14

In this case, the total weight obtained by applying the Greedy algorithm is
23 + 18 + 12 + 8 + 12 = 73, while that of Edge-Picking algorithm is 20 + 12 + 8 +
11 + 23 = 74. Since we want a minimum number of time for Jamie to complete
her task, we choose the route yielded by the Greedy algorithm because it
resulted to a lower total weight.

Planarity and Euler’s Formula

Graphs may be redrawn to show that it is a planar graph. By planar graph,


we mean that the graph may be drawn in such a way that no edges intersect.

Planar Graph

A planar graph is a graph that can be drawn so


that no edges intersect each other (except at
vertices).

The graph that is drawn showing o intersection between edges is called the
planar drawing of the graph.

Example 9.

Show that the graph in Figure 15 is planar.

Page 16 of 30
Figure 15
Graph of the problem
Solution.

We first analyze if it is possible for us to redraw the graph without


intersections. We see that if we move vertex D below C, we come up with a
graph drawn in Figure 16.

Figure 16
Resulting graph when vertex D is moved below vertex C

Since no edges intersect, we have shown that the graph given in Figure 16 is
planar.

A 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 a given graph, that is not planar.
The Utilities graph below is a common subgraph to watch for. Another graph
that is not planar is the complete graph with five vertices, denoted 𝐾5 .

Page 17 of 30
(a) The Utilities graph (b) Complete graph 𝐾5

Figure 17

Subgraph Theorem

If a graph G has a subgraph that is not planar, then G is


also not planar. In particular, if G contains the Utilities
Graph or K5 as a subgraph, G is not planar.

Example 10.

Show that the following graph is not planar.

Figure 18

Page 18 of 30
Solution.

We start by removing vertex G and edges


EG, GF, EF, and GD

We then move E and F as shown to


check if we can redraw the graph and
come up with the utilities graph.

Moving D shows that the subgraph is


the utilities graph. Thus, by the
subgraph theorem, the given graph is
not planar.

The Utilities graph and 𝐾5 serve as building blocks for nonplanar graphs. It
was proved that any nonplanar graph will always have a subgraph that is the
Utilities graph or 𝐾5 .

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 𝐾5 .

Euler’s Formula

Euler noticed a connection between various properties of planar graphs. Aside


from edges and vertices, he considered the faces of a graph. In a planar
drawing of a graph, the edges divide the graph into different regions which are
called faces. The region surrounding the graph, or the exterior is called the
infinite face. The following relationship, called Euler’s formula, is always true.

Page 19 of 30
Euler’s Formula

In a connected planar graph drawn with no intersecting edges, let


𝑣 be the number of vertices, 𝑒 the number of edges, and 𝑓 the
number of faces. Then 𝑣 + 𝑓 = 𝑒 + 2.

Example 11.

Count the number of edges, vertices, and faces in the planar graph below,
and then verify Euler’s formula.

Figure 19

Solution.

In the graph, there are 5 vertices, 4 faces, and 7 edges. Using Euler’s formula,
we have 𝑣 + 𝑓 = 5 + 4 = 9 and 𝑒 + 2 = 7 + 2 = 9. So, 𝑣 + 𝑓 = 𝑒 + 2.

Graph Coloring

Coloring Maps

In the mid-1800s, Francis Guthrie tried to color a map of countries of


England. In particular, he wanted countries sharing a common border to have
different colors. After several colorings, he noticed that at most four colors
were required to color the map. This observation became known as the four-
color problem.

An example is a map of the United States shown in Figure 20. Note that the
map has only four colors and that no two states that share a common border
have the same color.

Page 20 of 30
Figure 20

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.

Consider a fictional map shown in Figure 21 with each region labeled as


letters.

Figure 21

We can represent a region by a vertex. If two regions share the same


boundary, we connect them using an edge. This is illustrated in Figure 22.

(a) Vertices are connected based on (b) The graph representing the map
common boundary

Figure 22

If we erase the map, what will be left is the graph that represents the map
(Figure 22(b)). Recall that a vertex is a region in the map and an edge indicates

Page 21 of 30
that the two regions share a common boundary. Now, we color the vertices
using a simple rule: If two vertices are connected, they must not be assigned
the same color. The result of this coloring is given in Figure 23.

(a) Vertices are colored (b) Colored map

Figure 23

From the figure, we see that map coloring is based on the color of the vertex
in the graph. In this case, since 4 colors were used to color the map, then the
map is said to be 4-colorable.

Four Color Theorem

Every planar graph is 4-colorable.

Example 12.

The map below shows the boundaries of countries on a 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.

Figure 24
An uncolored map

Page 22 of 30
Solution.

We start by assigning vertices


for each region. Each vertex
is labeled with the letters A to
I.

We connect the vertices based


on the common boundaries of
the corresponding regions.

We now drop the map and


consider its representative
graph.

We then proceed with the


vertex coloring following the
rule. Thus, vertices A and H
are colored yellow, vertices B,
D, F, and I are red, vertices C
and E are colored green, and
vertex D is colored blue.

Finally, we color the map


based on the color of its
corresponding vertex.

Page 23 of 30
Chromatic Number of a Graph

We mentioned previously that representing a map as a graph always results


in a planar graph. The four-color theorem guarantees that we need only four
colors to color a planar 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. In general, there is no efficient method of
finding the chromatic number of a graph, but a theorem can tell us whether
a graph is 2-colorable.

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.

Task Scheduling

Determining the chromatic number of a graph and finding a corresponding


coloring of the graph can solve practical problems. One common application
is in scheduling meetings or events. This is best shown by example.

Example 13.

Five different school organizations want to schedule meetings every last day
of the month. Some club members, however, belong to more than one of these
clubs, so clubs that share members cannot meet at the same time. Find the
number of time slots required so that all members can attend all meetings.
Clubs that have a member in common are indicated with an “X” in the table
below.

Scholars Student Community Student Musical


Society Government Outreach Newspaper Ensemble
Scholars
− X X
Society
Student
X − X X X
Government
Community
X − X
Outreach
Student
X X X − X
Newspaper
Musical
X X −
Ensemble

Page 24 of 30
Solution.

We can represent the given information by a graph as shown in Figure 27.


Each organization is represented by a vertex, and an edge connects two
vertices if the corresponding organizations have at least one common member.

Figure 25

If two organizations are connected, then they cannot meet simultaneously. If


we let a color correspond to a time slot, then we need to find a coloring of the
graph that uses the fewest possible number of colors. Following the rule on
graph coloring we get the vertex coloring of the graph shown in Figure 28.

Figure 26

The graph can be colored using at least three colors. In this case, since each
color corresponds to a time slot, then we can schedule the meetings as follows:

First time slot: Scholars Society, Musical Ensemble,


Community Outreach
Second time slot: Student Newspaper
Third time slot: Student Government

Page 25 of 30
Supplementary Learning Resources

 Without Lifting the Pencil


https://www.transum.org/Maths/Activity/without/

 Graph Isomorphism Explained + A Game to Play!


https://www.youtube.com/watch?v=rOTXqBBMFxc
http://github.ericmickelsen.com/graf/isomorphism.html

Flexible Teaching-Learning Modality

Remote (asynchronous)

 Module, exercises, problem sets, powerpoint lessons


Assessment Task

Direction: Answer each item.

1. For each graph, determine the number of edges, the number of vertices,
the number of vertices that are of odd degree, whether the graph is
connected, and whether the graph is complete.

Number Is the graph


Number of
Number
Graph of vertices
of edges connected? complete?
vertices of odd
degree

2. Determine whether the two graphs are equivalent.

Page 26 of 30
3. Label the second graph so that it is equivalent to the first graph.

4. Consider the graphs given in the following table.

Determine whether the graph is Eulerian. If it is, find an Euler circuit.


If it is not, explain why.

If yes, sketch If no, explain


Is the graph
Graph the Euler why.
Eulerian?
circuit

Page 27 of 30
If the graph does not have an Euler circuit, does it have an Euler path?
If so, find one. If not, explain why.

Does the graph If no, explain


If yes, sketch
Graph contain an why.
the Euler path
Euler path?

5. Use Dirac’s algorithm to verify that the following graphs are


Hamiltonian. Then find the Hamiltonian circuit.

Graph Verification Hamiltonian circuit

Page 28 of 30
6. Consider the given graph below. Find two Hamiltonian circuits with
different total weights, starting at vertex A. Compute the total weight of
each circuit.

Graph Hamiltonian circuit 1 Hamiltonian circuit 2

Total weight: __________ Total weight: _________

7. Consider the graph below. Use the greedy algorithm to find a


Hamiltonian circuit starting at vertex B.

Graph Hamiltonian circuit

8. Show that each of the given graphs is planar by finding a planar


drawing.

Graph Planar drawing

Page 29 of 30
9. Verify Euler’s formula for each graph given.

Graph Verification

𝑣 = _______
𝑒 = _______
𝑓 = _______

𝑣 = _______
𝑒 = _______
𝑓 = _______

10. Represent the given map by a graph and find a coloring of the
graph using the least possible number of colors. Then color the map
based on the graph coloring you found.

Graph and Graph


Uncolored map Coloring of the map
coloring

Page 30 of 30

You might also like