Expand contracted paths back on to full, uncontracted graphs.
Source:R/paths.R
dodgr_paths_expand.RdPaths 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.
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 withvertices = TRUE), or as an integer vector of row indices intograph_c(as returned withvertices = FALSE).pathsshould generally carry theverticesattribute 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-NULLpath is used instead. Individual paths which areNULLor which trace no transitions are ignored.- graph
The full, uncontracted graph from which
graph_cwas generated with dodgr_contract_graph.- graph_c
The contracted graph on which
pathswas 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)