Edexcel IAL Maths

D1.2 Graphs, minimum spanning trees and Dijkstra

The full notes page in 11 sections · live simulations · practice questions

Press F for full screen · → or click to move on

ExaminerPrep is an independent tutoring service. It has been developed independently from and is not endorsed by the International Baccalaureate Organization. "International Baccalaureate", "IB" and "IB Diploma Programme" are registered trademarks of the IBO, used here for descriptive purposes only.
Pearson Edexcel and Cambridge are trademarks of their owners; ExaminerPrep is not affiliated with any exam board.

What this page covers
Overview

Graph vocabulary: vertex, edge, weight, degree, walk, trail, path, cycle, connected, subgraph, tree, spanning tree, simple graph, digraph

Complete graphs Kₙ, planar graphs and isomorphic graphs

Eulerian and semi-Eulerian graphs and the degree test

Adjacency matrices and distance (weight) matrices

Minimum spanning trees by Kruskal's algorithm

Prim's algorithm on a drawn network and on a distance matrix

Dijkstra's algorithm: labelling boxes, working values, and tracing back the route

In one minute
Key points

1. The degrees of all the vertices of a graph add up to twice the number of edges, so the number of odd vertices is always even; Kₙ has ½n(n − 1) edges.

2. A tree is connected with no cycles; a tree on n vertices has n − 1 edges. A minimum spanning tree (MST) is a spanning tree of least total weight.

3. Kruskal: list the arcs in increasing order of weight; add each one unless it would make a cycle; stop at n − 1 arcs.

4. Prim: start at any vertex; repeatedly add the cheapest arc joining a vertex in the tree to one outside it. On a matrix: cross out rows, look down the labelled columns.

5. Dijkstra: give the start 0; from the newest permanent vertex update working values; make the smallest working value permanent; repeat. Trace back using final(Y) − final(X) = weight of XY.

6. Eulerian: connected with every degree even. Semi-Eulerian: connected with exactly two odd vertices, and a trail through every edge starts at one and ends at the other.

What are graphs and networks, and what do the words mean?
Section 1 of 11

D1 graph questions reward exact vocabulary and visible working: why a graph is or is not simple, connected, a tree, planar or Eulerian; the order in which Kruskal or Prim adds arcs; and every Dijkstra working value with a trace-back.

A graph is a set of points (vertices or nodes) joined by lines (edges or arcs); a network is a graph whose edges carry numbers called weights.

WordMeaning
Degree (valency)the number of edge-ends at a vertex; a loop adds 2. A vertex is odd or even according to its degree
Walka sequence of edges, each starting where the last one ended
Traila walk in which no edge is used twice
Patha walk in which no vertex is visited twice (so no edge is repeated either)
What are graphs and networks, and what do the words mean? (continued)
Section 1 of 11
WordMeaning
Cyclea closed path: it ends where it started, with no other vertex repeated
Connectedthere is a path between every pair of vertices
Subgrapha graph made from some of the vertices and edges of another graph
Simple graphno loops and at most one edge between any pair of vertices
Treea connected graph with no cycles
Spanning treea subgraph that is a tree and includes every vertex of the original graph
Digrapha graph whose edges have directions (one-way arcs), shown with arrows
What are graphs and networks, and what do the words mean? (continued)
Section 1 of 11
PQRSTXZABCDEFY(a) simple, connected(b) loop + double edge(c) a tree
(a) Degrees 3, 2, 3, 2, 2 add to 12, twice its 6 edges. (b) A loop at Y (adding 2 to its degree) and a double edge X–Z stop a graph being simple. (c) A tree: connected, no cycles, one edge fewer than vertices.

Handshaking result: sum of all the degrees = 2 × (number of edges). Each edge has two ends and adds 1 to the degree of each (or 2 to one vertex if it is a loop). So the degree sum is even, and every graph has an even number of odd vertices (0, 2, 4, …).

What are graphs and networks, and what do the words mean? (continued)
Section 1 of 11 · Worked example 1 · Easy · Find, explain

WORKED EXAMPLE · QUESTION

