Edited sentence: Consider a graph  with vertices , each numbered 1 through N.Further consider a function  that returns the shortest possible path from  to  using only vertices 1 through  as intermediate points along the way.It does so by incrementally improving an estimate on the shortest path between two vertices, until the estimate is known to be optimal.It is able to do this with only  comparisons.Now, given this function, our goal is to find the shortest path from each  to each  using only nodes 1 through.The Floyd-Warshall algorithm compares all possible paths through the graph between each pair of vertices.There are two candidates for this path: either the true shortest path only uses nodes in the set ; or there exists some path that goes from  to , then from  to  that is better.This is remarkable considering that there may be up to  edges in the graph, and every combination of edges is tested.We know that the best path from  to  that only uses nodes 1 through  is defined by , and it is clear that if there were a better path from  to  to , then the length of this path would be the concatenation of the shortest path from  to  (using vertices in ) and the shortest path from  to  (also using vertices in )