Download presentation
Presentation is loading. Please wait.
Published byRosalind Watkins Modified over 9 years ago
1
Which of these can be drawn without taking your pencil off the paper and without going over the same line twice? If we can find a path that goes over all the edges of the graph without repeating an edge then the graph is said to be traversable. If we introduce a vertex where two lines meet and make the lines edges, then we can model these problems as graphs. Route Inspection
2
Whether or not a graph is traversable depends on the number of edges that meet at the vertices. The number of edges that meet at a vertex is called the degree of that vertex. Degree 2 Degree 3 Degree 2 Degree 3 An odd vertex is one with an odd degree. An even vertex is one with an even degree. An odd vertex is one with an odd degree. An even vertex is one with an even degree. Even Odd Even Route Inspection
3
A graph with only even vertices is traversable and we can start and finish at the same vertex. Such a graph is called Eulerian. All vertices even – Eulerian graph. Route Inspection
4
All vertices even – Eulerian graph. A graph with exactly 2 odd vertices is traversable as long as we start on one of the odd vertices and finish at the other one. Such a graph is called Semi-Eulerian. 2 odd vertices – Semi-Eulerian 2 odd vertices – Semi-Eulerian Route Inspection
5
All vertices even – Eulerian graph. A graph with more than two odd vertices is not traversable. 2 odd vertices – Semi-Eulerian 2 odd vertices – Semi-Eulerian 4 odd vertices – not traversable 4 odd vertices – not traversable Route Inspection
6
All vertices even – Eulerian graph. Which type of graph is the one on the far right? 2 odd vertices – Semi-Eulerian 2 odd vertices – Semi-Eulerian 4 odd vertices – not traversable 4 odd vertices – not traversable Two odd vertices - Semi-Eulerian Two odd vertices - Semi-Eulerian Route Inspection
7
The Chinese postman algorithm Step 4 Find an Eulerian trail. Step 1 Find all the odd vertices in the network. Step 2 Consider all the routes joining pairs of odd vertices. Choose the routes with the shortest total distance. Step 3 Add in these edges again. This will give a network with only even vertices.
8
Consider now a network with weights associated with the edges. The route inspection problem is to find a path through the network that includes every edge at least once and has the minimum total weight. Postman Pat has to deliver along each of the roads in the network below. What is his minimum total distance? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 Route Inspection
9
G B C E D F A All the vertices are even – the network is Eulerian – so any route that traverses the graph will suffice. 5 7 8 3 4 2 6 5 7 3 4 6 An example of one such path out of the many is: AEBCDFEDBGCFA An example of one such path out of the many is: AEBCDFEDBGCFA The minimum total distance is just the sum of the edges. 7 + 6 + 6 + 3 + 8 + 3 + 2 + 5 + 4 + 7 + 4 + 5 = 60 The minimum total distance is just the sum of the edges. 7 + 6 + 6 + 3 + 8 + 3 + 2 + 5 + 4 + 7 + 4 + 5 = 60 Route Inspection
10
G B C E D F A Another road is added to Pat’s round. 5 7 8 3 4 2 6 5 7 3 4 6 12 There are now 2 odd nodes, A and D, so the graph is Semi- Eulerian. The graph is still traversable if we start at one of the odd nodes and finish at the other one. Route Inspection
11
What if Pat needs to start and finish at the same place? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 To start and finish at A he will need to get back from D to A at the end. What is the shortest way of doing this? We could use Dijkstra’s shortest path algorithm for this but for this small example we can see it is along DEA, adding 10 to the total length. Route Inspection
12
G B C E D F A So by repeating the edges DE and EA we can start at A, cover every street and get back to A. The total distance = sum of all the edges + repeated edges = 72 + (3 + 7) = 82 So by repeating the edges DE and EA we can start at A, cover every street and get back to A. The total distance = sum of all the edges + repeated edges = 72 + (3 + 7) = 82 5 7 8 3 4 2 6 5 7 3 4 6 12 One of the many alternative routes that give this total is: AEBGCFEDBCDFGDEA One of the many alternative routes that give this total is: AEBGCFEDBCDFGDEA Route Inspection
13
Suppose now another road is added, FG. We now have four odd vertices A, D, F and G. We have to consider all the ways of pairing up these four vertices. Suppose now another road is added, FG. We now have four odd vertices A, D, F and G. We have to consider all the ways of pairing up these four vertices. To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 Route Inspection
14
To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? Route Inspection
15
To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A G – A and D – F Which of these pairings adds the least amount of extra distance? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F Which of these pairings adds the least amount of extra distance? Route Inspection
16
To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F Which of these pairings adds the least amount of extra distance? G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F = (6 + 6) + 5 = 17 Which of these pairings adds the least amount of extra distance? To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F = (6 + 6) + 5 = 17 Which of these pairings adds the least amount of extra distance? Route Inspection
17
G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F = (6 + 6) + 5 = 17 The middle pairing adds the least amount of extra distance. To complete his rounds and finish at the place he started, he will have to repeat one of the following pairs of paths G – F and D – A = 6 + (7 + 3) = 16 G – D and F – A = (5 + 4) + 6 = 15 G – A and D – F = (6 + 6) + 5 = 17 The middle pairing adds the least amount of extra distance. Route Inspection
18
G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 G – D and F – A = (5 + 4) + 6 = 15 The total distance = sum of all the edges + repeated edges = 78 + 15 = 93 We can make it easier to find a route by drawing in extra edges on the repeated route. G – D and F – A = (5 + 4) + 6 = 15 The total distance = sum of all the edges + repeated edges = 78 + 15 = 93 We can make it easier to find a route by drawing in extra edges on the repeated route. Route Inspection
19
G B C E D F A 5 7 8 3 4 2 6 5 7 3 4 6 12 6 An example route is: AFCDFEGDEBDBGBCGFA, total length 93. An example route is: AFCDFEGDEBDBGBCGFA, total length 93. Route Inspection
20
Summary GraphOdd vertices Repeated edges 0None 2The shortest path joining the two odd vertices 4Try all possible pairings of the odd vertices and choose the smallest combination. Route Inspection
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.