Removes redundant (straight-line) vertices from graph, leaving only junction vertices.

dodgr_contract_graph(graph, verts = NULL)

Arguments

graph

A flat table of graph edges. Must contain columns labelled from and to, or start and stop. May also contain similarly labelled columns of spatial coordinates (for example from_x) or stop_lon).

verts

Optional list of vertices to be retained as routing points. These must match the from_id and to_id columns of graph.

Value

A list of two items: graph containing contracted version of the original graph, converted to a standardised format, and edge_map, a two-column matrix mapping all newly contracted edges onto corresponding edges in original (uncontracted) graph.

Examples

graph <- weight_streetnet (hampi) nrow (graph) # 5,729
#> [1] 5845
graph <- dodgr_contract_graph (graph) nrow (graph$graph) # 764
#> [1] 786