Get Shortest Path Between Two Vertices
Usage
get.shortest.path(path.result, from, to)
Arguments
- path.result
A "path.graph" object.
- from
Source vertex.
- to
Target vertex.
Value
A list with path (vertex indices in requested direction), length
and hops, or NULL when no stored route exists within this result's
hop limit. A vertex queried against itself has path from, length zero
and zero hops. Routes can be retrieved in either direction.
Examples
graph <- list(2L, c(1L, 3L), 2L)
lengths <- list(1, c(1, 2), 2)
pg <- create.path.graph(dgraph(graph, lengths), h.values = 2)[[1L]]
get.shortest.path(pg, from = 1, to = 3)
#> $path
#> [1] 1 2 3
#>
#> $length
#> [1] 3
#>
#> $hops
#> [1] 2
#>