25
C H A P T E R 23 MODULE 5 Undirected graphs How do we represent a graph by a diagram and by a matrix representation? How do we define each of the following: graph subgraph vertex edge (node) loop isolated vertex bipartite graph degenerate graph connected graph circuit tree spanning tree complete graph simple graph Euler path Euler circuit Hamilton path Hamilton circuit adjacency matrix planar graph degree of a vertex How do we apply Euler’s formula to planar graphs? How do we determine the shortest path between two given vertices on a graph? How do we find the minimum spanning tree of a graph? How do we apply Prim’s algorithm to find the minimum spanning trees of a connected graph? How do we apply the Hungarian algorithm? 23.1 Introduction and definitions A hockey team belongs to a competition in which there are six teams: A, B, C, D, E and F. A few weeks into the season, some of the teams have played each other: A has played B, F and E B has played C, F and A C has played B, D and E D has played C and F E has played A and C F has played A, B and D A E D C B F Figure 23.1 614 SAMPLE Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

Embed Size (px)

Citation preview

Page 1: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

C H A P T E R

23MODULE 5

Undirected graphs

How do we represent a graph by a diagram and by a matrix representation?

How do we define each of the following:

� graph

� subgraph

� vertex

� edge (node)

� loop

� isolated vertex

� bipartite graph

� degenerate graph

� connected graph

� circuit

� tree

� spanning tree

� complete graph

� simple graph

� Euler path

� Euler circuit

� Hamilton path

� Hamilton circuit

� adjacency matrix

� planar graph

� degree of a vertex

How do we apply Euler’s formula to planar graphs?

How do we determine the shortest path between two given vertices on a graph?

How do we find the minimum spanning tree of a graph?

How do we apply Prim’s algorithm to find the minimum spanning trees of a

connected graph?

How do we apply the Hungarian algorithm?

23.1 Introduction and definitionsA hockey team belongs to a competition in which there are six teams: A, B, C, D, E and F.

A few weeks into the season, some of the teams have played each other:

A has played B, F and E

B has played C, F and A

C has played B, D and E

D has played C and F

E has played A and C

F has played A, B and D

A

E

D

C

B

F

Figure 23.1

614

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 2: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 615

This situation can be represented graphically. The teams can be represented by points and two

such points are joined by a line whenever the teams they represent have played each other. A

figure such as Figure 23.1 is called a graph.

The points A, B, C, D, E and F are called the vertices or nodes of the graph and the lines

connecting the vertices are called edges.

A graph consists of a set of elements called vertices and a set of elements called edges.

Each edge joins two vertices.

The vertices A and B of a graph are adjacent vertices if they are joined by an edge.

The graph can be represented by a table or a matrix. A ‘1’ is used to denote that there is

one edge connecting the two vertices and a ‘0’ indicates that there is no edge. The matrix

shown below is called an adjacency matrix.

A B C D E F

A 0 1 0 0 1 1

B 1 0 1 0 0 1

C 0 1 0 1 1 0

D 0 0 1 0 0 1

E 1 0 1 0 0 0

F 1 1 0 1 0 0

A B C D E F

A

B

C

D

E

F

0 1 0 0 1 1

1 0 1 0 0 1

0 1 0 1 1 0

0 0 1 0 0 1

1 0 1 0 0 0

1 1 0 1 0 0

Table for figure 23.1 Matrix for figure 23.1

The adjacency matrix A of the graph is an n × n matrix in which for example the entry in

row C and column F is the number of edges joining vertices C and F.

Another graph, Figure 23.2, is shown opposite. Note that

three edges leave from A. The graph is said to have

multiple edges as there are two edges joining A and D.

C has one edge, which links C to itself. This edge is called

a loop. The table and matrix appear as shown below.

Note:A loop is recorded as one edge in an adjacency matrix

A

D

B

C

Figure 23.2

A B C D

A 0 1 0 2

B 1 0 0 1

C 0 0 1 0

D 2 1 0 0

A B C D

A

B

C

D

0 1 0 2

1 0 0 1

0 0 1 0

2 1 0 0

SAM

PLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 3: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

616 Essential Further Mathematics – Module 5 Networks and decision mathematics

