Graph Theory37 sections · 1633 units
Open in CourseQuiz: Negative Edges in Floyd-Warshall
Knowledge check
Check Your Understanding
Floyd-Warshall handles negative edge weights correctly (unlike Dijkstra). How do you detect a negative cycle after running the algorithm?
- A.Check if any
dist[i][j]is negative - B.Check if the total sum of all distances is negative
- C.Run the algorithm twice and compare results
- D.Check if any diagonal entry
dist[i][i]is negative