floyd {KODAMA}R Documentation

Find Shortest Paths Between All Nodes in a Graph

Description

The floyd function finds all shortest paths in a graph using Floyd's algorithm.

Usage

floyd(data)

Arguments

data

matrix or distance object

Value

floyd returns a matrix with the total lengths of the shortest path between each pair of points.

References

Floyd, Robert W
Algorithm 97: Shortest Path.
Communications of the ACM 1962; 5 (6): 345. doi:10.1145/367766.368168.

Examples

# 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)


[Package KODAMA version 2.4 Index]