Example 1 Representing a graph by a table or matrix

Construct the table and matrix corresponding to the graph

shown, which represents three houses, A, B and C,

connected to three utility outlets, gas (G), water (W)

and electricity (E).

A B C

G W E

Figure 23.3

Solution

A B C G W E

A 0 0 0 1 1 1

B 0 0 0 1 1 1

C 0 0 0 1 1 1

G 1 1 1 0 0 0

W 1 1 1 0 0 0

E 1 1 1 0 0 0

A B C G W E

A

B

C

G

W

E

0 0 0 1 1 1

0 0 0 1 1 1

0 0 0 1 1 1

1 1 1 0 0 0

1 1 1 0 0 0

1 1 1 0 0 0

Figure 23.3 is called a bipartite graph as the set of vertices is partitioned into two disjoint sets

(A, B, C) and (gas, water, electricity) and each edge has a vertex in each set.

A bipartite graph is a graph whose set of vertices can be split into two subsets X and Y in

such a way that each edge of the graph joins a vertex in X and a vertex in Y.

At each non-isolated vertex, A, in a graph there will be some edges joined to A (incident with

vertex A).

The degree of vertex A, written as deg(A) is the number of edges incident with it.

For Figure 23.4:

deg A = 3

deg B = 2

deg C = 2

deg D = 5

A

B

C

A

D

B

C

Figure 23.4

Note:Loops add two to the degree of avertex.

A simple graph is a graph with no loops or multiple edges.

Figure 23.5 is a simple graph. For a simple graph,

the sum of the degrees of the graph is equal to

twice the number of edges of the graph.

∴ the sum of the degrees of a simple graph is even. A

B

C

D

E

Figure 23.5

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 4: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 617

For Figure 23.5:

Sum = deg(A) + deg(B) + deg(C) + deg(D) + deg(E)

= 3 + 2 + 2 + 3 + 2 = 12

For a simple graph, the entries for the corresponding table are

either 1s or 0s.A B C D E

A 0 1 0 1 1

B 1 0 1 0 0

C 0 1 0 1 0

D 1 0 1 0 1

E 1 0 0 1 0

Note that the sum of the 1s = 12 = 2 × the number of edges.

If E is an isolated vertex (i.e. there are no edges

incident to E) then deg(E) = 0. See Figure 23.6.A

B

C

DE

Figure 23.6

A graph is said to be degenerate if all its vertices

are isolated. See Figure 23.7.A

B

C

Figure 23.7

Many applications of graphs involve ‘getting from one vertex to another’. In order to discuss

this, the idea of a path is introduced.

A path in the graph in Figure 23.8 from A to F could be

AB, BG, GE, EC, CD, DE, EG, GF (shown in red). Not all

the edges or vertices in a path are required to be different.

A

B

G

FE

D

C

Figure 23.8

A path can be thought of as a sequence of edges.

A graph is said to be connected if there is a path between each pair of vertices.

The graph in Figure 23.9 is connected. The graph in Figure 23.6 is not connected.

A circuit is a sequence of edges linking successive vertices

that starts and finishes at the same vertex.

In Figure 23.9, one circuit is A B C D F A. Another

circuit is E F D E.

A

B C

D

EF

Figure 23.9

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 5: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

618 Essential Further Mathematics – Module 5 Networks and decision mathematics

A subgraph of a graph consists of selected edges and vertices of the graph with the same

links as the original graph and with the selected vertices including all the endpoints of the

selected edges.

Figures 23.10a and 23.10b show two subgraphs of Figure 23.9.

A

B C

D

EF

Figure 23.10a

A

B C

D

EF

Figure 23.10b

A

B C

D

EF

Figure 23.10c

The graph shown in red in Figure 23.10c is not a subgraph as it has an edge that does not exist

in the original graph.

Exercise 23A

1 This section of a road map can be considered

as a graph, with towns as vertices and the

roads connecting the towns as edges.Town A

Town B

Town C

Town H

Town Da Give the degree of:

i Town A ii Town B iii Town H

b Construct the table (matrix) for this graph.

c Is this graph simple? Why?

2 For each of the following graphs give the associated table (matrix).

a

A

C

