Learn R Programming

dodgr (version 0.1.1)

dodgr_flows_aggregate: dodgr_flows_aggregate

Description

Aggregate flows throughout a network based on an input matrix of flows between all pairs of from and to points.

Usage

dodgr_flows_aggregate(graph, from, to, flows, wt_profile = "bicycle",
  contract = FALSE, heap = "BHeap", quiet = TRUE)

Arguments

graph

data.frame or equivalent object representing the network graph (see Details)

from

Vector or matrix of points **from** which aggregate flows are to be calculated (see Details)

to

Vector or matrix of points **to** which aggregate flows are to be calculated (see Details)

flows

Matrix of flows with nrow(flows)==length(from) and ncol(flows)==length(to).

wt_profile

Name of weighting profile for street networks (one of foot, horse, wheelchair, bicycle, moped, motorcycle, motorcar, goods, hgv, psv; only used if graph is not provided, in which case a street network is downloaded and correspondingly weighted).

contract

If TRUE, calculate flows on contracted graph before mapping them back on to the original full graph (recommended as this will generally be much faster).

heap

Type of heap to use in priority queue. Options include Fibonacci Heap (default; FHeap), Binary Heap (BHeap), Radix, Trinomial Heap (TriHeap), Extended Trinomial Heap (TriHeapExt, and 2-3 Heap (Heap23).

quiet

If FALSE, display progress messages on screen.

Value

Modified version of graph with additonal flow column added.

Examples

Run this code
# NOT RUN {
graph <- weight_streetnet (hampi)
from <- sample (graph$from_id, size = 10)
to <- sample (graph$to_id, size = 5)
to <- to [!to %in% from]
flows <- matrix (10 * runif (length (from) * length (to)),
                 nrow = length (from))
graph <- dodgr_flows_aggregate (graph, from = from, to = to, flows = flows)
# graph then has an additonal 'flows` column of aggregate flows along all
# edges. These flows are directed, and can be aggregated to equivalent
# undirected flows on an equivalent undirected graph with:
graph_undir <- merge_directed_flows (graph)
# This graph will only include those edges having non-zero flows, and so:
nrow (graph); nrow (graph_undir) # the latter is much smaller
# }

Run the code above in your browser using DataLab