Question: The Floyd-Warshall algorithm fails (does not work correctly) if the input graph has a negative weight cycle. (a) Draw a small graph with a negative-weight
The Floyd-Warshall algorithm fails (does not work correctly) if the input graph has a negative weight cycle.
(a) Draw a small graph with a negative-weight cycle. Demonstrate the result of running Floyd-Warshall on it (show D(k) for k = 1, . . . , n).
(b) In general, how can you use the output of the Floyd-Warshall algorithm to detect the presence of a negative-weight cycle?
Step by Step Solution
3.36 Rating (152 Votes )
There are 3 Steps involved in it
a Lets consider a small graph with a negativeweight cycle Graph G 1 1 2 4 In this graph there is a n... View full answer
Get step-by-step solutions from verified subject matter experts
