Floyd's Algorithm
Floyd's Algorithm
return D
TIME AND SPACE complexity
TIME COMPLEXITY : O(V3)
✔️Works well for dense graphs (where the number of edges is close to V²).
DISADVANTAGES
❌ Does not work with negative weight cycles (it will keep reducing
distances indefinitely).
Flight Connectivity In the aviation industry to find the shortest path between the airports.
GIS(Geographic Information Systems) applications often involve analyzing spatial data, such as
road networks, to find the shortest paths between locations.
Why Floyd-Warshall Algorithm better for Dense
Graphs and not for Sparse Graphs?