| ox_k_shortest_paths | R Documentation |
Computes up to k loopless shortest paths from from to to using Yen's
algorithm in the Rust core. Useful for route alternatives.
ox_k_shortest_paths(g, from, to, k = 3, weight = "length")
g |
An osm_graph. |
from, to |
Node |
k |
Number of paths to return. Default |
weight |
Edge column used as weight. Default |
A tibble with one row per path: rank, cost and
a list-column path of node osmids, ordered by increasing cost. Fewer
than k rows are returned when fewer distinct paths exist.
g <- example_osm_graph()
from <- ox_nearest_nodes(g, 0, 0)
to <- ox_nearest_nodes(g, 200, 200)
ox_k_shortest_paths(g, from, to, k = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.