Search code examples
algorithmfloyd-warshall

Floyd's Algorithm Explanation


Concerning

floyds(int a[][100],int n).

What does 'a' and represent and what does each of the two dimensions of a represent?

What does 'n' represent?

I have a list of locations, with a list of connections between those locations and have computed the distance between those connections that are connect to each other. Now I need to find shortest path between any given two locations (floyd's) - but need to understand how to apply floyds(int a[][100],int n) to my locations array, city dictionaries, and connection arrays.

FYI - Using objective C - iOS.


Solution

  • n is the number of nodes in the graph.

    a is an distance matrix of the graph. a[i][j] is the cost (or distance) of the edge from node i to node j.

    (Also read the definition of adjacency matrix if you need more help with the concept.)