Skip to contents

Computes the minimum-weight path from from to to using Dijkstra's algorithm in the Rust core.

Usage

ox_shortest_path(g, from, to, weight = "length")

Arguments

g

An osm_graph.

from, to

Node osmids (as returned by ox_nearest_nodes()).

weight

Edge column used as weight. Default "length".

Value

A vector of node osmids describing the path (length 0 if the target is unreachable).

Examples

g <- example_osm_graph()
from <- ox_nearest_nodes(g, 0, 0)
to <- ox_nearest_nodes(g, 300, 300)
ox_shortest_path(g, from, to)
#> [1]  1  5  9 13 14 15 16