The Floyd-Warshall algorithm finds the shortest paths between all pairs of vertices in a weighted graph. It works by iteratively updating the shortest path between all pairs through intermediate vertices. The algorithm takes as input the adjacency matrix representing the graph and outputs the distance matrix containing the shortest paths between all pairs of vertices.