def print_matrix(matrix, iteration, matrix_name):
    print(f"After iteration {iteration}, {matrix_name}:“)
    for row in matrix:
        print([‘inf’ if x == float('inf') else x for x in row])
    print()

def initialize_matrices(num_vertices, edges):
    inf = float('inf')
    D = [[inf if i != j else 0 for i in range(num_vertices)] for j in range(num_vertices)]
    P = [[None for _ in range(num_vertices)] for _ in range(num_vertices)]

    for start, end, weight in edges:
        D[start][end] = weight
        P[start][end] = start  # Initializing the predecessor as the start node

    return D, P

def floyd_warshall_with_printing(num_vertices, edges):
    D, P = initialize_matrices(num_vertices, edges)

    print_matrix(D, 0, "D0")
    print_matrix(P, 0, "P0")

    for k in range(num_vertices):
        for i in range(num_vertices):
            for j in range(num_vertices):
                if D[i][k] + D[k][j] < D[i][j]:
                    D[i][j] = D[i][k] + D[k][j]
                    P[i][j] = P[k][j]
        
        print_matrix(D, k + 1, f"D{k + 1}")
        print_matrix(P, k + 1, f"P{k + 1}")

    return D, P

# Assuming the numbering of vertices starts from 0. Adjust according to your input
edges = [
    (0, 1, 4), (0, 5, 10), (1, 0, 3), (1, 3, 18),
    (2, 1, 6), (3, 1, 5), (3, 2, 15), (3, 4, 2),
    (3, 5, 19), (3, 6, 5), (4, 2, 12), (4, 3, 1),
    (5, 6, 10), (6, 3, 8)
]

# Number of vertices in the graph
num_vertices = 7

final_D, final_P = floyd_warshall_with_printing(num_vertices, edges)

print("Final Distance Matrix:")
for row in final_D:
    print(row)

print("\nFinal Predecessor Matrix:")
for row in final_P:
    print(row)
 After iteration 0, D0:
[0, 4, 'inf', 'inf', 'inf', 10, 'inf']
[3, 0, 'inf', 18, 'inf', 'inf', 'inf']
['inf', 6, 0, 'inf', 'inf', 'inf', 'inf']
['inf', 5, 15, 0, 2, 19, 5]
['inf', 'inf', 12, 1, 0, 'inf', 'inf']
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
['inf', 'inf', 'inf', 8, 'inf', 'inf', 0]

After iteration 0, P0:
[None, 0, None, None, None, 0, None]
[1, None, None, 1, None, None, None]
[None, 2, None, None, None, None, None]
[None, 3, 3, None, 3, 3, 3]
[None, None, 4, 4, None, None, None]
[None, None, None, None, None, None, 5]
[None, None, None, 6, None, None, None]

After iteration 1, D1:
[0, 4, 'inf', 'inf', 'inf', 10, 'inf']
[3, 0, 'inf', 18, 'inf', 13, 'inf']
['inf', 6, 0, 'inf', 'inf', 'inf', 'inf']
['inf', 5, 15, 0, 2, 19, 5]
['inf', 'inf', 12, 1, 0, 'inf', 'inf']
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
['inf', 'inf', 'inf', 8, 'inf', 'inf', 0]

After iteration 1, P1:
[None, 0, None, None, None, 0, None]
[1, None, None, 1, None, 0, None]
[None, 2, None, None, None, None, None]
[None, 3, 3, None, 3, 3, 3]
[None, None, 4, 4, None, None, None]
[None, None, None, None, None, None, 5]
[None, None, None, 6, None, None, None]

After iteration 2, D2:
[0, 4, 'inf', 22, 'inf', 10, 'inf']
[3, 0, 'inf', 18, 'inf', 13, 'inf']
[9, 6, 0, 24, 'inf', 19, 'inf']
[8, 5, 15, 0, 2, 18, 5]
['inf', 'inf', 12, 1, 0, 'inf', 'inf']
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
['inf', 'inf', 'inf', 8, 'inf', 'inf', 0]

After iteration 2, P2:
[None, 0, None, 1, None, 0, None]
[1, None, None, 1, None, 0, None]
[1, 2, None, 1, None, 0, None]
[1, 3, 3, None, 3, 0, 3]
[None, None, 4, 4, None, None, None]
[None, None, None, None, None, None, 5]
[None, None, None, 6, None, None, None]

After iteration 3, D3:
[0, 4, 'inf', 22, 'inf', 10, 'inf']
[3, 0, 'inf', 18, 'inf', 13, 'inf']
[9, 6, 0, 24, 'inf', 19, 'inf']
[8, 5, 15, 0, 2, 18, 5]
[21, 18, 12, 1, 0, 31, 'inf']
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
['inf', 'inf', 'inf', 8, 'inf', 'inf', 0]

After iteration 3, P3:
[None, 0, None, 1, None, 0, None]
[1, None, None, 1, None, 0, None]
[1, 2, None, 1, None, 0, None]
[1, 3, 3, None, 3, 0, 3]
[1, 2, 4, 4, None, 0, None]
[None, None, None, None, None, None, 5]
[None, None, None, 6, None, None, None]

After iteration 4, D4:
[0, 4, 37, 22, 24, 10, 27]
[3, 0, 33, 18, 20, 13, 23]
[9, 6, 0, 24, 26, 19, 29]
[8, 5, 15, 0, 2, 18, 5]
[9, 6, 12, 1, 0, 19, 6]
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
[16, 13, 23, 8, 10, 26, 0]

After iteration 4, P4:
[None, 0, 3, 1, 3, 0, 3]
[1, None, 3, 1, 3, 0, 3]
[1, 2, None, 1, 3, 0, 3]
[1, 3, 3, None, 3, 0, 3]
[1, 3, 4, 4, None, 0, 3]
[None, None, None, None, None, None, 5]
[1, 3, 3, 6, 3, 0, None]

After iteration 5, D5:
[0, 4, 36, 22, 24, 10, 27]
[3, 0, 32, 18, 20, 13, 23]
[9, 6, 0, 24, 26, 19, 29]
[8, 5, 14, 0, 2, 18, 5]
[9, 6, 12, 1, 0, 19, 6]
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
[16, 13, 22, 8, 10, 26, 0]

After iteration 5, P5:
[None, 0, 4, 1, 3, 0, 3]
[1, None, 4, 1, 3, 0, 3]
[1, 2, None, 1, 3, 0, 3]
[1, 3, 4, None, 3, 0, 3]
[1, 3, 4, 4, None, 0, 3]
[None, None, None, None, None, None, 5]
[1, 3, 4, 6, 3, 0, None]

After iteration 6, D6:
[0, 4, 36, 22, 24, 10, 20]
[3, 0, 32, 18, 20, 13, 23]
[9, 6, 0, 24, 26, 19, 29]
[8, 5, 14, 0, 2, 18, 5]
[9, 6, 12, 1, 0, 19, 6]
['inf', 'inf', 'inf', 'inf', 'inf', 0, 10]
[16, 13, 22, 8, 10, 26, 0]

After iteration 6, P6:
[None, 0, 4, 1, 3, 0, 5]
[1, None, 4, 1, 3, 0, 3]
[1, 2, None, 1, 3, 0, 3]
[1, 3, 4, None, 3, 0, 3]
[1, 3, 4, 4, None, 0, 3]
[None, None, None, None, None, None, 5]
[1, 3, 4, 6, 3, 0, None]

After iteration 7, D7:
[0, 4, 36, 22, 24, 10, 20]
[3, 0, 32, 18, 20, 13, 23]
[9, 6, 0, 24, 26, 19, 29]
[8, 5, 14, 0, 2, 18, 5]
[9, 6, 12, 1, 0, 19, 6]
[26, 23, 32, 18, 20, 0, 10]
[16, 13, 22, 8, 10, 26, 0]

After iteration 7, P7:
[None, 0, 4, 1, 3, 0, 5]
[1, None, 4, 1, 3, 0, 3]
[1, 2, None, 1, 3, 0, 3]
[1, 3, 4, None, 3, 0, 3]
[1, 3, 4, 4, None, 0, 3]
[1, 3, 4, 6, 3, None, 5]
[1, 3, 4, 6, 3, 0, None]

Final Distance Matrix:
[0, 4, 36, 22, 24, 10, 20]
[3, 0, 32, 18, 20, 13, 23]
[9, 6, 0, 24, 26, 19, 29]
[8, 5, 14, 0, 2, 18, 5]
[9, 6, 12, 1, 0, 19, 6]
[26, 23, 32, 18, 20, 0, 10]
[16, 13, 22, 8, 10, 26, 0]

Final Predecessor Matrix:
[None, 0, 4, 1, 3, 0, 5]
[1, None, 4, 1, 3, 0, 3]
[1, 2, None, 1, 3, 0, 3]
[1, 3, 4, None, 3, 0, 3]
[1, 3, 4, 4, None, 0, 3]
[1, 3, 4, 6, 3, None, 5]
[1, 3, 4, 6, 3, 0, None]

=== Code Execution Successful === I want you to add 1 to each entry in the matrix P at every iteration to get the correct output.