I just drew this graph completely random:
I found the shortest path (marked in red) by simply checking everything. But the reason was to use Dijkstra's algorithm. But when I try I get stuck in a loop. Lake a look at my calculations:
How to read it is:
- Top Row: Wich node
- Section t: Total distance traveled
- From: Wich node did I come from
- The 10 over S and every other section can be read like this
- To come from S to node 1, the complete path takes 10 time units
So, if you try to follow Dijkstra's algorithm you will get something like this: S->D->C->5->4->6->D->S->5->4->6->D->(and so on)
I get stuck in a loop. I understand that when I return to S I can reset the time to 0, witch make at least the first bit correct, S->5->4, but than it get stuck.
How are you supposed to solve a problem like this based on how the algorithm is formed? For me, it is obviously stupid to just go around this route, but for an algorithm it is not.
Thank you in advance!