decision maths networks kruskals algorithm wiltshire networks a network is a weighted graph, which...

37
Decision Maths Networks Kruskal’s Algorithm

Upload: aaliyah-allington

Post on 28-Mar-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

Decision Maths

NetworksKruskal’s Algorithm

Page 2: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireNetworks

A Network is a weighted graph, which just means there is a number associated with each edge.

The numbers can represent distances, costs, times in real world applications.

Obvious examples include maps and similar geographical networks.

Page 3: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireNetworks

Page 4: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireMinimum Connector Problem

Basically you need to travel to every node using the least total length.

Consider 4 houses in a Network shown in the diagram below. The weight on each arc represents the distance between each house.

An Electricity company wants to supply every house by using as little cable as possible.

Clearly the shortest possible route is to go from A to B to C and then to D.

So 4 + 3 + 3 = 10, there is no shorter way of supplying every house.

Page 5: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireAlgorithms

The previous example was a simple one and the solution was very easy to spot.

For more complicated examples you will need to use an algorithm.

An Algorithm is simply a list of instructions that solve a particular problem.

(You will cover Algorithms in more depth later on in the course)

Page 6: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireKruskal`s Algorithm

There are 3 steps to follow in Kruskal`s Algorithm. Step 1 – Select the shortest arc in the

network. Step 2 – Select the shortest arc from those

which are remaining. Ensure that you do not create a cycle.

If you do ignore and move on to the next shortest arc.

Step 3 – If all the vertices are connected then stop. If not return to step 2.

Page 7: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireExample

Consider the Network below.

It helps to rank the arcs in increasing order.

Page 8: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying the Algorithm

1 – Start by selecting the smallest arc,

AB or DE, it makes no difference.

Select AB.

Page 9: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying the Algorithm

2 – Now select the next smallest, which is

DE.

Page 10: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying The Algorithm

3 – Next we can select CF or ` DF, again it makes no

difference. Lets pick DF.

Page 11: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying the Algorithm.

Next select CF.

Page 12: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying the Algorithm

The next smallest length is EF. However there is already a route from E to F, so this arc is not required.

Page 13: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireApplying the Algorithm

Adding CD will again create a loop so the last arc to add is AF. All vertices are now joined so the problem is complete.

Page 14: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireQuestion – Ex 3a pg 66 q1

Find the minimal spanning tree and associated shortest distance for the network below:

Page 15: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 16: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 17: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 18: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 19: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 20: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 21: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q1

Page 22: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 23: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 24: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 25: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 26: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 27: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 28: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 29: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 30: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 31: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 32: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 33: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 34: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 35: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 36: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4

Page 37: Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each

WiltshireSolution – Ex 3a pg 66 q4