get_isochrone {cppRouting} | R Documentation |
Compute isochrones/isodistances from nodes.
Description
Compute isochrones/isodistances from nodes.
Usage
get_isochrone(Graph, from, lim, setdif = FALSE, keep = NULL, long = FALSE)
Arguments
Graph |
An object generated by makegraph or cpp_simplify function. |
from |
numeric or character. A vector of one or more vertices from which isochrones/isodistances are calculated. |
lim |
numeric. A vector of one or multiple breaks. |
setdif |
logical. If |
keep |
numeric or character. Vertices of interest that will be returned. |
long |
logical. If |
Details
If length(lim) > 1
, value is a list
of length(from)
, containing list
s of length(lim)
.
All algorithms are multithreaded. Please use RcppParallel::setThreadOptions()
to set the number of threads.
For large graph, keep
argument can be used for saving memory.
Value
list
or a data.frame
containing reachable nodes below cost limit(s).
Note
get_isochrone()
recursively perform Dijkstra algorithm for each from
nodes and stop when cost limit is reached.
Examples
#Choose number of cores used by cppRouting
RcppParallel::setThreadOptions(numThreads = 1)
#Data describing edges of the graph
edges<-data.frame(from_vertex=c(0,0,1,1,2,2,3,4,4),
to_vertex=c(1,3,2,4,4,5,1,3,5),
cost=c(9,2,11,3,5,12,4,1,6))
#Construct directed graph
directed_graph<-makegraph(edges,directed=TRUE)
#Get nodes reachable around node 4 with maximum distances of 1 and 2
iso<-get_isochrone(Graph=directed_graph,from = "4",lim=c(1,2))
#With setdif set to TRUE
iso2<-get_isochrone(Graph=directed_graph,from = "4",lim=c(1,2),setdif=TRUE)
print(iso)
print(iso2)