def warshall(graph):
    """
    Warshall's Algorithm for Shortest Path
    Complexity: O(V^3)

    It produces the shortest paths between all the vertices.
    """
    for k in range(len(graph)):
        for i in range(len(graph)):
            for j in range(len(graph)):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

    return graph