3,161 views

1 Answer

Best answer
8 votes
8 votes
  Positive edge weight Negative edge weight Negative weight cycle
Kruskal Algorithm YES YES (Yes just add a positive number to all the edge weights which is sufficiently large to make all edge weights positive) YES(Yes just add a positive number to all the edge weights which is sufficiently large to make all edge weights positive)
Prims Algorithm YES YES (Yes just add a positive number to all the edge weights which is sufficiently large to make all edge weights positive) YES (Yes just add a positive number to all the edge weights which is sufficiently large to make all edge weights positive)
Dijkstra Algorithm YES NO(Not gives correct result always ) NO (can't detect negative weight cycles)
Bellman-Ford Algorithm YES YES NO (But it can detect negative weight cycles)
Floyd Warshall Algorithm YES YES NO (But it can detect negative weight cycles)

$\color{Magenta}{EDIT}$ -
Note - For those algorithms that can detect cycle, they cannot always detect $\color{RED}{ALL}$ the negative weight cycles. But they can always surely say that there is $\color{GREEN}{Some}$ negative edge weight cycle present in the Graph or not. 

Thanks a lot, @Deepak Poonia sir for suggesting edit.  :)

edited by

Related questions

1 votes
1 votes
0 answers
2
Na462 asked Feb 19, 2018
628 views
Given a graph with positive and distinct edge weights. If I double or triple.. the edge weights then:- 1. Shortest path will remain same2. Mst will remain sameRight?Note ...
2 votes
2 votes
0 answers
4
Dulqar asked Jan 26, 2017
460 views
Show the different minimum spanning Trees Possible in each of the following AlgorithmsPrims AlgorithmKruskal