Module 2: NETWORKS AND DECISION MATHEMATICS

Similar documents
Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Undirected Network Summary

Topic 10 Part 2 [474 marks]

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

MEI Further Mathematics Support Programme

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

WUCT121. Discrete Mathematics. Graphs

Worksheet for the Final Exam - Part I. Graphs

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

An Introduction to Graph Theory

Graphs Definitions. Gunnar Gotshalks. GraphDefinitions 1

1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G))

SAMPLE. MODULE 5 Undirected graphs

Chapter 5: Euler Paths and Circuits The Mathematics of Getting Around

Graph Theory. Part of Texas Counties.

MEI Conference 2009: D2

Assignment 4 Solutions of graph problems

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

Chapter 5: Euler Paths and Circuits The Mathematics of Getting Around

Varying Applications (examples)

Graph (1A) Young Won Lim 4/19/18

Discrete mathematics II. - Graphs

Chapter 1 Graph Theory

INTRODUCTION TO GRAPH THEORY. 1. Definitions

Math Summer 2012

Elements of Graph Theory

Mathematics and Statistics, Part A: Graph Theory Problem Sheet 1, lectures 1-4

CS6702 GRAPH THEORY AND APPLICATIONS 2 MARKS QUESTIONS AND ANSWERS

CS6702 GRAPH THEORY AND APPLICATIONS QUESTION BANK

0.0.1 Network Analysis

Graph and Digraph Glossary

Introduction to Graph Theory

Algorithms. Graphs. Algorithms

Simple graph Complete graph K 7. Non- connected graph

Foundations of Discrete Mathematics

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

Question. Why is the third shape not convex?

Chapter 9 Graph Algorithms

Network Topology and Graph

Chapter 9 Graph Algorithms

Assignments are handed in on Tuesdays in even weeks. Deadlines are:

Graph Theory. 1 Introduction to Graphs. Martin Stynes Department of Mathematics, UCC January 26, 2011

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95

1. CONVEX POLYGONS. Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D.

Introduction III. Graphs. Motivations I. Introduction IV

Instant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006

Notebook Assignments

TWO CONTRIBUTIONS OF EULER

The University of Sydney MATH2969/2069. Graph Theory Tutorial 2 (Week 9) 2008

Examples of Tasks from Course 1, Unit 4

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

2 hours THE UNIVERSITY OF MANCHESTER. 22 May :00 16:00

Honors ICM- Graph Theory Unit 7 Homework Packet Homework Day 1

EECS 203 Lecture 20. More Graphs

Graph Theory CS/Math231 Discrete Mathematics Spring2015

Chapter 9 Graph Algorithms

Chapter 2 Graphs. 2.1 Definition of Graphs

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Majority and Friendship Paradoxes

MAS 341: GRAPH THEORY 2016 EXAM SOLUTIONS

Graph Overview (1A) Young Won Lim 5/9/18

About the Tutorial. Audience. Prerequisites. Disclaimer & Copyright. Graph Theory

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Ordinary Differential Equation (ODE)

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Chapter 3: Paths and Cycles

08. First and second degree equations

Graph Theory II. Po-Shen Loh. June edges each. Solution: Spread the n vertices around a circle. Take parallel classes.

BIL694-Lecture 1: Introduction to Graphs

Combinatorics Summary Sheet for Exam 1 Material 2019

1. Sorting (assuming sorting into ascending order) a) BUBBLE SORT

Basic Combinatorics. Math 40210, Section 01 Fall Homework 4 Solutions

Planar Graph (7A) Young Won Lim 5/21/18

Student Name and ID Number. MATH 3012 Final Exam, December 11, 2014, WTT

How can we lay cable at minimum cost to make every telephone reachable from every other? What is the fastest route between two given cities?

PATH FINDING AND GRAPH TRAVERSAL

Lecture 10. Elementary Graph Algorithm Minimum Spanning Trees

MT365 Examination 2017 Part 1 Solutions Part 1

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Graphs. The ultimate data structure. graphs 1

Planar Graph (7A) Young Won Lim 6/20/18

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

Degree of nonsimple graphs. Chemistry questions. Degree Sequences. Pigeon party.

Instructor: Paul Zeitz, University of San Francisco

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH 1301 DISCRETE MATHEMATICS TIME ALLOWED: 2 HOURS

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

