#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))
# Origin-destination trips
trips <- data.frame(from = c(0,0,0,0,1,1,1,1,2,2,2,3,3,4,5,5,5,5,5),
to = c(1,2,5,3,2,5,2,4,2,5,2,3,5,2,0,0,3,5,1),
flow = c(10,30,15,5,5,2,3,6,4,15,20,2,3,6,2,1,4,5,3))
#Construct graph
graph<-makegraph(edges,directed=TRUE)
# Compute All-or-Nothing assignment
aon <- get_aon(Graph=graph, from=trips$from, to=trips$to, demand = trips$flow, algorithm = "d")
print(aon)
Run the code above in your browser using DataLab