Floyd-Warshall Algorithm
Introduction
Given a directed or undirected weighted graph with vertices. The task is to find the length of the shortest path between each pair of vertices and . The graph may have edges with negative weights, but there are no negative weight cycles.
This algorithm can also be used to determine the presence of negative cycles. The graph has a negative cycle if at the end of the algorithm the distance from vertex to itself is negative.