# Shortest paths and minimal weight

I have to use Warshall's algorithm to find the shortest paths and their minimal weights between all pairs of nodes in the following weighted graph.

From what I've been suggested I have to compute some matrices but I don't have a clear idea of what I am supposed to do.

I know how to compute $n * n$ matrix $P^{(n)}$ matrix of paths between nodes, do I have to compute until $P^{(5)}$ and if so, what does that mean? Moreover, I have to compute the minimal weights, how do I do that?

-

See Floyd-Warshall algorithm here. The matrix is a two-dimensional array $N*N$ where $N$ represents the number of nodes in your graph. When you access your matrix, you provide the start node and the end node and it gets populated with values representing the corresponding distance. In other words if I write: dist[0][1], then I'm writing or reading the distance from node 0 to node 1. Needless to say, if going from node 0 to node 1 is the same thing as going from node 1 to node 0, your matrix is only really going to need half, since you're not going to need to evaluate the distance from node 1 to node 0.