The Floyd-Warshall algorithm is used to find the shortest paths between all pairs of vertices in a weighted graph. It creates distance and sequence tables with rows and columns for each vertex. The distance table stores the weights of edges between vertices. The sequence table stores the path vertices to reach between each pair. It iterates through the tables, updating distances and paths at each iteration based on whether a new shortest path is found through a third vertex. When complete, the final distance table shows the shortest distance between each pair of vertices, and the sequence table shows the shortest path.