(a) Find the number of edges in K₇ and the degree of each vertex. (b) A graph has six vertices with degrees 4, 4, 3, 3, 2 and 2. Find the number of edges. (c) Explain why no graph has degrees 5, 4, 3, 3, 2, 2. (d) Explain why no simple graph on 5 vertices can have a vertex of degree 5. (e) State the number of edges in a spanning tree of a connected graph with 9 vertices.

SOLUTION

(a) Each vertex joins the other 6, and every edge is counted from both ends: degree 6; edges = ½ × 7 × 6 = 21.

(b) 4 + 4 + 3 + 3 + 2 + 2 = 18 = 2 × edges, so 9 edges.

(c) 5 + 4 + 3 + 3 + 2 + 2 = 19 is odd, so it cannot equal twice a whole number of edges (equivalently, there would be three odd vertices).

What are graphs and networks, and what do the words mean? (continued)
Section 1 of 11 · Worked example 1 · Easy · Find, explain (continued)

(d) In a simple graph a vertex joins each other vertex at most once; there are only 4 others, so the maximum degree is 4.

(e) A tree on n vertices has n − 1 edges: 8 edges.

What are complete, planar and isomorphic graphs?
Section 2 of 11

A complete graph Kₙ has n vertices, each joined to every other by exactly one edge: each degree is n − 1 and there are ½n(n − 1) edges (K₄: 6, K₅: 10, K₆: 15).

A graph is planar if it can be drawn in a plane with no edges crossing. A drawing with crossings does not prove a graph is non-planar: try redrawing it. K₄ is planar; K₅ is not.

Two graphs are isomorphic if they are the same graph drawn differently: there is a one-to-one matching of vertices so that two vertices are joined in one graph exactly when the matching vertices are joined in the other.

What are complete, planar and isomorphic graphs? (continued)
Section 2 of 11
ABCDABCDPQRST(a) K4 with a crossing(b) K4 redrawn: planar(c) K5: not planar
The crossing in (a) is only a feature of that drawing: moving D inside triangle ABC gives (b), so K₄ is planar. K₅ has 10 edges and cannot be drawn without a crossing.

Testing for isomorphism. Quick checks can rule it out: same number of vertices, same number of edges, same list of degrees; if any differ, the graphs are not isomorphic. Equal degree lists do not prove it: look for a structural difference such as a triangle in one but not the other, or how the odd vertices are joined. To show two graphs are isomorphic, write down the matching and check every edge.

What are complete, planar and isomorphic graphs? (continued)
Section 2 of 11
123456PQRSTU123456(a) G: hexagon + 1–4(b) H: isomorphic to G(c) J: triangle 1–2–3
G and H are the same graph: the degree-3 vertices 1 and 4 match Q and T. J has the same degrees as G but contains the triangle 1–2–3, so it is not isomorphic to G.
What are complete, planar and isomorphic graphs? (continued)
Section 2 of 11 · Worked example 2 · Medium · Show that, explain

WORKED EXAMPLE · QUESTION

G has vertices 1–6 and edges 12, 23, 34, 45, 56, 61, 14. H has vertices P–U and edges PQ, QR, ST, TU, PS, QT, RU. J has vertices 1–6 and edges 12, 23, 34, 45, 56, 61, 13. (a) Show that G and H are isomorphic. (b) Explain why G and J are not isomorphic, even though they have the same degrees.

SOLUTION

(a) Both have 6 vertices, 7 edges and degrees 3, 3, 2, 2, 2, 2; the degree-3 vertices are 1, 4 in G and Q, T in H, and in both they are joined. Matching 1→Q, 2→P, 3→S, 4→T, 5→U, 6→R: 12→QP, 23→PS, 34→ST, 45→TU, 56→UR, 61→RQ, 14→QT, all edges of H, so G and H are isomorphic.

(b) J contains the triangle 1–2–3; G has no cycle of length 3 (its shortest cycles, 1–2–3–4 and 1–4–5–6, have length 4), so they are not isomorphic.

When is a graph Eulerian, and how are graphs stored as matrices?
Section 3 of 11

An Eulerian graph has a closed trail using every edge exactly once (drawn without lifting your pen, finishing where you started). A semi-Eulerian graph has such a trail that starts and finishes at different vertices. Each time a trail passes through a vertex it uses two edge-ends there, so only the start and finish can be odd.

