floyd function finds all shortest paths in a graph using Floyd's algorithm.
matrix or distance object
floyd returns a matrix with the total lengths of the shortest path between each pair of points.
Floyd, Robert W
Algorithm 97: Shortest Path.
Communications of the ACM 1962; 5 (6): 345. doi:10.1145/367766.368168.
# build a graph with 5 nodes x=matrix(c(0,NA,NA,NA,NA,30,0,NA,NA,NA,10,NA,0,NA,NA,NA,70,50,0,10,NA,40,20,60,0),ncol=5) print(x) # compute all path lengths z=floyd(x) print(z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.