B D b A B

DC

c A B

C D

d

A

e A B

D C

f AB

C D

E F

gA

B

D

C

h

A

BC

D

3 Which of the graphs in Question 2 are:

a simple? b connected?SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 6: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 619

4 For each of the following, draw the graph for the given table (matrix).

a A B C D

A 0 1 1 0

B 1 0 1 1

C 1 1 0 0

D 0 1 0 0

b A B C

A 0 0 0

B 0 0 0

C 0 0 0

c A B C D

A 0 1 0 1

B 1 0 1 0

C 0 1 0 1

D 1 0 1 0

d

1 0 0 0

0 0 1 1

0 1 1 0

0 1 0 0

e 0 1 1

1 0 1

1 1 0

f

0 1 2 1

1 0 1 1

2 1 0 0

1 1 0 0

5 a Draw three connected subgraphs, with four

vertices, of the graph shown. (Note that there are

many such subgraphs.)A

B C

D

EF

b What is the degree of vertex A?

c Give the sum of the degrees of the vertices of the

graph.

d Give a circuit from A passing through 4 vertices (including A).

23.2 Planar graphs and Euler’s formulaLeonard Euler (pronounced ‘oiler’) was one of the most prolific mathematicians of all time.

He contributed to mathematics in an amazing array of topics. His proof of the formula named

after him is considered to be the beginning of the branch of mathematics called topology. The

application of Euler’s formula is developed in this section.

Electrical circuits can be represented by a graph, as in

Figure 23.11.

A

B C

D

EF

Figure 23.11

For certain electrical circuits it is advantageous to not have connections AD and CE crossing.

Figure 23.11 can be redrawn as shown in Figure 23.12 so

that these edges do not cross.

A

B C

D

F E

Figure 23.12

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 7: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

620 Essential Further Mathematics – Module 5 Networks and decision mathematics

A graph that can be drawn in such a way that no two edges meet (or have common points),

except at the vertices where they are both incident, is called a planar graph.

Not all graphs are planar. Figure 23.13 cannot be redrawn

so that the edges have no intersection points except at the

vertices. It is true that all simple graphs with four or fewer

vertices are planar.

Figure 23.13

Consider a connected planar graph ABCDEF shown in

Figure 23.14. This graph has 6 vertices and 8 edges.

Connected planar graphs also have faces or regions.

Figure 23.14 has four faces: f1, f2, f3 and f4, where

f4 is an infinite face.A F

E

DCB

f4 f1 f2f3

Figure 23.14There is a relationship between the number of vertices,

edges and faces in a connected planar graph.

Let v denote the number of vertices.

Let e denote the number of edges.

Let f denote the number of faces.

Note that in Figure 23.14:

v − e + f = 6 − 8 + 4 = 2

This result holds for any connected planar graph and is known as Euler’s formula.

Euler’s formula states:

v − e + f = 2

Example 2 Verifying Euler’s formula

Verify Euler’s formula for the graph shown.

A D

B CE

f1f3

f4

f2Solution

1 The vertices are A, B, C, D, E. There are 5 vertices so v = 5. v = 5

2 There are 4 faces as shown on the diagram.

Don’t forget the infinite face f1: So f = 4.f = 4

3 The edges are AB, BC, CD, DA, DB, AE and CA.

There are 7 of them, so e = 7.

e = 7

v − e + f = 5 − 7 + 4 = 2

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 8: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 621

Example 3 Verifying Euler’s formula

A tetrahedron may be represented graphically by a connected planar graph.

Verify Euler’s formula for the graph shown.

Solution

v = 4, f = 4, e = 6

v − e + f = 4 − 6 + 4 = 2

Example 4 Using Euler’s formula

A connected planar graph has 6 vertices and 8 edges. How many faces does the graph have?

Draw a connected planar graph with 6 vertices and 8 edges.

Solution

Euler's formula: v − e + f = 2

v = 6 and e = 9

6 − 9 + f = 2

−3 + f = 2

f = 5

A

f1

f2

f3

f4f5

B

C

D

E

F

Exercise 23B

1 For each of the following graphs:

i state the values of v, e and f ii verify Euler’s formula.

a b c d

