6.2 - Weighted Graphs
6.2 - Weighted Graphs
CHAPTER
6
The Mathematics
of Graphs
6.2
Section Weighted Graphs
1
4/19/21
Hamiltonian Circuits
A circuit that uses every edge, but never uses the same
edge twice, is called an Euler circuit. (The path may
cross through vertices more than once.)
2
4/19/21
Hamiltonian Circuits
In some situations we may be more interested in paths
that visit each vertex once, regardless of whether all
edges are used or not.
Hamiltonian Circuits
This path visits each vertex once and returns to the starting
vertex without visiting any vertex twice. This type of path is
called a Hamiltonian circuit. 6
3
4/19/21
Hamiltonian Circuits
4
4/19/21
Example 1 – Solution
There are six vertices in the graph, so n = 6, and every vertex has a
degree of at least n/2 = 3.
Answer: The graph has seven vertices, so n=7 and n/2 = 3.5. Several vertices
are of degree less than n/2, so Dirac’s theorem does not apply. Still, a routing
for the document may be possible.
10
5
4/19/21
Weighted Graphs
11
11
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.
(Note that the length of an edge does not necessarily correlate to its weight.)
12
12
6
4/19/21
Weighted Graphs
For each Hamiltonian circuit in the weighted graph, the sum
of the weights along the edges traversed gives the total
distance traveled along that route.
We can then compare different routes and find the one that
requires the shortest total distance. This is an example of a
famous problem called the traveling salesman problem. 13
13
14
14
7
4/19/21
Example 2 – Solution
The various options will be simpler to analyze if we first
organize the information in a graph. Begin by letting each
city be represented by a vertex. Draw an edge between two
vertices if there is a flight between the corresponding cities,
and label each edge with a weight that represents the
number of miles between the two cities.
15
15
Example 2 – Solution
cont’d
A route that visits each city just once corresponds to a
Hamiltonian circuit.
16
8
4/19/21
17
17
18
18
9
4/19/21
19
19
20
20
10
4/19/21
21
21
22
22
11
4/19/21
Figure 5.10
23
23
24
24
12
4/19/21
Figure 5.11
25
25
Example 3 – Solution
Begin at A. The weights of the At D, the edge with the
edges from A are 13, 5, 4, 15, smallest weight is DB.
and 8. The smallest is 4. Connect D to B.
Connect A to D.
26
26
13
4/19/21
cont’d
27
27
cont’d
28
28
14
4/19/21
29
29
Answer: A-D-C-B-E-A
Total weight: 26
30
30
15
4/19/21
31
31
Figure 5.11
32
32
16
4/19/21
Example 4 – Solution
The edge of next
smallest weight is AD
with weight 4.
We first highlight the edge of
smallest weight, namely BD
with weight 2.
33
33
34
34
17
4/19/21
35
36
18
4/19/21
Answer: A-D-C-B-E-A
Total weight: 26
37
37
38
38
19
4/19/21
39
39
40
40
20
4/19/21
41
41
Example 5 – Solution
First we draw a weighted graph with vertices representing
the cities and each edge labeled with the price of the flight
between the corresponding cities.
42
42
21
4/19/21
Answer: L – P – M – R – V – B - L
Total airfare for the trip, is
160 + 215 + 380 + 480 + 375 + 325 = $1935 43
43
44
22
4/19/21
45
45
Answer
46
46
23
4/19/21
47
47
Exercise
Page 241 Page 255
A map of a park is shown with bridges 1. Use the greedy algorithm to
connecting islands in a river to the find a Hamiltonian circuit
banks. starting at vertex A in the
weighted graph.
a. Represent the map as a graph.
b. Is it possible to take a walk that
2. Use the edge-picking
crosses each bridge once and
algorithm to find a Hamiltonian
returns to the starting point without
circuit in the indicated graph.
crossing any bridge twice? Justify
your answer.
48
48
24