matrix algo for shortest path between two nodes updated