Presentation is loading. Please wait.

Presentation is loading. Please wait.

Party-by-Night Problem

Similar presentations


Presentation on theme: "Party-by-Night Problem"— Presentation transcript:

1 Party-by-Night Problem
Dijkstra’s Algorithm Party-by-Night Problem

2 [node1 node2 node3 node4 … node14 ]
To illustrate Dijkstra’s algorithm, we will find the shortest path from node 1 (Engineering Building) to node 14 (Springbok’s). We begin with the following labels; where a * represents a permanent label, and the ith number is the distance to the node i (i = 1;2;3;…;14). [0* ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞] [node1 node2 node3 node4 … node14 ] We label node 1 with a permanent label 0*. Then we label each node i that is connected to node 1 by a single arc with a “temporary” label equal to the length of the arc joining node 1 and node i. As there is no direct paths (nodes connected by a single arc) between node 1 and node 4;…;14 these distances are represented by ∞

3 Step 2: Node 4 has the smallest temporary label. We therefore make node 4’s label permanent and obtain the following labels: [0* * ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞] We now know that node 4 is the closest node to node 1. We next compute temporary labels for all nodes that are connected to node 4 by a single arc. Node: Temporary Label Node 5 min{∞; } = 1150* Node 7 min{∞; } = 2050 Node 8 min{∞; } = 1450 We obtain the following labels: [0* 1100* 1150 ∞ ∞ ∞ ∞ ∞ ∞ ∞]

4 Step 3: Node 5 has the smallest temporary label. We therefore make node 5’s label permanent and obtain the following labels: [0* 1100* 1150* ∞ ∞ ∞ ∞ ∞ ∞ ∞] We now know that node 5 is the second closest node to node 1. We next compute temporary labels for all nodes that are connected to node 5 by a single arc. Node: Temporary Label Node 9 min{∞; } = 1390* We obtain the following labels: [0* 1100* 1150* 1390* ∞ ∞ ∞ ∞ ∞]

5 Step 4: Node 9 has the only temporary label as it’s the only node with a direct path from node 5. We therefore make node 9’s label permanent and obtain the following labels: [0* 1100* 1150* 1390* ∞ ∞ ∞ ∞ ∞] We next compute temporary labels for all nodes that are connected to node 9 by a single arc. Node: Temporary Label Node 11 min{∞; } = 1890 Node 12 min{∞; } = 1740 Node 13 min{∞; } = 1520* We obtain the following labels: [0* 1100* 1150* 1390* ∞ ∞]

6 Step 5: Node 13 has the smallest temporary label. We therefore make node 13’s label permanent and obtain the following labels: [0* 1100* 1150* 1390* ∞ * ∞] We now only have one node left. We compute temporary labels for the node that connects the last node, node 14, by a single arc. Node: Temporary Label Node 14 min{∞; } = 1910* We obtain the following labels: [0* 1100* 1150* 1390* 1520* 1910]

7 [Node1 Node4 Node5 Node9 Node13 Node14]
Conclusion: Our final set of labels is: [0* 1100* 1150* 1390* 1520* 1910*] We can now work backwards and find the shortest path from node 1 to node 14. The permanent label for node 14 represents the length of the shortest path, thus 1970m. The difference between the permanent labels of the nodes represents the lengths of the arc (path) between the nodes. E.g. Node 13 – Node 9 1520 – 1390 = 130 the distance between node 9 and node 13 is 130m. Our final labels thus represents the following path (in this order) through the nodes as the shortest path: [Node1 Node4 Node5 Node9 Node13 Node14]


Download ppt "Party-by-Night Problem"

Similar presentations


Ads by Google