Consider the adjacency matrix A for graph G, which contains vertices v_i and v_j. Then, A_i,j is the number of paths directly connecting v_i and v_j, and more generally by theorem 2, the i,j entry of A^r ("(A^r)_i,j") is the number of paths of length r connecting v_i and v_j.
If (A^r)_i,j = 0, then there are no paths of length r connecting v_i and v_j. So, our shortest path is the smallest r such that (A^r)_i,j > 0. (For all k < r, (A^k)_i,j = 0, and so there is no path of length k connecting v_i and v_j.)
More math symbol-y, the minimum path length p is: $ p = min( \{r | (A^r)_{i,j} > 0, r \in \mathbb{N} \} ) $
-Brian (Thomas34 01:20, 13 November 2008 (UTC))