to_df: Convert cppRouting graph to data.frame

View source: R/to_df.R

to_dfR Documentation

Convert cppRouting graph to data.frame

Description

Convert cppRouting graph to data.frame

Usage

to_df(Graph, aux = FALSE, capacity = FALSE, alpha = FALSE, beta = FALSE)

Arguments

Graph

An object generated by cppRouting::makegraph() or cpp_simplify() function.

aux

logical. If TRUE, append the graph's aux weight(s), when present (a plain vector becomes a column named aux; a named data.frame keeps its own column names). Silently ignored if the graph has no aux.

capacity

logical. If TRUE, append the graph's capacity, when present. Silently ignored if the graph has no capacity.

alpha

logical. If TRUE, append the graph's alpha, when present. Silently ignored if the graph has no alpha.

beta

logical. If TRUE, append the graph's beta, when present. Silently ignored if the graph has no beta.

Value

Data.frame with from, to and dist column, plus any of aux/capacity/alpha/beta requested.

Examples

#Simple directed graph

edges<-data.frame(from=c(1,2,3,4,5,6,7,8),
to=c(0,1,2,3,6,7,8,5),
dist=c(1,1,1,1,1,1,1,1))

#Construct cppRouting graph
graph<-makegraph(edges,directed=TRUE)

#Convert cppRouting graph to data.frame

df<-to_df(graph)

cppRouting documentation built on Nov. 12, 2026, 5:11 p.m.