dodgr_paths_expand: Expand contracted paths back on to full, uncontracted graphs.

dodgr_paths_expandR Documentation

Expand contracted paths back on to full, uncontracted graphs.

Description

Paths calculated with dodgr_paths on graphs contracted with dodgr_contract_graph trace and return only the intervening junction vertices. This function expands contracted paths back onto full sequences of edges of original, uncontracted graphs.

Usage

dodgr_paths_expand(paths, graph, graph_c, edge_map = NULL)

Arguments

paths

A nested list of paths between pairs of (origin, destination) points, generated by dodgr_paths on a graph previously contracted with dodgr_contract_graph, so that paths [[i]] [[j]] is the path between the i-th origin and j-th destination points. Each individual path may be given either as a character vector of vertex IDs (as returned by dodgr_paths with vertices = TRUE), or as an integer vector of row indices into graph_c (as returned with vertices = FALSE). paths should generally carry the vertices attribute attached by dodgr_paths, used here to determine the type of the return value (see 'Value' below); if that attribute is absent, the type of the first non-NULL path is used instead. Individual paths which are NULL or which trace no transitions are ignored.

graph

The full, uncontracted graph from which graph_c was generated with dodgr_contract_graph.

graph_c

The contracted graph on which paths was calculated.

edge_map

Optional edge map generated internally by dodgr_contract_graph, and used to map contracted edges back on to their corresponding sequences of edges in graph. If not given, this is extracted directly from the dodgr cache.

Value

A nested list of the same structure as paths, in which result [[i]] [[j]] is the expansion of paths [[i]] [[j]] on to the full, uncontracted sequence of edges of graph, ordered from start to end of that path. Each expanded path is returned in a form structurally identical to the corresponding input: a character vector of vertex IDs from graph if paths [[i]] [[j]] was itself a character vector (that is, if paths was generated with vertices = TRUE), or an integer vector of row indices into graph if paths [[i]] [[j]] was an integer vector (vertices = FALSE). Entries for which the corresponding input path is NULL or has no transitions are returned as NULL. The result also carries the same vertices attribute as paths.

See Also

Other distances: dodgr_distances(), dodgr_dists(), dodgr_dists_categorical(), dodgr_dists_nearest(), dodgr_paths(), dodgr_times()

Examples

graph <- weight_streetnet (hampi)
graph_c <- dodgr_contract_graph (graph)
verts <- dodgr_vertices (graph_c)
from <- verts$id [1]
to <- verts$id [nrow (verts)]
paths_c <- dodgr_paths (graph_c, from = from, to = to)
paths <- dodgr_paths_expand (paths_c, graph, graph_c)

dodgr documentation built on Sept. 3, 2026, 5:08 p.m.