Longest paths: Dijkstra 2: Unterschied zwischen den Versionen

Aus Operations-Research-Wiki
Wechseln zu: Navigation, Suche
[unmarkierte Version][unmarkierte Version]
Zeile 47: Zeile 47:
 
'''Step 1:'''
 
'''Step 1:'''
  
Select start node A as base node and calculate all paths to neighbor nodes. You have the possibiltity to choose B or C as next node. In this case you choose C because it is the longest path from A. So you have a distance A (A-C = 7)
+
Select start node A as base node and calculate all paths to neighbor nodes. You can choose B or C as next base node. In this case we choose C because it has the longest distance to A. The actual distance is 7. (A-C = 7)
  
 
[[Datei:Schritt 01.png]]
 
[[Datei:Schritt 01.png]]
Zeile 53: Zeile 53:
 
Step 2:
 
Step 2:
  
Select the most distant node from a as next base node (C) and repeat step 2 from above. You have not yet reached the goal node (G). You continue with the next Basic node C calculate '''all''' distance from node C. You can go from C to E or from C to F. So yyou have the distance C (C-E = 11) and C '''(C-F = 15).'''  
+
Select the most distant node from A as next base node (C) and repeat step 2 from above. We have not reached the goal node (G) yet, so we continue with the next Base node C and calculate '''all''' paths from node C to the neighbour nodes. We choose the Path A-C-F and F as next base node. (C-E = 11) and C '''(C-F = 15).'''  
  
 
[[Datei:Schritt 02.png]]
 
[[Datei:Schritt 02.png]]
Zeile 59: Zeile 59:
 
Step 3:  
 
Step 3:  
  
The next Iteration step is from E to D and from E to F and check where is the longest path. It could be possibile that the graph have a longer way maybe from E to D. So you '''have to''' check '''all''' possibilities from one node to another node up to reach your goal node. So you have distance from E (E-D = 12, A-C=7 + C-E=4 + E-D=1). E (E-F=14). So you the way '''A-C-F=15'''.
+
The next iteration step from base node F leads to our goal node G. Our temporary longest path is A-C-F-G with 20.  
  
 
[[Datei:Schritt 03.png]]
 
[[Datei:Schritt 03.png]]
Zeile 65: Zeile 65:
 
Step 4 and 5:
 
Step 4 and 5:
  
From node F in this case you have only one possibility to reach the goal node G. '''F (F-G=20''').
+
Now we have to check if there are any paths that have a longer distance than A-C-F-G.
 +
So we take the second distant node from A (In this Case E) and calculate the paths to all neighbour nodes as before.
 +
A-C-E-F is shorter than A-C-F and therefore we reject this path.
 +
A-C-E-D is stored with the path length of 12.
 +
 
 +
D is our next base node and we calculate the path to our goal node G (A-C-E-D-G). The length is 16 and shorter than A-C-F-G therefore we have to reject it.
  
 
[[Datei:Schritt 04.png]]
 
[[Datei:Schritt 04.png]]
Zeile 71: Zeile 76:
 
Step 6:
 
Step 6:
  
You have to check the last node from D to G because it could be possible that the distance from D to G is very long to reach the final node G. To reach G over D you have a distance from A-C-E-D-G= 16. You compare the results and decide to go the longest way.
+
We continue with the next distant node from A (node B)and repeat the calculation.
 +
A-B-E is shorter than A-C-E and therefore we reject this path.
 +
A-B-D has the same length as A-C-E-D, we can decide which path we want to keep.
 +
We have considered all paths of this graph and found the longest path is A-C-F-G (20)
  
 
[[Datei:Schritt 05.png]]
 
[[Datei:Schritt 05.png]]
Zeile 77: Zeile 85:
 
Longest Path
 
Longest Path
  
In this problem you have one way to reached the final node G with longest path namly '''A-C-F-G= 20'''. '''It is very important to check all ways from one node to another node to reach your goal node.'''
+
The longest path is '''A-C-F-G with 20'''.  
 +
 
  
 
[[Datei:Schritt 06.png]]
 
[[Datei:Schritt 06.png]]

Version vom 30. Juni 2013, 22:06 Uhr

1. Theory

One of the most important tasks in the graph theory is the calculation of the longest and shortest path between a starting node I and an end node J.

The Dijkstra Algorithm is an algorithm that allows you to allocate the shortest path in a graph between a starting node i and an end note j by inlcuding other nodes of the graph.

It can also be used to calculate longest paths, if some simple modifications are used.

The calculation of the longest path demands directed arcs in order to proceed a correct solution.

Furthermore loops have to be eliminated, otherwise the solution would be infinite and therefore invalid.



2. Example

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

3. Explanation of the problem

In this example we want to find the longest path from node A to node G. To avoid the calculation of every possible path, we use the djikstra algorithm.

Although It might be seem easy to recognize the solution by overviewing the problem, but more complex problems with a lot more nodes,

will make it is necessary to have a working algorithm which can provide a precise and easy solution.


4. Detailed Solution

1. Select starting node as base node.

2. Compute path length to all neighbor nodes of the base node, which have not been base node yet. If the path is longer than the longest one caculated up to now,the new path will be stored.

3. Select that node as new base node, with the longest distance to the starting node and repeat step 2.

4. The optimal solution is found when there are no more paths left that haven’t been calculated.


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


Step 1:

Select start node A as base node and calculate all paths to neighbor nodes. You can choose B or C as next base node. In this case we choose C because it has the longest distance to A. The actual distance is 7. (A-C = 7)

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

Step 2:

Select the most distant node from A as next base node (C) and repeat step 2 from above. We have not reached the goal node (G) yet, so we continue with the next Base node C and calculate all paths from node C to the neighbour nodes. We choose the Path A-C-F and F as next base node. (C-E = 11) and C (C-F = 15).

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

Step 3:

The next iteration step from base node F leads to our goal node G. Our temporary longest path is A-C-F-G with 20.

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

Step 4 and 5:

Now we have to check if there are any paths that have a longer distance than A-C-F-G. So we take the second distant node from A (In this Case E) and calculate the paths to all neighbour nodes as before. A-C-E-F is shorter than A-C-F and therefore we reject this path. A-C-E-D is stored with the path length of 12.

D is our next base node and we calculate the path to our goal node G (A-C-E-D-G). The length is 16 and shorter than A-C-F-G therefore we have to reject it.

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

Step 6:

We continue with the next distant node from A (node B)and repeat the calculation. A-B-E is shorter than A-C-E and therefore we reject this path. A-B-D has the same length as A-C-E-D, we can decide which path we want to keep. We have considered all paths of this graph and found the longest path is A-C-F-G (20)

Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden

Longest Path

The longest path is A-C-F-G with 20.


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden



Literature

Müller-Merbach, Operations Research 2. Auflage, Verlag: Vahlen 1971, S. 241-247.

Lecture and script (slide 2.4 to 2.9) from Operation Research Prof. Oliver Wendt SS 2013.

Assignment 1 from Operation Research Tutorial for graph theory.