2 Show that the following graphs are planar by redrawing them in a suitable form:

a A B C

F E D

b

A D

F E

B C c A B

DC E

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 9: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

622 Essential Further Mathematics – Module 5 Networks and decision mathematics

3 For a planar connected graph, find:

a f, if v = 8 and e = 10 b v, if e = 14 and f = 4

c f, if v = 5 and e = 14 d e, if v = 10 and f = 11

4 a Represent this cube as a planar graph.

b Verify Euler’s formula for this graph.

23.3 Complete graphsA complete graph is a graph with edges connecting all pairs of vertices. The complete

graph with n vertices is denoted by Kn .

K3 K4 K5

Note: K3 and K4 are planar while K5 is not.

The complete graph with n vertices, Kn , hasn(n − 1)

2edges.

For example:

K4 has4(4 − 1)

2= 6 edges

K5 has5(5 − 1)

2= 10 edges

A

B

D

C

E

A B C D E

A

B

C

D

E

0 1 1 1 1

1 0 1 1 1

1 1 0 1 1

1 1 1 0 1

1 1 1 1 0

A complete graph could be used to represent a

round robin competition (a competition in

which each side plays every other side once).

For example, for five teams, A, B, C, D and E

are shown. Each edge represents a match that

has been played. The adjacency matrix has

1’s in all positions except the main diagonal.

This graph could be drawn for six people

at a party. Each edge indicates that a

conversation took place. The adjacency

matrix has 1s in all positions except the

main diagonal.

B C

A D

EF

0 1 1 1 1 1

1 0 1 1 1 1

1 1 0 1 1 1

1 1 1 0 1 1

1 1 1 1 0 1

1 1 1 1 1 0

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 10: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 623

Exercise 23C

1 A competition consists of six teams. In the competition each team plays every other team.

a How many matches are there?

b Represent the competition with the complete graph K6.

c Represent the competition with an adjacency matrix.

2 a How many edges does K7 have? b Draw K7.

3 How many handshakes could take place among 8 people. Represent this with a graph.

23.4 Euler and Hamilton pathsEuler pathsIn a paper published in 1736, Leonard Euler solved the problem that had intrigued the citizens

of Konigsberg, which lay near the mouth of the Pregel River. The river divided the city into

four parts, as shown in Figure 23.15. There were seven bridges.

A

C

B D Pregel River

Figure 23.15

The problem was posed as follows:

‘Could we walk over each of the seven bridges once only and return to our starting point?’

Euler represented this situation as shown in Figure 23.16. A

B

D

CFigure 23.16

Euler showed that this graph cannot be traversed

completely in a single cyclical trail. That is, no matter

which vertex is chosen as the starting point it is

impossible to cover the graph and come back to the

chosen starting vertex while using each

edge only once.

We recall that for a graph, a path is a sequence of edges.

In Figure 23.17, one path from A to D is e1, e3, e4 (red).

Another path from A to D is e5 (green).A

e1

e2e4

e5

e3B

D

C

Figure 23.17

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 11: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

624 Essential Further Mathematics – Module 5 Networks and decision mathematics

Recalling the definition of circuit in section 23.1: a

circuit is a path that begins and finishes at a particular

vertex. In Figure 23.18, one circuit is e1, e2, e3, e4,

e5, e6 (red). This circuit begins and finishes at A.

A

e1e2

e4e5e6

e3

B

D

F E

C

Figure 23.18

A path that includes every edge just once is called an Euler path.

An Euler circuit is an Euler path that starts and finishes at the same vertex.

Identifying Euler paths and circuitsA useful way of identifying Euler circuits is to look for a connected graph where all

vertices have an even degree.

The converse result also holds: if a graph has an Euler circuit, then it is connected and each

vertex has an even degree. Using this result, it can be seen that the graph for the Konigsberg

bridge problem does not contain an Euler circuit as vertex B has an odd degree.

A connected graph has an Euler path starting at vertex A and finishing at vertex B if A

and B are the only odd vertices of the graph.

Example 5 Identifying an Euler circuit

a Explain why the graph shown opposite has an Euler circuit.

b List an Euler circuit for this graph.

D

C E

B ASolution

