1

I need your help with F-W algorithm. My question is: is it possible to find shortest path between two vertexes? Down below I will give you an example of what I want.

 1 -----50(w)----- 5
 | \__         /    |
 |    \5(w)   /20(w)|
 10(w) \__3__/      |25(w)
 |           \___   |
 |           18(w)\ |  
 2--------8(w)------4

If my picture isn't possible to see, here is a picture of it: http://prntscr.com/b6n43d

This is what I got with final cycle with weights:

0   10   5   18   25   
10  0    15  8    33   
5   15   0   18   20   
18  8    18  0    25   
25  33   20  25   0  

And this is what I got with vertex'es:

0   1   2   1   2   
0   0   0   3   3   
0   0   0   3   4   
1   1   2   0   4   
2   3   2   3   0 

And I need to find that vertex, that furthermost vertex be as most as possible near that first vertex. What I mean, that vertex 1 have 50 weight with 5 vertex (that mean they are furthermost from each other) and I need to find shortest path between 1 and 5. Any ideas how I can do that ?

The whole code were write'd from https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm pseuudo code.

Golden112
  • 11
  • 4
  • What do you mean by `shortest path` between 1 and 5? If you are asking for the weight, then the cell (1,5) in your weighted result array is your answer, which is 25. Or do you mean the path? You may check https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm#Path_reconstruction – Gary Sham May 21 '16 at 15:07
  • Your question is not quite clear. What does "final cycle with weights" mean ? and what does "what I got with vertices" mean ? – Fafore Tunde May 21 '16 at 18:53
  • for first question: yes 25 is anser but i need to print it like: Shortest path 1 --> 3 --- > 5 (something like that) To second question final cycle with weight's mean that i have graph where is little bit upper ANSWER that numbers in matrix I got after F-W algorithm realization, same with vertex'es. What I want is to print is clear rezult's like: Shortest path between furthermost vertex'es is 1 -> 3 -> 5 :) – Golden112 May 22 '16 at 06:22

0 Answers0