Removes redundant (straight-line) vertices from graph, leaving only junction vertices.
Arguments
- graph
A flat table of graph edges. Must contain columns labelled
from
andto
, orstart
andstop
. May also contain similarly labelled columns of spatial coordinates (for examplefrom_x
) orstop_lon
).- verts
Optional list of vertices to be retained as routing points. These must match the
from
andto
columns ofgraph
.- nocache
If
FALSE
(default), load cached version of contracted graph if previously calculated and cached. IfTRUE
, then re-contract graph even if previously calculated version has been stored in cache.
Value
A contracted version of the original graph
, containing the same
number of columns, but with each row representing an edge between two
junction vertices (or between the submitted verts
, which may or may not be
junctions).
See also
Other modification:
dodgr_components()
,
dodgr_uncontract_graph()
Examples
graph <- weight_streetnet (hampi)
nrow (graph) # 5,973
#> [1] 6813
graph <- dodgr_contract_graph (graph)
nrow (graph) # 662
#> [1] 744