Description Usage Arguments Value Examples
Obtain a list of all possible paths from a given node within a directed graph
1 2 
graph 
a graph object of class

from 
the node from which all paths will be determined. 
to 
the node to which all paths will be determined. 
shortest_path 
an option to return paths that are the shortest in the set of all determined paths. 
longest_path 
an option to return paths that are the longest in the set of all determined paths. 
distance 
a vector of integer values that specify which of the valid paths to return when filtering by distance. 
a list of paths, sorted by ascending traversal length, comprising vectors of node IDs in sequence of traversal through the graph.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69  # Create a simple graph
graph <
create_graph() %>%
add_n_nodes(8) %>%
add_edge(1, 2) %>%
add_edge(1, 3) %>%
add_edge(3, 4) %>%
add_edge(3, 5) %>%
add_edge(4, 6) %>%
add_edge(2, 7) %>%
add_edge(7, 5) %>%
add_edge(4, 8)
# Get a list of all paths outward from node `1`
get_paths(graph, from = 1)
#> [[1]]
#> [1] 1 3 5
#>
#> [[2]]
#> [1] 1 2 7 5
#>
#> [[3]]
#> [1] 1 3 4 6
#>
#> [[4]]
#> [1] 1 3 4 8
# Get a list of all paths leading to node `6`
get_paths(graph, to = 6)
#> [[1]]
#> [1] 1 3 4 6
# Get a list of all paths from `1` to `5`
get_paths(graph, from = 1, to = 5)
#> [[1]]
#> [1] 1 3 5
#>
#> [[2]]
#> [1] 1 2 7 5
# Get a list of all paths from `1` up to a distance
# of 2 node traversals
get_paths(graph, from = 1, distance = 2)
#> [[1]]
#> [1] 1 3 5
#>
#> [[2]]
#> [1] 1 2 7
#>
#> [[3]]
#> [1] 1 3 4
# Get a list of the shortest paths from `1` to `5`
get_paths(
graph,
from = 1,
to = 5,
shortest_path = TRUE)
#> [[1]]
#> [1] 1 3 5
# Get a list of the longest paths from `1` to `5`
get_paths(
graph,
from = 1,
to = 5,
longest_path = TRUE)
#> [[1]]
#> [1] 1 2 7 5

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.