View source: R/get_isochrone.R
get_isochrone | R Documentation |
Compute isochrones/isodistances from nodes.
get_isochrone(Graph, from, lim, setdif = FALSE, keep = NULL, long = FALSE)
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 |
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.
list
or a data.frame
containing reachable nodes below cost limit(s).
get_isochrone()
recursively perform Dijkstra algorithm for each from
nodes and stop when cost limit is reached.
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.