get_shortest_paths()
returns a single shortest path per vertex pair,
while the variant with _all_
returns all found paths.
The variant with _simple_
removes paths with cycles.
The results should be the same for simple graphs like trees, but the order of
the paths may differ.
Arguments
- graph
An
igraph_ptr
object.- from
An integer vector of vertex IDs.
- to
An integer vector of vertex IDs.
- weights
A numeric vector of edge weights;
TRUE
to useEattr(graph, "weight")
.- mode
An integer value of edge type to count; {1: OUT, 2: IN, 3: ALL}.
- cutoff
integer
Examples
g = graph_tree(5L)
vsource = Vsource(g)
vsink = Vsink(g)
get_shortest_paths(g, vsource, vsink, mode = 1L)
#> [[1]]
#> [1] 1 3
#>
#> [[2]]
#> [1] 1 2 4
#>
#> [[3]]
#> [1] 1 2 5
#>
get_all_shortest_paths(g, vsource, vsink, mode = 1L)
#> [[1]]
#> [1] 1 3
#>
#> [[2]]
#> [1] 1 2 4
#>
#> [[3]]
#> [1] 1 2 5
#>
get_all_simple_paths(g, vsource, vsink, mode = 1L)
#> [[1]]
#> [1] 1 2 4
#>
#> [[2]]
#> [1] 1 2 5
#>
#> [[3]]
#> [1] 1 3
#>