a The graph has only even vertices.

b An Euler circuit is C → D → E → C → A → B → C .

Example 6 Identifying an Euler path

a Explain why the graph opposite has an Euler path

between B and C.

b List one possible Euler path (there are several)

between B and C.

A

B

CD

E

Solution

a B and C are odd vertices. The remaining vertices are even.

b B → A → E → D → B → C → D → C .

Hamilton paths

A Hamilton path is a path through a graph that passes through each vertex exactly once.

A Hamilton circuit is a Hamilton path which starts and finishes at the same vertex.

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 12: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 625

It is easy to remember the difference between Hamilton paths (circuits) and Euler paths

(circuits). Hamilton graphs are defined in terms of vertices and Euler graphs are defined

in terms of edges.

Unfortunately, unlike the condition for an Euler circuit, there is no nice condition to identify

when a graph is a Hamilton circuit. It is just a matter of trial and error.

Example 7 Identifying a Hamilton circuit

List a Hamilton circuit for the graph shown.

C

D

H G F

AB

E

Solution

A Hamilton circuit is C → B → A → E → F → G → H → D → C .

Not every graph that has a Hamilton circuit has an Euler circuit,

and also not every graph that has an Euler circuit has a

Hamilton circuit. The graph in Example 7 has a Hamilton

circuit but not an Euler circuit. The graph in Figure 23.19 has an

Euler circuit but not a Hamilton circuit.

F A

C

E B

Figure 23.19

Exercise 23D

1 a Which of the following graphs has:

i an Euler circuit? ii an Euler path but not an Euler circuit?

b Name the Euler circuits or paths found.

a A

E D

B

C

b B

A

F

EH

G

C

D

cC

A

B

D

EF

d

EA

BC

De AE

B

F

D C

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 13: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

626 Essential Further Mathematics – Module 5 Networks and decision mathematics

2 List a Hamilton circuit for each of the following.

a A B C

F

IHG

DE

b

A

B C

D

EF

c

DA

C

E

B

d

D

A

C

G

F

E

B

e B

A E F C

D

3 List a Hamilton path for this graph starting at

F and finishing at G.

A

D

E

FG

H

B

C

23.5 Weighted graphsA weighted graph is one where a number is associated with each edge. These numbers are

called weights.

Examples of weighted graphs arise when the vertices of a graph are towns on a map and the

edges are the roads between the towns. The number assigned to each edge is the distance

between the towns represented by the vertices of that edge. Figure 23.20 is a weighted graph

representing towns and the roads connecting them.

12

20

7

Snugvill

CudstopHeavytown

ClearviewMelville

Appleville

9

8

6 13

5 11

Figure 23.20

The numbers in a weighted graph may also represent times, fuel consumption, cost, and so

on. The number attached to an edge is called the weight of that edge.

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 14: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 627

TreesA tree is a connected graph that contains no circuits.

Figure 23.21 is a tree. A tree has no multiple edges.

The simplest tree is a single vertex. A tree with n

vertices has n − 1 edges. A

B FG

E

DC

Figure 23.21

Minimum spanning treesA cable is needed to connect the communication systems

of the four towns in figure 23.22. It is convenient to lay the

cable alongside existing roads but it is not necessary to lay

the cable next to all roads.

B

C

A

D

6

4

6

5

5

3

Figure 23.22

A subgraph connecting all four towns can be chosen. It is

sensible for such a subgraph to be a tree (in red in figure 23.22)

shown in figure 23.23.B

A

D

C

5

43

Figure 23.23

A spanning tree is a subgraph that contains all the vertices of the original graph and is a tree.

A minimum spanning tree for a weighted graph is a spanning tree for which the sum of the

weights of the edges is as small as possible.

Figure 23.23 is a minimum spanning tree for figure 23.22.

Prim’s algorithmPrim’s algorithm is a set of rules to determine a minimum spanning tree for a graph.

Examples of where Prim’s algorithm applies include such problems as the following

‘For a certain number of cities, a railroad network is to be developed and the

cost of connecting any two given cities is known. Find how all the cities

should be connected by rail to minimise total cost.’

Similar problems involve utility connections, e.g. water, gas, electricity.

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 15: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