Graphs (MTAT , 6 EAP) Lectures: Mon 14-16, hall 404 Exercises: Wed 14-16, hall 402

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Grade 7/8 Math Circles Graph Theory - Solutions October 13/14, 2015

6.2. Paths and Cycles

Sections 5.2, 5.3. & 5.4

Math 311. Trees Name: A Candel CSUN Math

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Simple Graph. General Graph

Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path

Fundamental Properties of Graphs

Mathematics MD01. General Certificate of Education Advanced Subsidiary Examination. Unit Decision 1

Transcription:

Further Mathematics 2017 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks Key knowledge the conventions, terminology, properties and types of graphs; edge, face, loop, vertex, the degree of a vertex, isomorphic and connected graphs, and the adjacency matrix, and Euler s formula for planar graphs and its application the exploring and travelling problem, walks, trails, paths, Eulerian trails and circuits, and Hamiltonian cycles the minimum connector problem, trees, spanning trees and minimum spanning trees the shortest path problem and Dijkstra s algorithm Key skills construct graphs, digraphs and networks and their matrix equivalents to model and analyse practical situations recognise that a problem is an example of the exploring and travelling problem and to solve it by utilising the concepts of walks, trails, paths, Eulerian trails and circuits, and Hamiltonian paths and cycles recognise that a problem is an example of the minimum connector problem and solve it by utilising the properties of trees, spanning trees and by determining a minimum spanning tree by inspection or using Prim s algorithm for larger scale problems recognise that a problem is an example of the shortest path problem and solve it by inspection or using Dijkstra s algorithm for larger scale problems Chapter Sections Questions to be completed 9.2 Basic concepts 2, 4, 6, 8, 10, 12, 14, 15ab, 16a, 17, 20, 21, 22 9.3 Planar graphs and Euler s formula 1, 2, 4, 5, 6, 9ac, 10, 12, 14, 15, 17,20 9.4 Walks, trails, paths, cycles and circuits 1, 2, 3, 4, 5, 6, 8, 9, 13, 17, 18, 19, 20, 21 9.5 Trees and their application 1, 2, 7, 8, 10, 13, 15, 16, 17, 18, 21ac, 22a, 23, 24

MODULE 2: NETWORKS AND DECISION MATHEMATICS Table of Contents CHAPTER 9 UNDIRECTED GRAPHS AND NETWORKS... 1 KEY KNOWLEDGE... 1 KEY SKILLS... 1 9.2 BASIC CONCEPTS OF A NETWORK... 3 DEFINITION OF A NETWORK... 3 WORKED EXAMPLE 1... 3 THE DEGREE OF A VERTEX... 3 WORKED EXAMPLE 2... 4 REPRESENTATION OF NETWORKS... 4 WORKED EXAMPLE 3... 4 WORKED EXAMPLE 4... 5 MATRIX REPRESENTATION OF NETWORKS... 5 WORKED EXAMPLE 5... 5 9.3 PLANAR, GRAPHS AND EULER S FORMULA... 6 DEGENERATE GRAPH... 6 COMPLETE GRAPH... 6 PLANAR GRAPHS... 6 THE REGIONS OF A PLANAR GRAPH... 7 CONVERTING A NON- PLANAR GRAPH... 7 WORKED EXAMPLE 6... 7 WORKED EXAMPLE 7... 7 CONVERTING THREE- DIMENSIONAL SOLIDS TO PLANAR GRAPHS... 8 WORKED EXAMPLE 8... 8 EULER S FORMULA... 8 WORKED EXAMPLE 9... 8 9.5 TREES AND THEIR APPLICATION... 12 GRAPHS AND SUBGRAPHS... 12 TREES... 13 WORKED EXAMPLE 15... 13 SHORTEST PATHS... 13 WORKED EXAMPLE 16... 13 A SHORTEST PATH ALGORITHM... 13 WORKED EXAMPLE 17... 14 SPANNING TREES... 15 MINIMUM SPANNING TREE AND PRIM S ALGORITHM... 16 PRIM S ALGORITHM... 16 WORKED EXAMPLE 18... 16 MAXIMUM SPANNING TREE... 17 WORKED EXAMPLE 19... 17 DIJKSTRA S ALGORITHM... 18 DIJKSTRA S ALGORITHM EXAMPLE 1... 18 DIJKSTRA S ALGORITHM EXAMPLE 2... 20 WORKED EXAMPLE 20 (STUDENT PRACTICE)... 21 ADDITIONAL DIJKSTRA S ALGORITHM QUESTIONS... 22 9.4 WALKS, TRAILS, PATHS, CYCLES AND CIRCUITS... 9 WALKS... 9 CONNECTED GRAPHS... 9 EULER TRAILS... 9 WORKED EXAMPLE 10... 9 EULER CIRCUITS... 10 WORKED EXAMPLE 11... 10 AN EULER CIRCUIT ALGORITHM... 10 WORKED EXAMPLE 12... 11 PATH AND CYCLES... 11 WORKED EXAMPLE 13... 12 HAMILTONIAN CYCLES... 12 WORKED EXAMPLE 14... 12 Page 2 of 22

