Something went wrong. Try again.
Distances on Directed Graphs in R
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520# Generated by using Rcpp::compileAttributes() -> do not edit by hand# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' rcpp_centrality - parallel function#'#' sample is used to estimate timing, by calculating centrality from just a few#' vertices.#' @noRdrcpp_centrality <- function(graph, vert_map_in, heap_type, dist_threshold, edge_centrality, sample) { .Call(`_dodgr_rcpp_centrality`, graph, vert_map_in, heap_type, dist_threshold, edge_centrality, sample)}
#' rcpp_concaveman#' @noRd rcpp_concaveman <- function(xy, hull_in, concavity, length_threshold) { .Call(`_dodgr_rcpp_concaveman`, xy, hull_in, concavity, length_threshold)}
#' De-duplicate edges by replacing with minimal weighted distances and times#'#' @param graph Full graph in any form#' @param fr_col Name of column holding from edge labels#' @param to_col Name of column holding to edge labels#' @param d_col Name of column holding weighted distances#' @param t_col Name of column holding weighted times (or "" if no weighted#' times).#' @return A `data.frame` of 3 columns: 'from', 'to', and 'd', where 'd' is the#' minimal value taken from all duplicated edges. If 't_col' is specified, the#' equivalent minimal times are in the lower half of the result.#' @noRdrcpp_deduplicate <- function(graph, fr_col, to_col, d_col, t_col) { .Call(`_dodgr_rcpp_deduplicate`, graph, fr_col, to_col, d_col, t_col)}
#' Make unordered_set of all new edge names#' @noRdNULL
#' Make vector of all new edge names#' @noRdNULL
#' Get numbers of old edges corresponding to each contracted edge#' @noRdNULL
#' Collect sets of all from and to vertices for each set of edges corresponding#' to each contracted edge. These sets aren't in any particular order, but the#' two sets may be used to match the from and to vertices. These sets are then#' arranged into sequences in the subsequent function,#' \code{order_vert_sequences}.#' @noRdNULL
#' rcpp_aggregate_to_sf#'#' Aggregate a dodgr network data.frame to an sf LINESTRING data.frame#'#' @param graph_full Rcpp::DataFrame containing the **full** graph#' @param graph_contr Rcpp::DataFrame containing the **contracted** graph#' @param edge_map Rcpp::DataFrame containing the edge map returned from#' \code{dodgr_contract_graph}#'#' @return Rcpp::List object of `sf::LINESTRING` geoms#'#' @noRdrcpp_aggregate_to_sf <- function(graph_full, graph_contr, edge_map) { .Call(`_dodgr_rcpp_aggregate_to_sf`, graph_full, graph_contr, edge_map)}
#' rcpp_flows_aggregate_par#'#' @param graph The data.frame holding the graph edges#' @param vert_map_in map from <std::string> vertex ID to (0-indexed) integer#' index of vertices#' @param fromi Index into vert_map_in of vertex numbers#' @param toi Index into vert_map_in of vertex numbers#' @param tol Relative tolerance in terms of flows below which targets#' (to-vertices) are not considered.#'#' @note The parallelisation is achieved by dumping the results of each thread#' to a file, with aggregation performed at the end by simply reading back and#' aggregating all files. There is no way to aggregate into a single vector#' because threads have to be independent. The only danger with this approach#' is that multiple threads may generate the same file names, but with names 10#' characters long, that chance should be 1 / 62 ^ 10.#'#' @noRdrcpp_flows_aggregate_par <- function(graph, vert_map_in, fromi, toi_in, flows, norm_sums, tol, heap_type) { .Call(`_dodgr_rcpp_flows_aggregate_par`, graph, vert_map_in, fromi, toi_in, flows, norm_sums, tol, heap_type)}
#' rcpp_flows_aggregate_pairwise#'#' Pairwise version of flows_aggregate_par#'#' @param graph The data.frame holding the graph edges#' @param vert_map_in map from <std::string> vertex ID to (0-indexed) integer#' index of vertices#' @param fromi Index into vert_map_in of vertex numbers#' @param toi Index into vert_map_in of vertex numbers#' @param tol Relative tolerance in terms of flows below which targets#' (to-vertices) are not considered.#'#' @note The parallelisation is achieved by dumping the results of each thread#' to a file, with aggregation performed at the end by simply reading back and#' aggregating all files. There is no way to aggregate into a single vector#' because threads have to be independent. The only danger with this approach#' is that multiple threads may generate the same file names, but with names 10#' characters long, that chance should be 1 / 62 ^ 10.#'#' @noRdrcpp_flows_aggregate_pairwise <- function(graph, vert_map_in, fromi, toi, flows, norm_sums, tol, heap_type) { .Call(`_dodgr_rcpp_flows_aggregate_pairwise`, graph, vert_map_in, fromi, toi, flows, norm_sums, tol, heap_type)}
#' rcpp_flows_disperse_par#'#' Modified version of \code{rcpp_flows_aggregate} that aggregates flows to all#' destinations from given set of origins, with flows attenuated by distance#' from those origins.#'#' @param graph The data.frame holding the graph edges#' @param vert_map_in map from <std::string> vertex ID to (0-indexed) integer#' index of vertices#' @param fromi Index into vert_map_in of vertex numbers#' @param k Coefficient of (current proof-of-principle-only) exponential#' distance decay function. If value of \code{k<0} is given, a standard#' logistic polynomial will be used.#'#' @note The flow data to be used for aggregation is a matrix mapping flows#' between each pair of from and to points.#'#' @noRdrcpp_flows_disperse_par <- function(graph, vert_map_in, fromi, k, dens, tol, heap_type) { .Call(`_dodgr_rcpp_flows_disperse_par`, graph, vert_map_in, fromi, k, dens, tol, heap_type)}
#' rcpp_flows_si#'#' @param graph The data.frame holding the graph edges#' @param vert_map_in map from <std::string> vertex ID to (0-indexed) integer#' index of vertices#' @param fromi Index into vert_map_in of vertex numbers#' @param toi Index into vert_map_in of vertex numbers#' @param kvec Vector of k-values for each fromi#' @param nvec Vector of density-values for each fromi#' @param tol Relative tolerance in terms of flows below which targets#' (to-vertices) are not considered.#'#' @noRdrcpp_flows_si <- function(graph, vert_map_in, fromi, toi_in, kvec, dens_from, dens_to, norm_sums, tol, heap_type) { .Call(`_dodgr_rcpp_flows_si`, graph, vert_map_in, fromi, toi_in, kvec, dens_from, dens_to, norm_sums, tol, heap_type)}
#' @noRdrcpp_fundamental_cycles <- function(graph, verts) { .Call(`_dodgr_rcpp_fundamental_cycles`, graph, verts)}
#' get_to_from#'#' Get one pair of two and from edges and vertices. Main task is to make sure#' that bi-directed edges ("intermediate_double") correctly return the#' **different** values of from and to vertices and edges.#'#' @noRdNULL
#' same_hwy_type#'#' Determine whether two edges represent the same weight category (type of#' highway for street networks, for example). Categories are not retained in #' converted graphs, but can be discerned by comparing ratios of weighted to#' non-weighted distances.#' @noRdNULL
#' rcpp_contract_graph#'#' Removes nodes and edges from a graph that are not needed for routing#'#' @param graph graph to be processed#'#' @return \code{Rcpp::List} containing one \code{data.frame} with the#' contracted graph, one \code{data.frame} with the original graph and one#' \code{data.frame} containing information about the relating edge ids of the#' original and contracted graph.#'#' @noRdrcpp_contract_graph <- function(graph, vertlist_in) { .Call(`_dodgr_rcpp_contract_graph`, graph, vertlist_in)}
#' rcpp_merge_cols#'#' Merge columns in directed graph to form aggregate undirected columns, and#' return a corresponding undirected graph useful for visualisation.#'#' @param graph The result of a call to \code{dodgr_flows_aggregate/disperse}#' or similar function resuling in columns of directed values.#' @return A single vector of aggregate values with non-zero values only for#' those edges to be retained in the directed graph.#'#' @noRdrcpp_merge_cols <- function(graph) { .Call(`_dodgr_rcpp_merge_cols`, graph)}
#' sample_one_edge_no_comps#'#' Sample one edge for graph that has no pre-calculated components. Only used#' in \code{sample_one_vertex}#'#' @param edge_map edge_map#' @return std::vector of 2 elements: [0] with value of largest connected #' component; [1] with random index to one edge that is part of that component.#' @noRdNULL
#' sample_one_edge_with_comps#'#' Sample one edge for graph that has pre-calculated components. Only used in#' \code{sample_one_vertex}#'#' @param edge_map edge_map#' @return Random index to one edge that is part of the largest connected#' component.#' @noRdNULL
#' rcpp_sample_graph#'#' Randomly sample one connected componnent of a graph#'#' @param graph graph to be processed#' @param nverts_to_sample Number of vertices to sample#' @param quiet If TRUE, display progress#'#' @return Smaller sub-set of \code{graph}#'#' @noRdrcpp_sample_graph <- function(graph, nverts_to_sample) { .Call(`_dodgr_rcpp_sample_graph`, graph, nverts_to_sample)}
#' graph_has_components#'#' Does a graph have a vector of connected component IDs? Only used in#' \code{sample_one_vertex}#' @noRdNULL
#' @name graph_from_df#'#' Convert a standard graph data.frame into an object of class graph. Graphs #' are standardised with the function \code{dodgr_convert_graph()$graph}, and#' contain only the four columns [from, to, d, w]#'#' @noRdNULL
#' identify_graph_components#'#' Identify initial graph components for each **vertex**#' Identification for edges is subsequently performed with #' \code{rcpp_get_component_vector}.#'#' @param v unordered_map <vertex_id_t, vertex_t>#' @param com component map from each vertex to component numbers#' @noRdNULL
#' strong_connect#'#' Helper function for applying Tarjan's algroithm to identify#' strong components recursively#'#' @param vt id of vertex currently being evaluated#' @param v unordered_map <vertex_id_t, vertex_t>#' @param com component map from each vertex to component numbers#' @param index_map map from each vertex to index number#' @param lowlink_map map from each vertex to lowlink number#' @param on_stack set of all vertices currently on stack#' @param s stack used to execute algorithm#' @param index used to execute algoritm#' @param compnum the current component number#' @noRdNULL
#' identify_graph_strong_components#'#' Identify initial graph strong components for each **vertex**#' Identification for edges is subsequently performed with #' \code{rcpp_get_component_vector}.#'#' @param v unordered_map <vertex_id_t, vertex_t>#' @param com component map from each vertex to component numbers#' @noRdNULL
#' rcpp_get_component_vector#'#' Get component numbers for each edge of graph#'#' @param graph graph to be processed; stripped down and standardised to five#' columns#'#' @param strong A Boolean flag to indicate whether components should be strong,#' i.e. its vertices connected bidirectionally. Defaults to FALSE.#'#' @return Two vectors: one of edge IDs and one of corresponding component#' numbers#' @noRdrcpp_get_component_vector <- function(graph, strong = FALSE) { .Call(`_dodgr_rcpp_get_component_vector`, graph, strong)}
#' rcpp_unique_rownames#'#' Construct vertex (from, to) ID values from unique pairs of coordinates#' rounded to <precision>. Used when vertices have no ID values.#'#' @noRdrcpp_unique_rownames <- function(xyfrom, xyto, precision = 10L) { .Call(`_dodgr_rcpp_unique_rownames`, xyfrom, xyto, precision)}
#' Determine which side of intersecting line a point lies on.#'#' @param (ax, ay) Coordinates of one end of line#' @param (bx, by) Coordinates of other end of line#' @param (x, y) Coordinates of point#' @return 0 if point on line, -1 if to the left; +1 if to the right.#'#' @noRdNULL
#' Simple match of points to nearest vertices#' @noRdNULL
#' Match points to nearest edge of graph at which perpendicular from point#' bisects edges. Uses psuedo-code from#' https://stackoverflow.com/a/6853926#' @noRdNULL
#' rcpp_points_index_par#'#' Get index of nearest vertices to list of points#'#' @param xy Rcpp::DataFrame containing the vertex coordinates of the graph#' @param pts Rcpp::DataFrame containing the points to be matched#'#' @return 0-indexed Rcpp::NumericVector index into graph of nearest points#'#' @noRdrcpp_points_index_par <- function(xy, pts) { .Call(`_dodgr_rcpp_points_index_par`, xy, pts)}
#' rcpp_points_to_edges_par#'#' Get index of nearest edges to list of points#'#' @param graph Rcpp::DataFrame containing the full edge-based graph#' @param pts Rcpp::DataFrame containing the points to be matched#'#' @return 0-indexed Rcpp::NumericVector index into graph of nearest points#'#' @noRdrcpp_points_to_edges_par <- function(graph, pts) { .Call(`_dodgr_rcpp_points_to_edges_par`, graph, pts)}
#' rcpp_get_sp_dists_par#'#' @noRdrcpp_get_sp_dists_par <- function(graph, vert_map_in, fromi, toi_in, heap_type, is_spatial) { .Call(`_dodgr_rcpp_get_sp_dists_par`, graph, vert_map_in, fromi, toi_in, heap_type, is_spatial)}
#' rcpp_get_sp_dists_nearest#'#' @noRdrcpp_get_sp_dists_nearest <- function(graph, vert_map_in, fromi, toi_in, heap_type) { .Call(`_dodgr_rcpp_get_sp_dists_nearest`, graph, vert_map_in, fromi, toi_in, heap_type)}
#' rcpp_get_sp_dists_paired_par#'#' @noRdrcpp_get_sp_dists_paired_par <- function(graph, vert_map_in, fromi, toi, heap_type, is_spatial, do_bidirectional) { .Call(`_dodgr_rcpp_get_sp_dists_paired_par`, graph, vert_map_in, fromi, toi, heap_type, is_spatial, do_bidirectional)}
#' rcpp_get_iso#'#' @noRdrcpp_get_iso <- function(graph, vert_map_in, fromi, dlim, heap_type) { .Call(`_dodgr_rcpp_get_iso`, graph, vert_map_in, fromi, dlim, heap_type)}
#' rcpp_get_sp_dists#'#' @noRdrcpp_get_sp_dists <- function(graph, vert_map_in, fromi, toi_in, heap_type) { .Call(`_dodgr_rcpp_get_sp_dists`, graph, vert_map_in, fromi, toi_in, heap_type)}
#' rcpp_get_paths#'#' @param graph The data.frame holding the graph edges#' @param vert_map_in map from <std::string> vertex ID to (0-indexed) integer#' index of vertices#' @param fromi Index into vert_map_in of vertex numbers#' @param toi Index into vert_map_in of vertex numbers#'#' @note The graph is constructed with 0-indexed vertex numbers contained in#' code{vert_map_in}. Both \code{fromi} and \code{toi} already map directly#' onto these. The graph has to be constructed by first constructing a#' \code{std::map} object (\code{vertmap}) for \code{vert_map_in}, then#' translating all \code{graph["from"/"to"]} values into these indices. This#' construction is done in \code{inst_graph}.#'#' @note Returns 1-indexed values indexing directly into the R input#'#' @noRdrcpp_get_paths <- function(graph, vert_map_in, fromi, toi_in, heap_type) { .Call(`_dodgr_rcpp_get_paths`, graph, vert_map_in, fromi, toi_in, heap_type)}
rcpp_get_paths_pairwise <- function(graph, vert_map_in, fromi, toi_in, heap_type, is_spatial, do_bidirectional) { .Call(`_dodgr_rcpp_get_paths_pairwise`, graph, vert_map_in, fromi, toi_in, heap_type, is_spatial, do_bidirectional)}
#' rcpp_get_sp_dists_categorical#'#' The `graph` must have an `edge_type` column of non-negative integers,#' with 0 denoting edges which are not aggregated, and all other values#' defining aggregation categories.#'#' Implemented in parallal form only; no single-threaded version, and#' only for AStar (so graphs must be spatial).#' @noRdrcpp_get_sp_dists_categorical <- function(graph, vert_map_in, fromi, toi_in, heap_type, proportions_only) { .Call(`_dodgr_rcpp_get_sp_dists_categorical`, graph, vert_map_in, fromi, toi_in, heap_type, proportions_only)}
#' rcpp_get_sp_dists_categ_paired#'#' Pairwise version of 'get_sp_dists_categorical'. The `graph` must have an#'`edge_type` column of non-negative integers, with 0 denoting edges which are#' not aggregated, and all other values defining aggregation categories.#'#' Implemented in parallal form only; no single-threaded version, and#' only for AStar (so graphs must be spatial).#' @noRdrcpp_get_sp_dists_categ_paired <- function(graph, vert_map_in, fromi, toi_in, heap_type) { .Call(`_dodgr_rcpp_get_sp_dists_categ_paired`, graph, vert_map_in, fromi, toi_in, heap_type)}
#' rcpp_get_sp_dists_cat_threshold#'#' The `graph` must have an `edge_type` column of non-negative integers,#' with 0 denoting edges which are not aggregated, and all other values#' defining aggregation categories.#'#' Implemented in parallal form only; no single-threaded version, and#' only for AStar (so graphs must be spatial).#' @noRdrcpp_get_sp_dists_cat_threshold <- function(graph, vert_map_in, fromi, dlimit, heap_type) { .Call(`_dodgr_rcpp_get_sp_dists_cat_threshold`, graph, vert_map_in, fromi, dlimit, heap_type)}
#' rcpp_gen_hash#'#' Efficient generation of long sequences of hash keys#'#' @noRdrcpp_gen_hash <- function(n, hash_len) { .Call(`_dodgr_rcpp_gen_hash`, n, hash_len)}
#' rcpp_sf_as_network#'#' Return OSM data from Simple Features format input#'#' @param sf_lines An sf collection of LINESTRING objects#' @param pr Rcpp::DataFrame containing the weighting profile#'#' @return Rcpp::List objects of OSM data, one matrix of numeric and one of#' character values. The former contain 7 columns:#' 1. sf geom index#' 2. from longitude#' 3. from latitude#' 4. to longitude#' 5. to latitude#' 6. distance#' 7. weighted_distance#' The character value matrix has 4 columns of:#' 1. from ID#' 2. to ID#' 3. highway type#' 4. OSM way ID#'#' @noRdrcpp_sf_as_network <- function(sf_lines, pr) { .Call(`_dodgr_rcpp_sf_as_network`, sf_lines, pr)}
#' rcpp_route_times#'#' @noRdrcpp_route_times <- function(graph, left_side, turn_penalty) { .Call(`_dodgr_rcpp_route_times`, graph, left_side, turn_penalty)}