628 Essential Further Mathematics – Module 5 Networks and decision mathematics

Prim’s algorithm:1 Choose a vertex and connect it to a second vertex chosen so that the weight of the edge

is as small as possible.

2 In each step thereafter, take the edge with the lowest weight, producing a tree with the

edges already selected. (If two edges have the same weight the choice can be arbitrary.)

3 Repeat until all the vertices are connected and then stop.

Example 8 Applying Prim’s algorithm

Apply Prim’s algorithm to obtain a minimum spanning

tree for the graph shown. Write down its weight, and

compare it to the weight of the original graph. A

B

C

D

E

F

6

52 6 3

6

2

7

5

8

Solution

Step 1

2

A

BStep 2

25

A

B

D

Step 3

2

5

3

A

BC

D

Step 4

2

5

3 5A

B

D

C

E

Step 5

2

2

5

5

3

A

B

C

D

F

E

The total weight is 17. The total weight of the original graph is 50.

Exercise 23E

1 Find a minimum spanning tree for each of the following graphs and give the total weight.

a 2

6

2

2 2

1

3

5

3

AB E

F

DC

b

16

24

16

17

10

17

1511

17

12

16

FG

A

BC

DESAM

PLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 16: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Chapter 23 – Undirected graphs 629

c

18

10

18

1920

10

18

9

A

B

E

C

D

d

90

70100 140

10080

90120

90200

H

D

G

F

A

EC

B

2 By trial and error find the shortest path from A to E.64

35

38

7B

C

AE

D

F

3 Find the shortest Hamilton path for the following graph,

starting at A.6

4

6

4

3 55

2

4

5 3

3

B C

A

E

D

F

G

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 17: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Rev

iew

630 Essential Further Mathematics – Module 5 Networks and decision mathematics

Key ideas and chapter summary

Graph A graph consists of a set of elements

called vertices and a set of elements called

edges. Each edge joins two vertices

A figure such as the one drawn opposite is called

a graph.

A

E

B

F

C

D

Vertices (nodes) The points A, B, C, D, E and F are called the vertices or nodes of the

graph and the lines connecting the vertices are called edges of the graph.and edges

Adjacent vertices The vertices A and B of a graph are adjacent vertices if they are joined

by an edge

Adjacency matrix The adjacency matrix A of the graph

is an n × n matrix in which for example

the entry in row C and column F is the

number of edges joining vertices C

and F. For the graph above the

adjacency matrix is as shown.

A B C D E F

A

B

C

D

E

F

0 1 0 0 1 1

1 0 1 0 0 1

0 1 0 1 1 0

0 0 1 0 0 1

1 0 1 0 0 0

1 1 0 1 0 0

Multiple edges The graph is said to have multiple edges as there

are two edges joining A and D. C has one

edge, which links C to itself. This edge

is called a loop.

and loopsA

DB

C

Bipartite graph A bipartite graph is a graph whose set of vertices can be split into two

subsets X and Y in such a way that each edge of the graph joins a vertex

in X and a vertex in Y.

Degree of a vertex At each non-isolated vertex, A, in a graph there will be some edges

joined to A (adjacent with vertex A). The degree of vertex A, written as

deg(A) is the number of edges incident with it. Loops are counted twice.

Simple graph A simple graph is a graph with no loops or multiple edges.

Degenerate graph A graph is said to be degenerate if all its vertices are isolated.

Path A path can be thought of as a sequence

of edges of the form AB, BG, GE, EC, CD,

DE, EG, GFA

B

G

FE

D

C

Connected graph A graph is said to be connected if there is a path between each pair of

vertices.

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 18: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Review

Chapter 23 – Undirected graphs 631

Circuit A circuit is a sequence of edges linking successive

vertices that starts and finishes at the same vertex. A

B

C

D

E

Subgraph A subgraph of a graph consists of selected edges and vertices of the

graph with the same links as the original graph and with the selected

vertices including all the endpoints of the selected edges.

Planar graph A graph that can be drawn in such a way that no two edges meet (or

have common points), except at the vertices where they are both

incident, is called a planar graph.

Euler’s formula Euler’s formula states that for any connected planar graph,

