topic badge
AustraliaVIC
VCE 11 General 2023

8.06 Weighted graphs and networks

Lesson

Network weights

The number added to each edge is called a weight. Often it represent time or distance, here are a few examples.

This image shows European capitals. Ask your teacher for more information.

Approximate travel times, in hours, between some European capitals

This image shows the travel times in hours between some European capitals. Ask your teacher for more information.

Average length of bonds in acetic acid (CH_3COOH), measured in Angstrom

This image shows a simple circuit diagram with resistances in Ohms. Ask your teacher for more information.

A simple circuit diagram, with resistances measured in Ohms.

These numbers transform the way we look at networks. We will be able to encode a lot more information, and perform more insightful analysis.

If a network has weights on its edges, we can give a weight to the whole network by adding up all the weights. This applies to subnetworks too. Similarly, we can give a weight to any walk by adding up all the weights on the edges chosen in the walk (the weight of a walk is sometimes called its length).

This image shows network weights. Ask your teacher for more information.
  • This network has a weight of 4+5+7+3+6+6+11+5+16+21=84.

  • The subnetwork in the middle (highlighted in orange) has weight 4+5+7+3+6=25.

  • The red walk on the right has weight 3+5+16+11=35.

Examples

Example 1

Consider the following network:

This image shows a weighted and undirected network with vertices P, Q, R, S, T, U. Ask your teacher for more information.
a

What is the weight of the edge connecting Q and S?

Worked Solution
Create a strategy

Use the weight of the edge from vertex Q that points to vertex S.

Apply the idea

The number 9 is written beside the edge that from Q pointing to S.

So the weight is 9.

b

What is the weight of the entire network?

Worked Solution
Create a strategy

Add all the weights in the network.

Apply the idea
\displaystyle \text{Network weight}\displaystyle =\displaystyle 6+7+2+9+4+5Add the weights
\displaystyle =\displaystyle 33Evaluate
Idea summary

The number added to each edge is called a weight.

If a network has weights on its edges, we can give a weight to the whole network by adding up all the weights. This applies to subnetworks too. Similarly, we can give a weight to any walk by adding up all the weights on the edges chosen in the walk (the weight of a walk is sometimes called its length).

Shortest path problems

A common problem posed in networks is to find the path of lowest weight between two vertices. For example, finding the best (fastest, shortest, cheapest) route between two destinations.

This image shows a weighted and undirected network with vertices A, B, C, D, E. Ask your teacher for more information.

Let’s take a look at this network of towns.

The weights represent travel time in minutes, and we want to get from A to B via the optimal (fastest) path. Here are three paths we could take:

A weighted undirected network with 3 paths, in red, blue, and green, from A to B. Ask your teacher for more information.
  • The red path AB will take 9 minutes.

  • The blue path ACEB will take 2+3+4=9 minutes.

  • The green path ADB will take 4+4=8 minutes.

This last path is close to the answer, but we can get from A to D even faster if we take a shortcut through C.

A weighted undirected network with an orange path A C D B. Ask your teacher for more information.

This path does not look like the fastest but it takes 2+1+4=7 minutes, and is the quickest way to get from A to B.

The same strategy can be applied to directed networks.

A weighted directed graph with vertices Ato G. Ask your teacher for more information.

Here is a directed graph. This time, the streets are all one-way.

A weighted directed graph with with 3 paths, in purple, blue, and green, from A to G. Ask your teacher for more information.

Let’s try a few paths out:

  • The blue path AFG takes 10+11=21 minutes.

  • The green path ADG takes 4+12=16 minutes.

  • The purple path ABCEG takes6+1+5+5=17 minutes.

This image shows a network with green path  A D E G. Ask your teacher for more information.

We can now check more paths, thinking about taking detours on paths we already know about. Starting from the path ADG, the best one we have found so far, we can improve the trip from D to G by going through E.

Going along the path ADEG only takes \\ 4+6+5=15 minutes, and this is the fastest route.

Using trial and error is an appropriate method when solving shortest path problems. However, we need to be systematic to ensure all paths are checked.

Examples

Example 2

A rock band is planning a tour across several cities. The following table represents the routes and distance between the cities at which they will be performing.

Starting CityEnding CityDistance
AC9
AF6
BE11
BF5
CD3
CF7
ED5
EF8
a

Which of the following graphs does the table represent?

A
Undirected network with edges D C, D E, C A, C F, A F, F E, F B, and E B and weights 3, 5, 6, 7, 9, 8, 11, 5, respectively.
B
Undirected network with edges D C, D E, C A, C F, A F, F E, F B, and E B, and weights 7, 8, 9, 3, 6, 5, 5, 11, respectively.
C
Undirected network with edges D C, D E, C A, C F, A F, F E, F B, and E B, and weights 3, 5, 9, 7, 6, 8, 5, 11, respectively.
D
Undirected network with edges D C, D E, C A, C F, A F, F E, F B, and E B, and weights 3, 8, 9, 7, 6, 5, 5, 11, respectively.
Worked Solution
Create a strategy

Compare the routes and distances in the table with each of the graphs.

Apply the idea

Looking at the table, starting at A and ending at C, there is a distance of 9. So the edge AC must have a weight of 9. That means that option A cannot be the answer.

In the last row of the table, starting at E and ending at F, there is a distance of 8. The only remaining graph that has the edge EF with weight 8, is option C.

So the correct answer is option C.

b

Using either the correct graph or table given, find the shortest route for the rock band to cross starting at city A and passing by each city only once.

Worked Solution
Create a strategy

At each vertex, choose the edge that has the lowest weight until all vertices have been visited.

Apply the idea
Undirected network with edges D C, D E, C A, C F, A F, F E, F B, and E B, and weights 3, 5, 9, 7, 6, 8, 5, 11, respectively.

From A we move to F since 6 \lt 9.

From F we move to B since 5\lt 7 \lt 8.

From B we move to E since it is the only remaining option.

From E we move to D since it is the only remaining option.

From D we move to C since it is the only remaining option.

So the shortest route for the rock band to cross starting at city A and passing by each city only once is: \text{Shortest route} = A,\,F,\,B,\,E,\,D,\,C

Reflect and check

There are other routes with the same total weight. The weight of the above route is 6+5+11+5+3=30.

Another route that has the same total weight, and so would also be the shortest route is: A,\,C,\,D,\,E,\,F,\,B

Idea summary

To solve shortest path problems, at each vertex, we should choose the edge with the smallest weight avoiding paths that contain extended detours from the shortest path.

Outcomes

U2.AoS2.2

weighted graphs and networks, and the shortest path problem

U2.AoS2.6

find the shortest path in a weighted graph (solution by inspection only)

U2.AoS2.8

construct graphs, digraphs and networks and their matrix equivalents to model and analyse practical situations

What is Mathspace

About Mathspace