A new algorithm to find the shortest paths between all pairs of nodes