FloydWarshall is very memory inefficient
See original GitHub issueFurther to our sending Dijkstra out to lunch:
FloydWarshall starts with:
// init the backtrace matrix
backtrace = new Object[n][n];
You know what’s coming next 😀 Let’s assume that N = 586165 (our “small” graph):
586165 * 586165 * 8 // on a 64-bit machine
2748715257800 // bytes
./1048576
2621379 // megabytes...
./1024
2559 // gigabytes ...
Since our graph is directed and largely acyclic, I think we can do much better. Interestingly, we haven’t even hit hash tables, this is a straight array. So, raising a ticket as a placeholder while we figure this out.
It looks like a lovely candidate for a ForkJoinPool, too.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Unreasonable memory usage for JohnsonShortestPaths? #626
The Floyd-Warshall implementation is very efficient storage-wise, using one map from vertices to integers and then only 2 arrays (with n^2 ...
Read more >Improving The Floyd-Warshall All Pairs Shortest Paths ... - arXiv
Thus, in general the Floyd-Warshall algorithm becomes very inefficient especially for sparse graphs. In this paper, we show a simple.
Read more >Time complexity of Floyd Warshall algorithm - Stack Overflow
Therefore the time complexity comes out to be O(v^3) but with a very small constant value, making it extremely viable during implementation. So ......
Read more >Solving All Pairs Shortest Paths in Parallel
Taking advantage of locality is extremely important in this case, as Floyd-Warshall's algorithm is memory bound. Besides the dependencies between iterations ...
Read more >A Memory Access Model for Highly-threaded Many-core ...
memory-access latency and validates the intuition that the Floyd-Warshall algorithm performs ... count the number of memory transfers from slow memory to.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

(I think the duplicated code noted by @shevek has finally been removed in #630.)
I’ve merged #632. Remaining items here are:
Anything else?