GraphDistanceMatrix[g] gives a matrix in which the entry is the length of a shortest path in g between vertices i and j.
returns a three-dimensional matrix in which the entry is the length of a shortest path from i to j and the entry is the predecessor of j in a shortest path from i to j.