shortest path python adjacency matrix