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!
==Time complexity== Let <math>n</math> be <math>|V|</math>, the number of vertices. To find all <math>n^2</math> of <math>\mathrm{shortestPath}(i,j,k)</math> (for all <math>i</math> and <math>j</math>) from those of <math>\mathrm{shortestPath}(i,j,k-1)</math> requires [[big theta|<math>\Theta(n^2)</math>]] operations. Since we begin with <math>\mathrm{shortestPath}(i,j,0) = \mathrm{edgeCost}(i,j)</math> and compute the sequence of <math>n</math> matrices <math>\mathrm{shortestPath}(i,j,1)</math>, <math>\mathrm{shortestPath}(i,j,2)</math>, <math>\ldots</math>, <math>\mathrm{shortestPath}(i,j,n)</math>, each having a cost of <math>\Theta(n^2)</math>, the total [[time complexity]] of the algorithm is <math>n \cdot \Theta(n^2) = \Theta(n^3)</math>.<ref name=":1" /><ref>{{cite book | last1 = Baras | first1 = John | last2 = Theodorakopoulos | first2 = George | date = 2022 | title = Path Problems in Networks | publisher = Springer International Publishing | isbn = 9783031799839 }}</ref>
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)