Add Floyd-Warshall algorithm#1312
Conversation
029f7dc to
8e70a8e
Compare
24d5dce to
870709c
Compare
Performance Measurements with Valgrind:@angriman, @fabratu where Next I changed the From these observations, I conclude that the performance difference between Comparison of
|
|
Thanks for doing the benchmarks. This seems to back the assumption, that in the case at hand, there is no significant difference in performance. |
|
Thanks a lot for setting up those benchmarks and sharing the results. For this particular application, it looks that using |
Implement Floyd-Warshall Algorithm for All-Pairs Shortest Paths
This PR introduces the Floyd-Warshall algorithm for computing all-pairs shortest paths in a weighted graph. It supports both directed and undirected graphs, correctly handles negative edge weights, and detects negative cycles. If multiple shortest paths exist with the same distance, the algorithm selects the one with the fewest nodes.
Features
getNodesOnShortestPath(source, target).The algorithm runs in O(n³) time complexity, with n representing the number of nodes, making it suitable for small to medium-sized graphs.