Degree test: connected and all degrees even ⇔ Eulerian; connected and exactly two odd vertices ⇔ semi-Eulerian, and the trail must start at one odd vertex and end at the other. With 4, 6, … odd vertices the graph is neither: some edges would have to be repeated.

When is a graph Eulerian, and how are graphs stored as matrices? (continued)
Section 3 of 11
P 2Q 2R 4S 2T 2A 2B 4C 5D 3E 2(a) all even: Eulerian(b) C, D odd: semi-Eulerian
(a) All degrees even, so a closed trail exists, e.g. R P Q R S T R. (b) The graph of worked example 3 (double edge B–C): only C and D are odd, so it is semi-Eulerian.

An adjacency matrix has a row and column for each vertex; the entry in row X, column Y is the number of edges joining X to Y. For an undirected graph it is symmetric about the leading diagonal; a loop at X goes on the diagonal (usually as 2, as it adds 2 to the degree, or as 1 by some conventions: say which you use). With no loops, the row sum for X is the degree of X. A distance (weight) matrix holds the weight of each arc, with a dash for no direct arc; Prim's algorithm runs on it directly.

When is a graph Eulerian, and how are graphs stored as matrices? (continued)
Section 3 of 11

For a digraph, row X, column Y refers to the arc from X to Y, so the matrix need not be symmetric.

When is a graph Eulerian, and how are graphs stored as matrices? (continued)
Section 3 of 11 · Worked example 3 · Medium · Explain, determine

WORKED EXAMPLE · QUESTION

A graph has this adjacency matrix. (a) Explain how it shows that the graph is not simple. (b) Find the degree of each vertex and the number of edges. (c) Determine whether the graph is Eulerian, semi-Eulerian or neither, and write down a trail that uses every edge exactly once.

ABCDE
A01100
B10210
C12011
D01101
E00110
When is a graph Eulerian, and how are graphs stored as matrices? (continued)
Section 3 of 11 · Worked example 3 · Medium · Explain, determine (continued)

SOLUTION

(a) The entry 2 in row B, column C means two edges join B and C.

(b) Row sums: A 2, B 4, C 5, D 3, E 2; 16 ÷ 2 = 8 edges.

(c) The graph is connected and only C and D are odd, so it is semi-Eulerian, with a trail from C to D, e.g. C – B – C – A – B – D – E – C – D. Check: 8 edges, using each of the two B–C edges once.

What is a minimum spanning tree, and how does Kruskal's algorithm find one?
Section 4 of 11

A minimum spanning tree (minimum connector) is a spanning tree of a network whose total weight is as small as possible: for example the least total length of cable, pipe or road connecting every site. With n vertices it has n − 1 arcs; any further arc would create a cycle.

Kruskal's algorithm is greedy: at every step it takes the cheapest arc still available, as long as it does not form a cycle.

1. Sort the arcs into ascending order of weight.

2. Add the arc of least weight to the tree.

3. Take the next arc: add it if it does not form a cycle with the arcs already chosen, otherwise reject it.

4. Repeat step 3 until n − 1 arcs have been added.

The tree may be in separate pieces until the end. Arcs of equal weight may be taken in either order; say which you chose.

What is a minimum spanning tree, and how does Kruskal's algorithm find one? (continued)
Section 4 of 11
7594610581176931210ABCDEFGH
Kruskal on the network of worked example 4: red arcs added in the order GH, BD, AC, DE, CD, EG, EF. AB (dashed) is rejected because A, B, C and D are already connected.
What is a minimum spanning tree, and how does Kruskal's algorithm find one? (continued)
Section 4 of 11 · Worked example 4 · Medium · Find, state

WORKED EXAMPLE · QUESTION

The network has vertices A–H and arcs AB 7, AC 5, BC 9, BD 4, CD 6, BE 10, DE 5, DF 8, CF 11, EF 7, EG 6, FG 9, GH 3, EH 12, FH 10. (a) Use Kruskal's algorithm to find a minimum spanning tree, listing the arcs in the order considered and stating which are rejected. (b) State the weight of the tree.

SOLUTION

(a) Work through the sorted arcs until there are 8 − 1 = 7:

