Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Floyd–Warshall algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Algorithm in graph theory}} {{CS1 config|mode=cs1}} {{Redirect|Floyd's algorithm|cycle detection|Floyd's cycle-finding algorithm|computer graphics|Floyd–Steinberg dithering}} {{Infobox Algorithm |class=[[All-pairs shortest path problem]] (for weighted graphs) |image= |caption = |data=[[Graph (data structure)|Graph]] |time=<math>\Theta (|V|^3)</math> |average-time=<math>\Theta (|V|^3)</math> |best-time=<math>\Theta (|V|^3)</math> |space=<math>\Theta(|V|^2)</math> }} In [[computer science]], the '''Floyd–Warshall algorithm''' (also known as '''Floyd's algorithm''', the '''Roy–Warshall algorithm''', the '''Roy–Floyd algorithm''', or the '''WFI algorithm''') is an [[algorithm]] for finding [[shortest path problem|shortest paths]] in a directed [[weighted graph]] with positive or negative edge weights (but with no negative cycles).<ref name=":0">{{Introduction to Algorithms|1}} See in particular Section 26.2, "The Floyd–Warshall algorithm", pp. 558–565 and Section 26.4, "A general framework for solving path problems in directed graphs", pp. 570–576.</ref><ref>{{cite book | author=Kenneth H. Rosen | title=Discrete Mathematics and Its Applications, 5th Edition | publisher = Addison Wesley | year=2003 | isbn=978-0-07-119881-3 }}</ref> A single execution of the algorithm will find the lengths (summed weights) of shortest paths between all pairs of vertices. Although it does not return details of the paths themselves, it is possible to reconstruct the paths with simple modifications to the algorithm. Versions of the algorithm can also be used for finding the [[transitive closure]] of a relation <math>R</math>, or (in connection with the [[Schulze method|Schulze voting system]]) [[widest path problem|widest paths]] between all pairs of vertices in a weighted graph.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)