Article

The Floyd‐Warshall all‐pairs shortest paths algorithm for disconnected and very sparse graphs

Authors:
To read the full-text of this research, you can request a copy directly from the author.

Abstract

The Floyd‐Warshall algorithm is the most popular algorithm for determining the shortest paths between all vertex pairs in a graph. It is a very simple and an elegant algorithm. However, for graphs without any negative weighted edges, using Dijkstra's shortest path algorithm for every vertex as a source vertex to produce all‐pairs shortest paths works significantly better than the Floyd‐Warshall algorithm, especially for large graphs. Furthermore, for graphs with negative weighted edges, with no negative cycle, in general Johnson's algorithm also performs better than the Floyd‐Warshall algorithm for large graphs. Johnson's algorithm first transforms the graph into a non‐negative one by using the Bellman‐Ford algorithm, then applies the Dijkstra's algorithm to the transformed graph. Thus, mainly, the Floyd‐Warshall algorithm is quite inefficient, especially for large graphs. In this paper, we show a simple improvement on the Floyd‐Warshall algorithm that will increases its efficiency, especially for very sparse graphs (i.e., the number of its edges is less than the number of its vertices), so it can be used instead of more complicated alternatives. We also show that our approach is also very effective for denser disconnected graphs. Since the new algorithm modifies the original Floyd‐Warshall algorithm, it is mainly aimed for directed graphs without negative cycles. Most programmers prefer to implement the Floyd‐Warshall algorithm over more complicated but more efficient alternatives for solving all‐pairs shortest path problems. In this work, we show that without the addition of any complicated data structures, the performance of the Floyd‐Warshall algorithm can be improved very easily. Our practical approach works even better than its alternatives for large sparse graphs.

No full-text available

Request Full-text Paper PDF

To read the full-text of this research,
you can request a copy directly from the author.

ResearchGate has not been able to resolve any citations for this publication.
Conference Paper
Full-text available
We present the results of an extensive computational study on dynamic algorithms for all pairs shortest path problems. We describe our implementations of the recent dynamic algorithms of King [18] and of Demetrescu and Italiano [7], and compare them to the dynamic algorithm of Ramalingam and Reps [25] and to static algorithms on random, real-world and hard instances. Our experimental data suggest that some of the dynamic algorithms and their algorithmic techniques can be really of practical value in many situations.
Article
Full-text available
We study novel combinatorial properties of graphs that allow us to devise a completely new approach to dynamic all pairs shortest paths problems. Our approach yields a fully dynamic algorithm for general directed graphs with non-negative realvalued edge weights that supports any sequence of operations in e O(n amortized time per update and unit worst-case time per distance query, where n is the number of vertices. We can also report shortest paths in optimal worst-case time. These bounds improve substantially over previous results and solve a long-standing open problem. Our algorithm is deterministic and uses simple data structures.
Conference Paper
Full-text available
The all-pairs shortest paths problem in weighted graphs is investigated. An algorithm called the hidden paths algorithm, which finds these paths in time O(m*+n n<sup>2</sup> log n), where m * is the number of edges participating in shortest paths, is presented. It is argued that m * is likely to be small in practice, since m*=O(n log n) with high probability for many probability distributions on edge weights. An Ω( mn ) lower bound on the running time of any path-comparison-based algorithm for the all-pairs shortest paths problem is proved
Article
Random graph (RG) models play a central role in complex networks analysis. They help us to understand, control, and predict phenomena occurring, for instance, in social networks, biological networks, the Internet, and so on. Despite a large number of RG models presented in the literature, there are few concepts underlying them. Instead of trying to classify a wide variety of very dispersed models, we capture and describe concepts they exploit considering preferential attachment, copying principle, hyperbolic geometry, recursively defined structure, edge switching, Monte Carlo sampling, and so on. We analyze RG models, extract their basic principles, and build a taxonomy of concepts they are based on. We also discuss how these concepts are combined in RG models and how they work in typical applications like benchmarks, null models, and data anonymization.
Article
Given an arbitrary directed graph with non-negative edge lengths, we present an algorithm that computes all pairs shortest paths in time , where is the number of different edges contained in shortest paths and is the running time of an algorithm solving the single-source shortest path problem (SSSP). This is a substantial improvement over a trivial times application of that runs in . In our algorithm we use as a black box and hence any improvement on results also in improvement of our algorithm. A combination of our method, Johnson’s reweighting technique and topological sorting results in an all-pairs shortest path algorithm for directed acyclic graphs with arbitrary edge lengths. We also point out a connection between the complexity of a certain sorting problem defined on shortest paths and SSSP. Finally, we show how to improve the performance of the proposed algorithm in practice. We then empirically measure the running times of various all-pairs shortest path algorithms on randomly generated graph instances and obtain very promising results.
Article
We present an all-pairs shortest path algorithm whose running time on a complete directed graph on n vertices whose edge weights are chosen independently and uniformly at random from [0, 1] is O(n(2)), in expectation and with high probability. This resolves a long-standing open problem. The algorithm is a variant of the dynamic all-pairs shortest paths algorithm of Demetrescu and Italiano [2006]. The analysis relies on a proof that the number of locally shortest paths in such randomly weighted graphs is O(n(2)), in expectation and with high probability. We also present a dynamic version of the algorithm that recomputes all shortest paths after a random edge update in O(log(2) n) expected time.
Article
Algorithms for finding shortest paths are presented which are faster than algorithms previously known on networks which are relatively sparse in arcs. Known results which the results of this paper extend are surveyed briefly and analyzed. A new implementation for priority queues is employed, and a class of “arc set partition” algorithms is introduced. For the single source problem on networks with nonnegative arcs a running time of O(min(n1+1/k + e, n + e) log n)) is achieved, where there are n nodes and e arcs, and k is a fixed integer satisfying k > 0. This bound is O(e) on dense networks. For the single source and all pairs problem on unrestricted networks the running time is O(min(n2+1/k + ne, n2 log n + ne log n).
A note on two problems in connection with graphs
  • EW Dijkstra