0% found this document useful (0 votes)
214 views14 pages

Module 3 Topic 3 Lesson 2B Weighted Graphs PDF

The Edge-Picking Algorithm also finds the optimal route with total time of 28 minutes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
214 views14 pages

Module 3 Topic 3 Lesson 2B Weighted Graphs PDF

The Edge-Picking Algorithm also finds the optimal route with total time of 28 minutes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 14

Mathematics in the Modern World

Module 3 – Topic 3
Graph Theory
Lesson 2B: Weighted Graphs
Introduction
In many applications, you can use the edges or the vertices of a
graph to represent real-life metrics. In navigation, for example, the
vertices may mean destinations while the edges may mean the
distance or cost of traveling from one point to another. In
communication network, the edges may indicate loading capacity.
Informally, any value that is assigned to the edges is called weight. In
such cases, the question of whether the graph is Eulerian or
Hamiltonian should no longer be constrained to utilizing the vertices
or edges of the graph, but to make the process more efficient by
optimizing the weights in the graph.
Assigning weights to the edges of a graph is the labeling aspect of a
graph. Graph labeling has become one rich area of graph theory in
terms of research opportunities because of the unlimited areas where
this concept can be applied.
Learning Outcomes

At the end of the lesson, students should be able to:


1. define and illustrate a weighted graph;
2. explain and execute algorithms for identifying
Hamiltonian cycles in weighted graphs; and
3. use the algorithms to solve practical problems about
weighted graphs.
Definitions

B
-A graph is considered weighted if A 8
its edges are assigned numeric
values called weights. 2

-A weighted graph is a graph where 6 3


every edge has associated numeric 4
value (called weight)

D 5 C

Weighted K4
Illustration
One problem that can be addressed with A 8 B
weighted graphs is to traverse all the vertices
through the least total weights possible. 2

Examine the total weights for all possible 6 3


Hamiltonian cycles of the weighted K4 shown on 4
the right.

D 5 C

Weighted K4
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.
The Greedy Algorithm: Illustration

1. Suppose we start at vertex A. By the A 8 B


algorithm, we proceed to vertex C, as the
weight 4 is the least compared to vertex B 2
(weight 8) or to vertex D (weight 6).
6 3
2. From vertex C we proceed to vertex B 4
(weight 3 vs 5 of D). Then to D (weight 2).
3. Go back to A with the weight 6.
D 5 C
The cycle A-C-B-D-A accumulates a total
weight of
4 + 3 + 2 + 6 = 15
Limitation of the Greedy Algorithm

1. Suppose we start at vertex B. In this B


A 8
case, we pick D next.
2. From vertex D we proceed to vertex C, 2
then to vertex A.
6 3
3. Go back to B with the weight 8. 4

The cycle B-D-C-A-B accumulates a total


weight of D 5 C
2 + 5 + 4 + 8 = 19
(not minimum)
Edge-Picking Algorithm
1. Mark the edge with the least weight (choose arbitrarily if the least
weight is carried by 2 or more edges).
2. Mark the edge with the second least weight. Take note of the
following:
i. Choose arbitrary edge in cases of tied weights.
ii. Do not choose an edge if it completes a cycle.
iii. Do not choose an edge if it becomes the third marked edge
incident to a single vertex.
3. Keep repeating Step 2 until there is no more edge available.
4. Mark the last edge that will complete the Hamiltonian cycle.
Edge-Picking Algorithm: Illustration

A 8 B A 8 B A 8 B A 8 B

2 2 2 2

6 3 6 3 6 3 6 3
4 4 4 4

D 5 C D 5 C D 5 C D 5 C

2 + 3 + 4 + 6 = 15
Example
Egay is tasked to distribute examination papers during the quarterly
examination of the mathematics department. From the office, he has
to bring the test papers and answer sheets to four examination areas
in the campus: North Building, South Building, West Building, and
Southwest Building. The table below summarizes the roaming time
from one area to other areas. Determine the roaming route that gives
the least time for the distribution of the examination materials.
Example
Example

Using the Greedy Algorithm:


Office-North-West-Southwest-
South-Office Sum of weights:
7 + 5 + 4 + 3 + 9 = 28
It can take 28 minutes for Egay to
finish the distribution.
Example
Using the Edge-Picking Algorithm:

Order of edge Edge Weight


(time)
1st Southwest – South 3
2nd Southwest – West 4
3rd West – North 5
4th North – Office 7
5th (closing) Office – South 8
TOTAL TIME 28

Possible routes:
Office-South-Southwest-West-North-Office
Office-North-West-Southwest-South-Office

You might also like