StepArcWeightDecision
1GH3add
2BD4add
3AC5add
4DE5add
What is a minimum spanning tree, and how does Kruskal's algorithm find one? (continued)
Section 4 of 11 · Worked example 4 · Medium · Find, state (continued)
StepArcWeightDecision
5CD6add
6EG6add
7AB7reject (cycle)
8EF7add

Seven arcs are added, so DF 8, BC 9, FG 9, … need not be considered. (b) MST GH, BD, AC, DE, CD, EG, EF; weight 3 + 4 + 5 + 5 + 6 + 6 + 7 = 36.

The tied pairs (AC, DE at 5 and CD, EG at 6) are both accepted, so their order does not matter. AB and EF tie at 7: taking EF first would complete the tree and AB would never be considered. The tree is the same either way.

What is a minimum spanning tree, and how does Kruskal's algorithm find one? (continued)
Section 4 of 11

Common error

Rejecting an arc because one of its ends is "already in the tree". Reject only if both ends are already connected through chosen arcs: that is what makes a cycle. EF is accepted although E is in the tree, because F is not.

How does Prim's algorithm work, on a network and on a matrix?
Section 5 of 11

1. Choose any vertex to start the tree.

2. Select the arc of least weight joining a vertex in the tree to a vertex not yet in the tree, and add it.

3. Repeat step 2 until every vertex is in the tree.

Prim never needs a cycle check, because each new arc reaches a new vertex, and the tree is connected at every stage.

How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11 · Worked example 5 · Easy · Find

WORKED EXAMPLE · QUESTION

Use Prim's algorithm, starting at A, on the network of worked example 4. List the arcs in the order selected.

SOLUTION

From A alone the cheapest arc out is AC 5; from A, C it is CD 6 (not AB 7). From A, C, D: DB 4; then DE 5; then EG 6; then GH 3; finally F joins by EF 7 (cheaper than DF 8, FG 9, FH 10, CF 11). Order AC, CD, DB, DE, EG, GH, EF; weight 36.

GH 3 is the lightest arc but Prim takes it sixth: it cannot be chosen until G is in the tree. That is the key difference from Kruskal.

How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11
7594610581176931210A (1)B (4)C (2)D (3)E (5)F (8)G (6)H (7)
Prim from A: the numbers give the order in which vertices join. The tree is the same as Kruskal's because this network has only one MST; only the order of selection differs.

On a distance matrix, "arcs from the tree" are the entries in the columns of vertices already chosen. Label each column in the order its vertex joins and cross out its row, so you never select an arc back into the tree.

1. Choose a starting vertex: label its column 1 and delete its row.

2. Look down all labelled columns and circle the smallest entry not in a deleted row.

3. That entry's row gives the new vertex: label its column with the next number and delete its row.

4. Repeat until every row is deleted.

How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11

The circled entries are the arcs of the tree.

How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11 · Worked example 6 · Medium · Find, state

WORKED EXAMPLE · QUESTION

The table gives lengths, in km, of possible water pipes between villages P–U. Use Prim's algorithm, starting at P, to find a minimum spanning tree. State the order in which vertices are added and the total length.

P (1)Q (2)R (3)S (5)T (4)U (6)
P—1421173025
Q(14)—12192428
R21(12)—161322
S1719(16)—1811
T3024(13)18—20
U252822(11)20—
How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11 · Worked example 6 · Medium · Find, state (continued)

SOLUTION

Column P labelled 1, row P deleted: smallest in column P is 14, row Q. Columns P, Q: 12 (column Q, row R) → R. Columns P, Q, R: 13 (column R, row T) → T. Columns P, Q, R, T: 16 (column R, row S), not 17 (P to S) or 18 (T to S) → S. Finally 11 (column S, row U) → U.

Order P, Q, R, T, S, U; arcs PQ 14, QR 12, RT 13, RS 16, SU 11: total 66 km. The bracketed numbers in the header are the order labels; the bold entries are the circled arcs.

How does Prim's algorithm work, on a network and on a matrix? (continued)
Section 5 of 11
1412131611PQRTSU
The minimum spanning tree of worked example 6, total 66 km.

Exam tip

"The order in which the arcs are selected" needs arcs (PQ, QR, …), not vertices; "the order of vertices" needs vertices. On a matrix, show the column labels and deleted rows: the final tree alone does not show you used Prim.