9.2 Basic concepts of a network UNDIRECTED GRAPHS AND NETWORKS Definition of a network The telephone system, your family tree and the internet are all considered to be networks (graphs). The simplest definition of a network is: Consider the following diagram. It is perhaps the simplest network. It consists of two vertices (singular vertex) (circles labelled 1 and 2) and one connection between them. This connection is called an edge. Worked Example 1 Count the number of vertices and edges in the network shown. Vertices: Edges: There are two things worth noting about this classification of a network: 1. the vertices and edges can be labelled in any order, using any suitable labelling system. 2. vertices may have different number of edges connected to them. The degree of a vertex Each vertex may have a number of edges connecting it with the rest of the network. This number is called the degree. A vertex with degree 0 is not connected to any other vertex, and is called an isolated vertex. If two (or more) edges connect the same pair of vertices they are called parallel edges (or multiple edges) and all count towards the degree. If there is only one connection between two vertices, the connection is called a simple, or single, connection. Page 3 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Worked Example 2 Determine the degree of each vertex in the figure shown. Representation of networks So far we have seen graphical representation of networks. Two other ways of representing networks are: 1. labelling the vertices and labelling the edges according to their vertices 2. matrix representation Worked Example 3 Label the vertices and edges for the figure shown, as in Worked example 2 Page 4 of 22

Worked Example 4 Construct a graph from the following list of vertices and edges. V = {A, B, C, D, E} E = {(A, B), (A, C), (A, D), (B, C), (B, D), (B, D), (C, E), (D, E), (E, E)} UNDIRECTED GRAPHS AND NETWORKS There may be other geometric configurations which can be drawn from the same vertex and edge list, but they isomorphic (or equivalent) to this one. Matrix representation of networks A method of representing a network is through the use of a matrix. Worked Example 5 Represent the network shown as a matrix In a matrix representation 1. the sum of a row (or column) gives a degree of that vertex, except where a loop is present (shown as a 1 in the leading diagonal), add 1 to the sum of the row or column. 2. if an entire row or its corresponding column has only s then that vertex is isolated 3. the matrix is diagonally symmetric. Page 5 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS 9.3 Planar, graphs and Euler s formula A planar graph is a special kind of network or graph. The additional properties of planar graphs will allow us to map two- dimensional and even three- dimensional objects into graphs. Degenerate graph A graph with no edges is called a degenerate graph (or null graph). Complete graph A graph were all vertices are directly connected to all other vertices without parallel edges or loops is called a complete graph. The figure on the left is a degenerate; the one on the right is complete. How many edges would there be in a complete graph of 6 vertices? Planar graphs Consider the following graphs. Figure a is a planar graph because none of the paths {A, B, C, D, E, F} cross each other. Figure b is apparently not a planar graph because the path (A, D) crosses the path (B, C). Is figure c a planar graph? Page 6 of 22

