Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Floyd's Algorithm quickly and effectively.
363+ students studying
Floyd's algorithm, also known as the Floyd-Warshall algorithm, is a method for finding the shortest paths between all pairs of nodes in a weighted graph. It is particularly effective for dense graphs and works for both directed and undirected graphs, provided there are no negative weight cycles.
Find the shortest paths between all pairs of nodes in the graph below:
Node Pair | Weight |
---|---|
A → B | 3 |
A → C | ∞ |
A → D | 7 |
B → A | 8 |
B → C | 2 |
B → D | ∞ |
C → A | 5 |
C → B | ∞ |
C → D | 1 |
D → A | 2 |
D → B | ∞ |
D → C | ∞ |
Initialisation Create the initial distance matrix and route matrix :
Distance Matrix :
Route Matrix :
First Iteration () Use as the intermediate node to update distances:
Updated Distance Matrix :
Updated Route Matrix :
Second Iteration () Use as the intermediate node to update distances:
Updated Distance Matrix :
Updated Route Matrix :
Third Iteration ()
Repeat using as the intermediate node.
Fourth Iteration ()
Finally, use as the intermediate node.
Final Result
After all iterations, the final distance matrix and route matrix give the shortest paths between all pairs of nodes.
Incorrect Initialisation Forgetting to set and all non-edges to ∞.
Order of Iterations Not completing the updates row by row as required.
Missing Updates Failing to check all pairs when using as the intermediate node.
Route Matrix Errors Forgetting to update the route matrix when a shorter path is found.
Negative Cycles Using the algorithm on graphs with negative weight cycles, which causes incorrect results.
Route Matrix Update If a shorter path is found, update to reflect the intermediate node .
Termination Criterion The algorithm completes after iterations, where is the number of nodes.
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
30 flashcards
Flashcards on Floyd's Algorithm
Revise key concepts with interactive flashcards.
Try Further Maths Decision Maths 1 Flashcards3 quizzes
Quizzes on Floyd's Algorithm
Test your knowledge with fun and engaging quizzes.
Try Further Maths Decision Maths 1 Quizzes29 questions
Exam questions on Floyd's Algorithm
Boost your confidence with real exam questions.
Try Further Maths Decision Maths 1 Questions27 exams created
Exam Builder on Floyd's Algorithm
Create custom exams across topics for better practice!
Try Further Maths Decision Maths 1 exam builder50 papers
Past Papers on Floyd's Algorithm
Practice past papers to reinforce exam experience.
Try Further Maths Decision Maths 1 Past PapersDiscover More Revision Notes Related to Floyd's Algorithm to Deepen Your Understanding and Improve Your Mastery
96%
114 rated
Shortest Path Algorithms
Comparing Dijkstra's & Floyd's Algorithms
441+ studying
196KViewsJoin 500,000+ A-Level students using SimpleStudy...
Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered