Computes the matrix of minimum-weight distances between every from node and
every to node (Rust core; one Dijkstra per source).
Arguments
- g
An osm_graph.
- from
Node
osmids for the matrix rows.- to
Node
osmids for the matrix columns. Defaults tofrom.- weight
Edge column used as weight. Default
"length".
Value
A numeric matrix (length(from) x length(to)) with osmid
dimnames; Inf marks unreachable pairs.
Examples
g <- example_osm_graph(n = 3)
nodes <- g$nodes$osmid
ox_distance_matrix(g, from = nodes[1:2], to = nodes[3:4])
#> 3 4
#> 1 200 100
#> 2 100 200