Solves shortest path problem of adjacency matrix of n vertices