How does Dijkstra's algorithm find a shortest route?
Section 6 of 11

Dijkstra's algorithm finds the shortest route from a start vertex to every other vertex, in networks and digraphs whose weights are not negative. Each vertex gets a box: vertex, order of labelling and final value on top, working values underneath. A working value is the shortest distance found so far; a final value is the shortest distance, fixed for good.

1. Give the start vertex final value 0 and order label 1.

2. For every vertex Y joined directly to the vertex X just made final (and Y not yet final): working value = final(X) + weight XY. Write it in Y's box only if it is smaller than Y's current working value.

3. Of all vertices without final values, give the one with the smallest working value its final value and the next order label.

4. Repeat 2 and 3 until the destination has a final value.

5. Trace back from the destination: arc XY is on the route when final(Y) − final(X) = weight of XY.

How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11 · Worked example 7 · Hard · Find

WORKED EXAMPLE · QUESTION

A network has arcs SA 9, SB 5, SC 12, AB 3, AD 7, BC 6, BD 11, BE 15, CE 9, DE 4, DT 16, EF 5, ET 13, FT 6. Use Dijkstra's algorithm to find the shortest route from S to T and its length.

SOLUTION

S final (0): A 9, B 5, C 12; smallest B. B final (5): A 5 + 3 = 8 < 9 (write 8), C 11 < 12 (write 11), D 16, E 20; smallest A. A final (8): D 8 + 7 = 15 < 16. C final (11): E 11 + 9 = 20, not smaller, so nothing is written. D final (15): E 19 < 20, T 31. E final (19): F 24, T 32 (not smaller). F final (24): T 30 < 31. T final (30).

OrderVertexFinal valueWorking values
1S0—
2B55
3A89, 8
How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11 · Worked example 7 · Hard · Find (continued)
OrderVertexFinal valueWorking values
4C1112, 11
5D1516, 15
6E1920, 19
7F2424
8T3031, 30

Trace back: 30 − 24 = 6 = FT; 24 − 19 = 5 = EF; 19 − 15 = 4 = DE; 15 − 8 = 7 = AD; 8 − 5 = 3 = BA; 5 − 0 = 5 = SB. Shortest route S–B–A–D–E–F–T, length 30. E is not the vertex before T: 30 − 19 = 11, but ET is 13.

How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11
9512376111594165136S 0A 8B 5C 11D 15E 19F 24T 30
Worked example 7 with each vertex's final value. The red arcs satisfy final(Y) − final(X) = weight and form the shortest route, length 30.

Common error

Crossing out or overwriting working values, or writing a new value larger than the existing one. List every improving value in order, and only those: the boxes are your evidence.

How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11 · Worked example 8 · Hard · Find, explain

WORKED EXAMPLE · QUESTION

Farm water pipes join junctions A–G; lengths in tens of metres are AB 12, AC 8, AD 15, BC 6, BE 10, CD 9, CE 15, CF 11, DF 7, EF 5, EG 13, FG 9, DG 18. (a) Use Kruskal's algorithm to find a minimum spanning tree, stating the order of arcs and its weight. (b) Use Dijkstra's algorithm to find the shortest route from A to G. (c) Water must now pass through B on its way from A to G. Find the shortest such route. (d) Explain why the route from A to G within your tree is not the answer to (b).

SOLUTION

(a) In order: EF 5, BC 6, DF 7, AC 8, CD 9, FG 9; none of the first six makes a cycle. EF, BC, DF, AC, CD, FG; weight 44 (6 arcs for 7 vertices; CD and FG tie at 9).

OrderVertexFinal valueWorking values
1A0—
2C88
How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11 · Worked example 8 · Hard · Find, explain (continued)
OrderVertexFinal valueWorking values
3B1212
4D1515
5F1919
6E2223, 22
7G2833, 28

(b) D keeps 15 (AD): via C it would be 17. Trace back: 28 − 19 = 9 = FG; 19 − 8 = 11 = CF; 8 − 0 = 8 = AC. A–C–F–G, length 28 (280 m).

(c) A to B: AB = 12 (A–C–B is 14). B to G: B–E–G = 23 (B–E–F–G is 24, B–C–F–G is 26). A–B–E–G, length 35 (350 m).

