| floyd | R Documentation |
The Floyd-Warshall algorithm finds all shortest paths (if exist) in a directed graph.
floyd(x)
x |
adjacency matrix of a directed graph. |
Returns a list with final costs and the shortest path between two nodes.
Floyd, R.W. (1962). Algorithm 97: Shortest Path. Communications of the ACM 5 (6), 345.
x <- matrix(c(0,3,Inf,5,2,0,Inf,4,Inf,1,0,Inf,Inf,Inf,2,0), nrow = 4,
ncol = 4, byrow = TRUE)
z <- floyd(x)
z
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.