The regions of a planar graph UNDIRECTED GRAPHS AND NETWORKS The above graph can be divided into three regions (faces): region I, region II and region III. Region III is infinite as it continues beyond the bounds of the diagram. Region I and region II have a finite area. Converting a non- planar graph Although it may appear that a graph is not planar, by modifying the graph it may become clearly planar. Two method that you could use are: 1. Move the edges 2. Move the vertices Worked Example 6 Convert the graph below to a planar graph. Indicate the faces of the planar graph. The degree of each face is the number of edges defining that region. Worked Example 7 Find the degree of each face of the graph shown in the figure. Page 7 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Converting three- dimensional solids to planar graphs Worked Example 8 The figure shows a cube with vertices, V = {A, B, C, D, E, F, G, H}. Convert this to a planar graph. Euler s formula The relationship that links vertices, edges and faces of a planar graph is know as Euler s formula. Worked Example 9 Verify Euler s formula for the cube of the last figure in Worked example 8. Note that the cube is a form of prism and all prisms can be converted to planar graphs using the technique of one face collapsing into another. Page 8 of 22

UNDIRECTED GRAPHS AND NETWORKS 9.4 Walks, trails, paths, cycles and circuits Walks A walk is a sequence of edges that takes you along some or all of the edges or through some or all of the vertices. There are different ways of naming a walk. For example, consider the figure shown on the right, travelling from node 1 to node 3. A walk could be specified via node 2, namely A- B or by specifying the vertices 1-2- 3. Alternatively, you could the walk C- E- D, or C- F. Each of these routes is a walk. Connected graphs The figure on the left, there is no walk between vertices 1 and 2, nor between vertices 3 and 4, so it is not a connected graph. However, if we add a single edge, as in the figure on the right, between vertices 1 and 2, the entire graph becomes connected. Euler trails A trail is a walk in which no edges are repeated. 1. For an Euler trail to exist, all vertices must be of an even degree or there must be exactly two vertices of odd degree. 2. If the degrees of all the vertices are even numbers, start with any vertex. In this case the starting vertex and ending vertex are the same. 3. If there are two vertices whose degree is an odd number used either as a starting point. The other vertex of odd degree must be the ending point. Worked Example 10 Using the figure, identify an Euler trail. Page 9 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Euler circuits In an Euler circuit all the vertices must be of an even degree. If there is an odd degree vertex, an Euler circuit is not possible. Worked Example 11 Find an Euler circuit for the planar graph shown. An Euler circuit algorithm For some networks it may be difficult to determine an Euler circuit. Here is an algorithm (a process) that guarantees an Euler circuit. Consider a network where all vertices ar3e of even degree. Let V = {1, 2, 3, } be the list of vertices. Step 1. Choose a starting vertex from the list V. Call this vertex A. Step 2. Step 3. From vertex A, find the smallest possible path which returns to vertex A. This is a sub- circuit of the original network. Let S be the list of vertices in this sub- circuit. For each vertex in S, choose a single vertex in turn as the starting vertex of a different sub- circuit. It should be as small as possible, and not use any previously used edge. Step 4. For each of these new sub- circuits (if there are any), add any new vertices to the list in S. Step 5. Repeat steps 3 and 4 until there are no more new vertices, edges or sub- circuits left; that is, the list S and V are the same. Step 6. Join the sub- circuits at their intersection points. Page 10 of 22

Worked Example 12 Find one possible Euler circuit for the network shown using the Euler circuit algorithm. UNDIRECTED GRAPHS AND NETWORKS Step Instruction Example 1 Choose a starting vertex, and find its smallest sub- circuit. 2 Create the list S from the first sub- circuit. Find new sub- circuit, not using any edges already used. (step 3) 3 Add to the list S. (step 4) 4 Find the new sub- circuit. (step 3) 5 Add to list S. Check that all vertices are in the list. (step 4) 6 Form the Euler trail, starting with the first sub- circuit, and proceeding through all the other sub- circuit at their intersection. (step 6) 7 List the Euler circuit. Path and cycles In Euler trails and circuits each edge was used exactly once, while vertices could be re- used. Now, consider the case where it is desirable to use each vertex exactly once. Please note: Not all edges need to be used. There can only be up to 2 vertices with degree 1 (dead ends). These would be the start and/or the finishing vertices. Page 11 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Worked Example 13 Determine a Hamiltonian path in the planar graph shown. Hamiltonian cycles When determining a Hamiltonian path, sometimes it is desirable to start and finish with the same vertex. For example, a travelling salesperson may live in one of the towns (vertices) she visits and would like to start and finish at her home town after visiting all the other towns once. This is similar to the concept of an Euler circuit. Worked Example 14 Determine a Hamiltonian cycle in the planar graph shown. 9.5 Trees and their application Graphs and subgraphs A network can also be called a graph. In practice, a graph should have at least 2 vertices and 1 edge. All or part of this graph can be considered as a subgraph. For example, in the figure, the entire network can be considered as a graph, while the path in pink can be considered a subgraph. Another subgraph could be defined by the path 1 2 3 4 1. 1 A minimum subgraph could be defined by the path 1 2. Often the edges can be assigned some quantity such as distance or cost. If a graph contains quantities, it is then called a weighted graph. Page 12 of 22