(d) In the tree, A to G is A–C–D–F–G = 33, longer than 28.

How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11 · Worked example 8 · Hard · Find, explain (continued)

An MST minimises the total length connecting every vertex, not the distance between a particular pair.

How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11
12815610915117513918ABCDEFG
Worked example 8 (a): the minimum spanning tree, weight 44. Its A-to-G route A–C–D–F–G has length 33.
How does Dijkstra's algorithm find a shortest route? (continued)
Section 6 of 11
12815610915117513918ABCDEFG
Worked example 8 (b): the shortest route A–C–F–G, length 28, uses CF, which is not in the tree.
Exam tips for D1.2
Section 7 of 11

Exam tip 1 — show the algorithm's evidence

For Kruskal, list every arc you consider in order, with "reject" beside rejected ones. For Prim, list arcs in the order selected. A correct tree with no order shown does not demonstrate the algorithm.

Exam tip 2 — every working value in every box

In Dijkstra, fill in order of labelling, final value and all working values for every vertex you reach, including the destination, then show the trace-back subtraction for each arc of the route.

Exam tip 3 — n − 1 arcs

Count the vertices first. A spanning tree on n vertices has exactly n − 1 arcs: stop Kruskal as soon as you have them, and check your Prim list has that many.

Exam tips for D1.2 (continued)
Section 7 of 11

Exam tip 4 — use the precise definition

"Explain why this is a tree" needs connected and no cycles. "Explain why it is semi-Eulerian" needs "connected and exactly two vertices of odd degree", naming them.

Exam tip 5 — ties

With equal weights either arc may come first; say which you took. If asked whether the MST is unique, check whether a tied arc you rejected could have replaced one you accepted.

Common misconceptions
Section 8 of 11
MisconceptionWhy it is wrongCorrect idea
Prim always starts with the lightest arc in the network.Prim starts from a chosen vertex and only looks at arcs leaving the current tree.The lightest arc is Kruskal's first step; in Prim it joins only when one end is in the tree.
Kruskal rejects an arc if one end is already in the tree.That is how the tree grows.Reject only if both ends are already connected, so the arc would close a cycle.
The MST contains the shortest route between any two vertices.It minimises total weight, not each pairwise distance.Use Dijkstra (worked example 8: 33 in the tree, 28 by Dijkstra).
In Dijkstra, a working value is final as soon as it is written.A later vertex may give a shorter route (A: 9 then 8).Only the smallest working value among non-final vertices is made final each step.
A drawing with crossing edges shows the graph is not planar.Planar means it can be redrawn without crossings.Try to redraw it; K₄ as a square with diagonals is planar.
Common misconceptions (continued)
Section 8 of 11
MisconceptionWhy it is wrongCorrect idea
Graphs with the same degrees are isomorphic.Matching degrees is necessary, not sufficient.Find an explicit matching, or a structural difference such as a triangle.
How this topic connects
Section 9 of 11

D1.3 Route inspection and the travelling salesperson

The degree test decides which arcs must be repeated in route inspection, Dijkstra finds the shortest repeats, and minimum spanning trees give upper and lower bounds for the travelling salesperson problem.

D1.1 Algorithms and critical path analysis

Kruskal's first step is a sort, and all three graph algorithms are greedy algorithms whose work grows with the network. Activity networks are digraphs; the forward pass works like Dijkstra but takes the largest value at each event.

P1 Coordinate geometry

When vertices are grid points, arc weights are often straight-line distances found with Pythagoras' theorem before an algorithm is run.

Key formulae
Section 10 of 11
FormulaUseIn the formulae list?
sum of degrees = 2 × number of edgescounting edges from degrees; showing a degree list is impossibleNo — learn it
number of odd vertices is evenconsequence of the line aboveNo — derive it
Kₙ: ½n(n − 1) edges, each degree n − 1complete graphs; maximum edges in a simple graph on n verticesNo — derive it
spanning tree on n vertices: n − 1 arcsknowing when Kruskal or Prim is finishedNo — learn it
Eulerian ⇔ connected, all degrees even; semi-Eulerian ⇔ connected, exactly two oddwhether every edge can be traced exactly onceNo — learn it
working value of Y = final(X) + weight XYupdating boxes in DijkstraNo — learn it
Key formulae (continued)
Section 10 of 11
FormulaUseIn the formulae list?
final(Y) − final(X) = weight XYtracing back a Dijkstra routeNo — learn it
Check your understanding
Section 11 of 11