v − e + f = 2, where v = the number of vertices,

e = the number of edges, and f = the number of faces.

Complete graph A complete graph is a graph with edges connecting all pairs of vertices.

Euler path A path that includes every edge just once is called an Euler path.

Euler circuit An Euler circuit is an Euler path that starts and finishes at the same

vertex.

Hamilton path A Hamilton path is a path through a graph that passes through each

vertex exactly once.

Hamilton circuit A Hamilton circuit is a Hamilton path that starts and finishes at the

same vertex.

Weighted graphs A weighted graph is a graph where a number is associated with each

edge. These numbers are called weights.

Tree A tree is a connected graph that contains

no circuits.

A tree has no multiple edges. The simplest tree

is a single vertex. A tree with n vertices has

n − 1 edges.

Spanning tree A spanning tree is a subgraph that contains all the vertices of the

original graph and is a tree.

Minimum spanning A minimum spanning tree for a weighted graph is a spanning tree for

tree which the sum of the weights of the edges is as small as possible.

Prim’s algorithm Prim’s algorithm is a set of rules to determine a minimum spanning

tree for a graph.

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 19: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Rev

iew

632 Essential Further Mathematics – Module 5 Networks and decision mathematics

Skills check

Having completed this chapter you should be able to:

construct an adjacency matrix from a graph and draw the graph from an adjacency

matrix

determine whether a graph is simple, connected, planar or complete

determine whether a graph has an Euler circuit or path

by trial and error, determine whether a graph has a Hamilton path or circuit

find a minimum spanning tree of a graph

Multiple-choice questions

1 The minimum number of edges for a graph with seven vertices to be connected is:

A 4 B 5 C 6 D 7 E 21

2 Which of the following graphs is a spanning tree for the

network shown?

1

4

2

3

5

6

7A 1

4

2

3

5

6

7

B 1

4

2

3

5

6

7

C 1

4

2

3

5

6

7

D 1

4

2

3

5

6

7

E 1

4

2

3

5

6

7

3 For the graph shown, which vertex has degree 5?

A Q B T C S D R E U

Q

P

R T

S

U

4 A connected graph on 15 vertices divides the plane into 12 regions. The number of

edges connecting the vertices in this graph will be:

A 15 B 23 C 24 D 25 E 27

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 20: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Review

Chapter 23 – Undirected graphs 633

5 Which of the following graphs does not have an Euler circuit?

A B C

D E

6 A connected planar graph divides the plane into a number of regions. If the graph

has eight vertices and these are linked by 13 edges, then the number of regions is:

A 5 B 6 C 7 D 8 E 10

7 For the graph shown, which of the following paths is a Hamilton

circuit?

A ABCDCFDEFAEA B AEFDCBA C AFCDEABA

D ABCDEA E AEDCBAF

A

E

D

C

FB

8 For which one of the following graphs is the sum of the degrees of the vertices

equal to 12?

A B C

D E

9 The sum of the degrees of the vertices on the graph shown

here is:

A 20 B 21 C 22 D 23 E 24

10 For the graph shown, which additional arc could be added

to the network so that the graph formed would contain an

Euler path?

A AF B DE C AB D CF E BF

A

B

E

D

F

C

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 21: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Rev

iew

634 Essential Further Mathematics – Module 5 Networks and decision mathematics

11 For the graph shown here, the minimum length spanning

tree has length:

A 30 B 31 C 33 D 34 E 26

78

10

9

2

4

54

6

12 Of the following graphs, which one has both Euler and

Hamilton circuits?

A B C

D E

13 Which one of the following graphs has an Euler circuit?

A B C

D E

14 Which one of the following is a spanning tree for

the graph shown here?

1

2

3

45

A

1

2

3

45

B

1

2

3

45

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 22: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Review

Chapter 23 – Undirected graphs 635

C

1

54

3

2 D

1

2

54

E

1

2

3

5

15 Which one of the following graphs has an Euler circuit?

A BC

D E

16 Which one of the following graphs provides a counter-example to the statement:

‘For a graph with seven vertices, if the degree of each vertex is greater than 2 then

the graph contains a Hamilton circuit’?

A B C

D E

