Minimum spanning tree
A spanning tree such that the total length of its arcs is as small as possible. Can tell you smallest/cheapest/fastest way of linking all nodes
What does Kruskal’s algorithm do?
Find the minimum spanning tree
Kruskal’s algorithm
Kruskal’s algorithm working
Write down edge, tick/cross if used, draw if necessary
Kruskal’s algorithm advantages and disadvantages
+ easy to follow
- weaker for many edges, difficult to check cycles
What does Prim’s algorithm do
Find the minimum spanning tree
Prim’s algorithm process
What does Prim’s algorithm do if there are multiple
Gives you a different spanning tree depending on the starting node
What else can Prim’s algorithm be used on?
An undirected distance matrix
Prim’s algorithm on a distance matrix
What does Dijkstra’s algorithm do?
Find the shortest path from one node to all the others in a network
Dijkstra’s Algorithm Table
Vertex | Order of labelling | Final label
Working values
Dijkstra’s Algorithm Process
Label the start vertex with order 1 and final label 0
Assign a working value to all that can be reached from that vertex of final value of that + distance between, replacing the current value if it is lower
Give the vertex with lowest working label its final label and repeat until the destination vertex has its final label
How to find the shortest path from Dijkstra’s algorithm?
Trace back from the end vertex, taking paths where the final label of the vertex you are going to is equal to the final label of the current node minus the distance between
Floyd’s algorithm setup
First iteration of Floyd’s algorithm
Further iterations of Floyd’s algorithm
Repeat, shading row and column B and so on
Unbox any values that were boxed on the last iteration
Finding a route from Floyd’s algorithm
Write down the start and end vertex with a gap in between
Using the final route table use the row of the start and column of the end to see if any nodes are used in between
Repeat this for any routes until all have been checked to be fastest direct