I am learning the way of computing Path Matrix from Adjacency Matrix(say AM1).
A Path Matrix of a graph G with n vertices is a Boolean n*n matrix whose elements can be defined as:
p[i][j]=1(if there is a path from i to j)
p[i][j]=0(otherwise)
And the steps i learned is as follows:
If we multiply an adjacency matrix A[][] by itself we get A^2(say AM2) whose each vertex A[i][j] basically represents the number of paths of path length 2 from i to j.
Similarly,If we multiply an adjacency matrix 3 times i.e we get A^3(say AM3) whose each vertex A[i][j] basically represents the number of paths of path length 3 from i to j.. and so on.
Now we define a Matrix X such that:
X=AM1+AM2+AM3...AMn (Where n is the number of vertices)
From this X matrix we compute the path/reach ability matrix by replacing all non-zero vertices by 1.
What i am unable to grasp is how does replacing all non-zero vertices by 1 gives us the path matrix.?. And why we calculate or add all the matrix up to AMn.?.
I understand that X[i][j] symbolizes number of paths, of path length n or less than n,from i to j,But why do we calculate only until n,not more or less?
Please explain!