Trees UNDIRECTED GRAPHS AND NETWORKS Worked Example 15 Determine whether each of the figures is a tree, and if not, explain why not. a. b. c. d. The advantage of trees within a network is that the tree could determine an efficient connection between vertices in the sense that there is a minimum distance, cost or time. Shortest paths Sometimes it may be useful to determine the shortest path between 2 selected vertices of a graph. Worked Example 16 Determine the shortest path between nodes A and F in the figure shown. Possible trees between A- F Distance travelled A shortest path algorithm Sometimes it can be difficult to list all the paths between the starting and ending vertex. Here is an algorithm that guarantees the shortest path. Step 1. From the starting vertex, find the shortest path to all other directly connected vertices. Include all such vertices, including the starting one in the list S = {A, B, } Step 2. Choose a vertex directly connected to those in S and find the shortest path to the staring vertex. Step 3. Add the new vertex, V, to the list S. Step 4. Repeat steps 2 and 3 until all vertices are in S. Find the shortest path to the vertex you want. Page 13 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Worked Example 17 Find the shortest path from vertex 1 to vertex 9. 1. From 1 find shortest path to each vertices directly connected to it From To Via Distance Shortest path to 2. Determine set of vertices in S 3. Choose a vertex directly connected to one in S Select vertex 5 4. Add new vertex to the S list 5. Choose a vertex directly connected to one in S Select vertex 6 6. Add new vertex to the S list 7. Choose a vertex directly connected to one in S Select vertex 7 8. Add new vertex to the S list 9. Choose a vertex directly connected to one in S Select vertex 8 10. Add new vertex to the S list 11. Choose last vertex 9 Select vertex 9 12. Add new vertex to the S list 13. Stop once all vertices are listed Page 14 of 22

UNDIRECTED GRAPHS AND NETWORKS Spanning trees Spanning trees include all vertices. Consider the following network. If the vertices are a location/town /house etc. and the distances are shown on the edges. Then the figures below show the possible trees. Note that each of these trees included all the vertices of the original network. These trees are called spanning trees because of this property. Page 15 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Minimum spanning tree and Prim s algorithm Minimum spanning trees connect all vertices with the smallest distance. Prim s algorithm Step 1. Step 2. Step 3. Step 4. Worked Example 18 Choose the edge with the minimum value. If 2 or more edges are the smallest, choose any of these. Inspect the next edges connected to the two vertices on the ends of your original edge. Choose the smallest edge. Inspect all included vertices so far and choose the smallest edge leading from any vertex. Repeat until all vertices are included. Determine the minimum spanning tree for the network representing footpaths in a school campus. Page 16 of 22

Maximum spanning tree Worked Example 19 UNDIRECTED GRAPHS AND NETWORKS Maximum spanning trees connect all vertices with the largest distance. The figure shown represents a telephone network connecting 6 towns, A, B,, F. The numbered edges represent the capacity of the telephone connection between the towns connected, that is, the maximum number of calls that can be made at the same time along that edge. A telephone engineer wishes to determine the maximum capacity of the system in terms of a tree connecting all the towns so that calls can be routed along that tree. Page 17 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Dijkstra s algorithm Another method for determining the shortest path between a given vertex and each of the other vertices is Dijkstra s algorithm. Dijkstra s algorithm Example 1 The weights in the graph opposite show the distances, in kilometres, by road between the towns. The algorithm will be used to find the shortest path between St Andrews (S ) and Toolangi (T ). Step 1: Create a table 1. Write the starting vertex as the first row vertex. 2. Write the other vertices in the network as column vertices (the order is unimportant). S K Y T H Step 2: Complete the first row Look at the graph to find the distance from the starting vertex (the row vertex in this example S) to the vertices that are directly connected to it (a column vertex). 1. Write down the distance from the row vertex to a column vertex, directly underneath the column vertex as shown. 2. If a vertex is not directly connected to the starting vertex, mark a cross (x). 3. Look for the smallest number in the first row and draw a box around it. If there are two or more the same, any one can be chosen. 4. The column vertex for this boxed number becomes the next row vertex. K Y T H S 13 15 X X K Y T H S 13 15 X X K Step 3: Complete the further rows 1. Copy all boxed numbers into the next row. K Y T H S 13 15 X X K 13 Page 18 of 22

