Dijkstra code is showing wrong output

Правка en1, от Ashik53, 2017-11-14 10:17:57

for below input,but my dijkstra code shows wrong output for this input.

5 6

1 2 1

2 3 1

3 4 7

1 5 1

5 4 3

1 4 1

Enter source and destination

1 3

output = 101, should be 2

I found that my code isn't adding the new neighbor nodes in if block of dijkstra function sometimes.So, that's why some nodes are not updated. Why does this happen? I tried multiples times to find out the reason but failed.

My code — https://ideone.com/J7JNxy

Теги java, graph, dijkstra

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Ashik53 2017-11-14 10:17:57 524 Initial revision (published)