1. How many edges does K₁₀ have, and how many arcs are in a spanning tree of K₁₀?

2. A connected graph has exactly four odd vertices. Is it Eulerian, semi-Eulerian or neither?

3. A simple graph has four vertices, each of degree 3. Name it and state its number of edges.

4. A minimum spanning tree is found for K₆ with distinct weights. How many arcs of K₆ are not used?

5. A network has arcs SA 4, SB 9, AB 3, AT 11, BT 6. Find the shortest route from S to T.

Check your understanding · answers
Section 11 of 11

1. ½ × 10 × 9 = 45 edges; a spanning tree has 10 − 1 = 9 arcs.

2. Neither: Eulerian needs no odd vertices and semi-Eulerian exactly two. At least two edges would have to be repeated.

3. K₄ (each vertex joins all three others), with (3 × 4) ÷ 2 = 6 edges.

4. K₆ has 15 arcs and the tree uses 5, so 10 are not used.

5. S 0; A 4; B min(9, 4 + 3) = 7; T min(4 + 11, 7 + 6) = 13. Route S–A–B–T, length 13.

Check understanding

Practice questions

The answer and each step appear one click at a time.

Question 1 [8 marks]

This question is about the complete graph K₈ and about trees on 8 vertices.

(a) Find the number of edges of K₈, explaining your method. [2]

(b) Explain why K₈ is not Eulerian, and state, with a reason, whether K₉ is Eulerian. [2]

(c) Each edge of K₈ is given a different weight. State the number of edges in a minimum spanning tree, and the number of edges of K₈ that are not in it. [2]

(d) A connected graph has 8 vertices and 7 edges. Explain why it must be a tree. [2]

Mark scheme click to reveal each step

each of the 8 vertices has degree 7 and each edge is counted twice: ½ × 8 × 7

28 edges

every vertex of K₈ has odd degree 7 (eight odd vertices), so it is not Eulerian

every vertex of K₉ has even degree 8 and K₉ is connected, so K₉ is Eulerian

8 − 1 = 7 edges in the tree

28 − 7 = 21 not used ft on their 28

if it had a cycle, removing one edge of the cycle would leave it connected

but a connected graph on 8 vertices needs at least 7 edges, and 6 would be too few; so there is no cycle, and connected with no cycles means a tree

Question 2 [6 marks]

A company is linking the computers in six offices, A to F, with cable. The possible cable routes and their lengths, in metres, are: AB 14, AC 9, AD 17, BC 10, BE 8, CD 12, CE 11, CF 20, DF 13, EF 15. The company wants every office connected using the least total length of cable.

Figure: possible cable routes, lengths in metres; not to scale

(a) Use Kruskal's algorithm to find a minimum spanning tree. List the arcs in the order in which you consider them, stating any that you reject. [4]

(b) State the minimum total length of cable needed. [1]

(c) Explain why your tree has exactly five arcs. [1]

ABCDEF149171081211201315

Mark scheme click to reveal each step

arcs considered in ascending order, starting BE 8, AC 9

BC 10 added

CE 11 rejected (it would make the cycle B–C–E)

CD 12 added, DF 13 added, then stop with 5 arcs: BE, AC, BC, CD, DF

8 + 9 + 10 + 12 + 13 = 52 m ft on their tree

a spanning tree on 6 vertices has 6 − 1 = 5 arcs; a sixth arc would make a cycle

Keep practising

D1.2 Graphs, minimum spanning trees and Dijkstra

Full notes, every simulation and hundreds of questions with mark schemes, free:

ExaminerPrep is an independent tutoring service. It has been developed independently from and is not endorsed by the International Baccalaureate Organization. "International Baccalaureate", "IB" and "IB Diploma Programme" are registered trademarks of the IBO, used here for descriptive purposes only.
Pearson Edexcel and Cambridge are trademarks of their owners; ExaminerPrep is not affiliated with any exam board.