2. For the remaining columns, add the boxed numbers for the row vertex to the distance from the row vertex to the column vertex. a) If the value is greater than the value above it, ignore the new value and copy the existing one. b) If the value is less than or equal to the value above it in the column, write down new value. c) If the row vertex is not directly connected to the column vertex, mark with a cross (x). 3. Look for the smallest unboxed number in the row and draw a box around it. 4. The column vertex for this new boxed number becomes the next row vertex. 5. Repeat step 3 until the destination vertex value has a boxed around it. UNDIRECTED GRAPHS AND NETWORKS K Y T H S 13 15 X X K 13 15 28 X K Y T H S 13 15 X X K 13 15 28 X Y K Y T H S 13 15 X X K 13 15 28 X Y 13 15 28 29 Step 4: Backtrack to identify the shortest path and its length 1. Start at the box value for the destination vertex. This is the length of the shortest path from the starting vertex to the destination vertex. 2. Draw a line up the column to the last number that is the same as the box number (it does not have to have a box around it). 3. Look at the row vertex for this number and draw a horizontal line to the column for this vertex. 4. Repeat until the starting vertex is reached. 5. The horizontal lines in the table indicate the shortest path. K Y T H S 13 15 X X K 13 15 28 X Y 13 15 28 29 Page 19 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Dijkstra s algorithm Example 2 Find the shortest path from A to F in the weighted graph shown using Dijkstra s algorithm Step 1: Create a table 1. Write the starting vertex as the first row vertex. 2. Write the other vertices in the network as column vertices (the order is unimportant). Step 2: Complete the first row Look at the graph to find the distance from the starting vertex (the row vertex in this example S) to the vertices that are directly connected to it (a column vertex). 1. Write down the distance from the row vertex to a column vertex, directly underneath the column vertex as shown. 2. If a vertex is not directly connected to the starting vertex, mark a cross (x). 3. Look for the smallest number in the first row and draw a box around it. If there are two or more the same, any one can be chosen. 4. The column vertex for this boxed number becomes the next row vertex. Step 3: Complete the further rows 1. Copy all boxed numbers into the next row. 2. For the remaining columns, add the boxed numbers for the row vertex to the distance from the row vertex to the column vertex. a) If the value is greater than the value above it, ignore the new value and copy the existing one. b) If the value is less than or equal to the value above it in the column, write down new value. c) If the row vertex is not directly connected to the column vertex, mark with a cross (x). 3. Look for the smallest unboxed number in the row and draw a box around it. 4. The column vertex for this new boxed number becomes the next row vertex. 5. Repeat step 3 until the destination vertex value has a boxed around it. A A A A A A B C D E F B C D E F B C D E F B C D E F B C D E F B C D E F Page 20 of 22

Step 4: Backtrack to identify the shortest path and its length 1. Start at the box value for the destination vertex. This is the length of the shortest path from the starting vertex to the destination vertex. 2. Draw a line up the column to the last number that is the same as the box number (it does not have to have a box around it). 3. Look at the row vertex for this number and draw a horizontal line to the column for this vertex. 4. Repeat until the starting vertex is reached. 5. The horizontal lines in the table indicate the shortest path. A UNDIRECTED GRAPHS AND NETWORKS B C D E F Worked Example 20 (STUDENT PRACTICE) Determine the shortest path from A to E, where the distance are in kilometres, by using Dijkstra s algorithm in tabular form. Page 21 of 22

MODULE 2: NETWORKS AND DECISION MATHEMATICS Additional Dijkstra s Algorithm Questions Page 22 of 22