17 For which one of the following graphs is the sum of the degrees of the vertices equal

to 20?

A B C

D ESAM

PLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 23: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Rev

iew

636 Essential Further Mathematics – Module 5 Networks and decision mathematics

18 Which one of the following paths is a Hamilton

circuit for the graph shown here?

A PQRSTP B PQRSTUVP

C PQUVRSTP D PQRSTUVUTP

E PQRSTUVRVQUTP

TT

UUVV

SS

RR

QQ

PP

19 Four towns, A, B, C and D are linked by roads as shown.

Which of the following graphs could be used to

represent the network of roads? Each edge

represents a route between two towns

B

A

C

D

A B

C

D

A

B B

C

D

A

C BC

DA

D B

C

D

A

E

D

BC

A

Extended-response questions

1 This question is about the vertices of a graph and the degree of a vertex. In Graph A

below, there are four vertices (the dots).

1 2

43

Graph A Graph B Graph C

a Complete the table for Graph B. Degree 0 1 2 3 4 5 6 7

Number of verticesb Study Graphs A, B and C and then

consider the statement:

‘In any graph the total number of vertices of odd degree is an even number.’

Is this statement true for Graphs A, B and C? How many vertices of odd degree

does each graph have?

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 24: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Review

Chapter 23 – Undirected graphs 637

c To Graph B an extra edge is added joining two vertices of even degree. Does the

above statement still hold true for this graph? Explain the reasons for your answer.

d From Graph C an edge joining an odd degree vertex to an even degree vertex is

removed. Does the above statement still hold true for this graph? Explain the

reasons for your answer.

2 Consider the graph shown here.

a Explain why this is a planar graph.

b For this graph, write down:

i the number of vertices

ii the number of edges

iii the number of facesNote: the region outside the graph is counted as a face.

c Draw a spanning tree for this graph.

d For the spanning tree drawn in c, write down

i the number of vertices

ii the number of edges

iii the number of faces

3 Let H denote a planar graph with n vertices.

a If T denotes a spanning tree of H, specify:

i the number of vertices in T

ii the number of edges in T

iii the number of faces in T

b Hence verify that, for the graph T:

number of vertices − number of edges + number of faces = 2.

4 The map shows six campsites, A, B, C, D, E

and F which are joined by paths. The numbers

by the paths show lengths in kilometres of

sections of the paths.

lakeA

6B

9

C

5

E2

3

1

34

4

F

5

5 D

a i Complete the graph opposite which shows

the shortest direct distances between

campsites. (The campsites are represented

by vertices and paths are represented by

edges.)

A

B

CD

E

F

6

8

5 75

4

4

9

8ii A telephone cable is to be laid to enable each

campsite to phone each other campsite. For

environmental reasons, it is necessary to lay the cable along the existing paths.

What is the minimum length of cable necessary to complete this task?

(cont’d.)

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin

Page 25: CHAPTER 23 · P1: FXS/ABE P2: FXS 9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0 Chapter 23 – Undirected graphs 615 This situation can be represented graphically.Authors:

P1: FXS/ABE P2: FXS9780521740517c23.xml CUAU031-EVANS September 7, 2008 7:0

Rev

iew

638 Essential Further Mathematics – Module 5 Networks and decision mathematics

iii Fill in the missing entries for the

matrix shown for the completed

graph formed above.

A B C D E F

A

B

C

D

E

F

0 1 0 1 1 1

1 0 1 0 0 0

0 1 0 1 1 0

1 0 − − − −1 0 − − − −1 0 − − − −

b A walker follows the route A−B−A−F−E−D−C−E−F−A.

i How far does this person walk?

ii Why is the route not a Hamilton circuit?

iii Write down a route that a walker could follow which is a Hamilton circuit.

iv Find the distance walked in following this Hamilton circuit.

c It is impossible to start at A and return to A by going along each path exactly

once. An extra path joining two campsites can be constructed so that this is

possible. Which two campsites need to be joined by a path to make this possible?

SAMPLE

Cambridge University Press • Uncorrected Sample pages • 978-0-521-61328-6 • 2008 © Jones, Evans, Lipson TI-Nspire & Casio ClassPad material in collaboration with Brown and McMenamin