Skip to content

Commit

Permalink
rename dists_proportional -> dists_categorical for #144
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 4, 2021
1 parent cee3a4b commit 776149f
Show file tree
Hide file tree
Showing 14 changed files with 78 additions and 172 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dodgr
Title: Distances on Directed Graphs
Version: 0.2.10.010
Version: 0.2.10.011
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre")),
person("Andreas", "Petutschnig", role = "aut"),
Expand Down
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by roxygen2: do not edit by hand

S3method(summary,dodgr_dists_proportional)
S3method(summary,dodgr_dists_categorical)
S3method(weight_streetnet,default)
S3method(weight_streetnet,sc)
S3method(weight_streetnet,sf)
Expand All @@ -14,7 +14,7 @@ export(dodgr_components)
export(dodgr_contract_graph)
export(dodgr_distances)
export(dodgr_dists)
export(dodgr_dists_proportional)
export(dodgr_dists_categorical)
export(dodgr_flowmap)
export(dodgr_flows_aggregate)
export(dodgr_flows_disperse)
Expand Down
12 changes: 6 additions & 6 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ rcpp_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_sp_dists_proportional
#' 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
Expand All @@ -308,11 +308,11 @@ rcpp_get_paths <- function(graph, vert_map_in, fromi, toi_in, heap_type) {
#' Implemented in parallal form only; no single-threaded version, and
#' only for AStar (so graphs must be spatial).
#' @noRd
rcpp_get_sp_dists_proportional <- function(graph, vert_map_in, fromi, toi_in, heap_type, proportions_only) {
.Call(`_dodgr_rcpp_get_sp_dists_proportional`, graph, vert_map_in, fromi, toi_in, heap_type, proportions_only)
rcpp_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_prop_threshold
#' 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
Expand All @@ -321,8 +321,8 @@ rcpp_get_sp_dists_proportional <- function(graph, vert_map_in, fromi, toi_in, he
#' Implemented in parallal form only; no single-threaded version, and
#' only for AStar (so graphs must be spatial).
#' @noRd
rcpp_get_sp_dists_prop_threshold <- function(graph, vert_map_in, fromi, dlimit, heap_type) {
.Call(`_dodgr_rcpp_get_sp_dists_prop_threshold`, graph, vert_map_in, fromi, dlimit, heap_type)
rcpp_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
Expand Down
24 changes: 12 additions & 12 deletions R/dists-proportional.R → R/dists-categorical.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#' Proportional distances along different edge categories
#' Cumulative distances along different edge categories
#'
#' @inheritParams dodgr_dists
#' @param graph `data.frame` or equivalent object representing the network
#' graph which must have a column named "edge_type" which labels categories of
#' edge types along which proportional distances are to be aggregated (see
#' edge types along which categorical distances are to be aggregated (see
#' Note).
#' @param proportions_only If `FALSE`, return full distance matrices for full
#' @param proportions_only If `FALSE`, return distance matrices for full
#' distances and for each edge category; if `TRUE`, return single vector of
#' proportional distances, like current `summary` function applied to full
#' proportional distances, like the `summary` function applied to full
#' results. See Note.
#' @param dlimit If `TRUE`, and no value to `to` is given, distances are
#' aggregated from each `from` point out to the specified distance limit (in
Expand All @@ -33,7 +33,7 @@
#' calculations which would otherwise require distance matrices too large to be
#' directly stored.
#' @export
dodgr_dists_proportional <- function (graph,
dodgr_dists_categorical <- function (graph,
from = NULL,
to = NULL,
proportions_only = FALSE,
Expand Down Expand Up @@ -62,7 +62,7 @@ dodgr_dists_proportional <- function (graph,
}
is_spatial <- is_graph_spatial (graph)
if (!is_spatial)
stop ("proportional distances only implemented for spatial graphs")
stop ("Categorical distances only implemented for spatial graphs")

vert_map <- make_vert_map (graph, gr_cols, is_spatial)

Expand All @@ -83,7 +83,7 @@ dodgr_dists_proportional <- function (graph,

if (is.null (dlimit) & !is.null (to)) {

d <- rcpp_get_sp_dists_proportional (graph,
d <- rcpp_get_sp_dists_categorical (graph,
vert_map,
from_index$index,
to_index$index,
Expand Down Expand Up @@ -121,7 +121,7 @@ dodgr_dists_proportional <- function (graph,
names (d) <- names (edge_type_table)

res <- c (d0, d)
class (res) <- append (class (res), "dodgr_dists_proportional")
class (res) <- append (class (res), "dodgr_dists_categorical")

} else {

Expand All @@ -132,7 +132,7 @@ dodgr_dists_proportional <- function (graph,
}
} else {

d <- rcpp_get_sp_dists_prop_threshold (graph,
d <- rcpp_get_sp_dists_cat_threshold (graph,
vert_map,
from_index$index,
dlimit,
Expand All @@ -153,13 +153,13 @@ dodgr_dists_proportional <- function (graph,
}


#' Transform a result from 'dodgr_dists_proportional' to summary statistics
#' Transform a result from 'dodgr_dists_categorical' to summary statistics
#'
#' @param object A 'dodgr_dists_proportional' object
#' @param object A 'dodgr_dists_categorical' object
#' @param ... Extra parameters currently not used
#' @return The summary statistics (invisibly)
#' @export
summary.dodgr_dists_proportional <- function (object, ...) {
summary.dodgr_dists_categorical <- function (object, ...) {

d0 <- object$distances # first list item
sum_d0 <- sum (d0, na.rm = TRUE)
Expand Down
14 changes: 4 additions & 10 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"codeRepository": "https://github.com/ATFutures/dodgr",
"issueTracker": "https://github.com/ATFutures/dodgr/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.2.10.010",
"version": "0.2.10.11",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -371,10 +371,7 @@
],
"releaseNotes": "https://github.com/ATFutures/dodgr/blob/master/NEWS.md",
"readme": "https://github.com/ATFutures/dodgr/blob/main/README.md",
"contIntegration": [
"https://github.com/atfutures/dodgr/actions?query=workflow%3AR-CMD-check",
"https://codecov.io/gh/ATFutures/dodgr"
],
"contIntegration": ["https://github.com/atfutures/dodgr/actions?query=workflow%3AR-CMD-check", "https://codecov.io/gh/ATFutures/dodgr"],
"developmentStatus": "https://www.repostatus.org/#active",
"keywords": [
"distance",
Expand Down Expand Up @@ -403,15 +400,12 @@
"@type": "PublicationIssue",
"datePublished": "2019",
"isPartOf": {
"@type": [
"PublicationVolume",
"Periodical"
],
"@type": ["PublicationVolume", "Periodical"],
"name": "Transport Findings"
}
}
}
],
"relatedLink": "https://CRAN.R-project.org/package=dodgr",
"fileSize": "12446.017KB"
"fileSize": "12403.894KB"
}
69 changes: 0 additions & 69 deletions man/dodgr_dists_proportional.Rd

This file was deleted.

19 changes: 0 additions & 19 deletions man/summary.dodgr_dists_proportional.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OBJ_HEAPS = heaps/bheap.o heaps/fheap.o heaps/heap23.o \
heaps/triheap_ext.o heaps/triheap.o
OBJ_SRC = centrality.o dgraph.o pathfinders.o dodgr-to-sf.o flows.o fund-cycles.o \
graph-contract.o graph.o graph-sample.o RcppExports.o run_sp.o \
run_sp_proportional.o sc-as-network.o sf-as-network.o turn_penalty.o
run_sp_categorical.o sc-as-network.o sf-as-network.o turn_penalty.o
OBJECTS = $(OBJ_HEAPS) $(OBJ_SRC)

.PHONY: all clean
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OBJ_HEAPS = heaps/bheap.o heaps/fheap.o heaps/heap23.o \
heaps/triheap_ext.o heaps/triheap.o
OBJ_SRC = centrality.o dgraph.o pathfinders.o dodgr-to-sf.o flows.o fund-cycles.o \
graph-contract.o graph.o graph-sample.o RcppExports.o run_sp.o \
run_sp_proportional.o sc-as-network.o sf-as-network.o turn_penalty.o
run_sp_categorical.o sc-as-network.o sf-as-network.o turn_penalty.o
OBJECTS = $(OBJ_HEAPS) $(OBJ_SRC)

.PHONY: all clean
Expand Down
20 changes: 10 additions & 10 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// rcpp_get_sp_dists_proportional
Rcpp::NumericMatrix rcpp_get_sp_dists_proportional(const Rcpp::DataFrame graph, const Rcpp::DataFrame vert_map_in, Rcpp::IntegerVector fromi, Rcpp::IntegerVector toi_in, const std::string& heap_type, const bool proportions_only);
RcppExport SEXP _dodgr_rcpp_get_sp_dists_proportional(SEXP graphSEXP, SEXP vert_map_inSEXP, SEXP fromiSEXP, SEXP toi_inSEXP, SEXP heap_typeSEXP, SEXP proportions_onlySEXP) {
// rcpp_get_sp_dists_categorical
Rcpp::NumericMatrix rcpp_get_sp_dists_categorical(const Rcpp::DataFrame graph, const Rcpp::DataFrame vert_map_in, Rcpp::IntegerVector fromi, Rcpp::IntegerVector toi_in, const std::string& heap_type, const bool proportions_only);
RcppExport SEXP _dodgr_rcpp_get_sp_dists_categorical(SEXP graphSEXP, SEXP vert_map_inSEXP, SEXP fromiSEXP, SEXP toi_inSEXP, SEXP heap_typeSEXP, SEXP proportions_onlySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -254,13 +254,13 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type toi_in(toi_inSEXP);
Rcpp::traits::input_parameter< const std::string& >::type heap_type(heap_typeSEXP);
Rcpp::traits::input_parameter< const bool >::type proportions_only(proportions_onlySEXP);
rcpp_result_gen = Rcpp::wrap(rcpp_get_sp_dists_proportional(graph, vert_map_in, fromi, toi_in, heap_type, proportions_only));
rcpp_result_gen = Rcpp::wrap(rcpp_get_sp_dists_categorical(graph, vert_map_in, fromi, toi_in, heap_type, proportions_only));
return rcpp_result_gen;
END_RCPP
}
// rcpp_get_sp_dists_prop_threshold
Rcpp::NumericMatrix rcpp_get_sp_dists_prop_threshold(const Rcpp::DataFrame graph, const Rcpp::DataFrame vert_map_in, Rcpp::IntegerVector fromi, const double dlimit, const std::string& heap_type);
RcppExport SEXP _dodgr_rcpp_get_sp_dists_prop_threshold(SEXP graphSEXP, SEXP vert_map_inSEXP, SEXP fromiSEXP, SEXP dlimitSEXP, SEXP heap_typeSEXP) {
// rcpp_get_sp_dists_cat_threshold
Rcpp::NumericMatrix rcpp_get_sp_dists_cat_threshold(const Rcpp::DataFrame graph, const Rcpp::DataFrame vert_map_in, Rcpp::IntegerVector fromi, const double dlimit, const std::string& heap_type);
RcppExport SEXP _dodgr_rcpp_get_sp_dists_cat_threshold(SEXP graphSEXP, SEXP vert_map_inSEXP, SEXP fromiSEXP, SEXP dlimitSEXP, SEXP heap_typeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -269,7 +269,7 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< Rcpp::IntegerVector >::type fromi(fromiSEXP);
Rcpp::traits::input_parameter< const double >::type dlimit(dlimitSEXP);
Rcpp::traits::input_parameter< const std::string& >::type heap_type(heap_typeSEXP);
rcpp_result_gen = Rcpp::wrap(rcpp_get_sp_dists_prop_threshold(graph, vert_map_in, fromi, dlimit, heap_type));
rcpp_result_gen = Rcpp::wrap(rcpp_get_sp_dists_cat_threshold(graph, vert_map_in, fromi, dlimit, heap_type));
return rcpp_result_gen;
END_RCPP
}
Expand Down Expand Up @@ -340,8 +340,8 @@ static const R_CallMethodDef CallEntries[] = {
{"_dodgr_rcpp_get_iso", (DL_FUNC) &_dodgr_rcpp_get_iso, 5},
{"_dodgr_rcpp_get_sp_dists", (DL_FUNC) &_dodgr_rcpp_get_sp_dists, 5},
{"_dodgr_rcpp_get_paths", (DL_FUNC) &_dodgr_rcpp_get_paths, 5},
{"_dodgr_rcpp_get_sp_dists_proportional", (DL_FUNC) &_dodgr_rcpp_get_sp_dists_proportional, 6},
{"_dodgr_rcpp_get_sp_dists_prop_threshold", (DL_FUNC) &_dodgr_rcpp_get_sp_dists_prop_threshold, 5},
{"_dodgr_rcpp_get_sp_dists_categorical", (DL_FUNC) &_dodgr_rcpp_get_sp_dists_categorical, 6},
{"_dodgr_rcpp_get_sp_dists_cat_threshold", (DL_FUNC) &_dodgr_rcpp_get_sp_dists_cat_threshold, 5},
{"_dodgr_rcpp_gen_hash", (DL_FUNC) &_dodgr_rcpp_gen_hash, 2},
{"_dodgr_rcpp_sf_as_network", (DL_FUNC) &_dodgr_rcpp_sf_as_network, 2},
{"_dodgr_rcpp_points_index_par", (DL_FUNC) &_dodgr_rcpp_points_index_par, 2},
Expand Down
6 changes: 3 additions & 3 deletions src/pathfinders.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PathFinder {
const bool *m_closed_vec,
const size_t &v0,
const std::vector<double> &heur);
// with A* heuristic for dists-proportional
// with A* heuristic for dists-categorical
void scan_edge_types_heur (
const DGraphEdge *edge,
std::vector<double>& d,
Expand All @@ -96,7 +96,7 @@ class PathFinder {
const bool *m_closed_vec,
const size_t &v0,
const std::vector<double> &heur);
// run_sp_proportional for threshold dists
// run_sp_categorical for threshold dists
void scan_edge_types (
const DGraphEdge *edge,
std::vector<double>& d,
Expand All @@ -112,7 +112,7 @@ class PathFinder {
std::vector<long int>& prev,
const size_t v0,
const std::vector <size_t> &to_index);
void DijkstraLimit ( // run_sp_proportional
void DijkstraLimit ( // run_sp_categorical
std::vector<double>& d,
std::vector<double>& w,
std::vector<long int>& prev,
Expand Down
10 changes: 5 additions & 5 deletions src/run_sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void make_vert_to_edge_maps (const std::vector <std::string> &from,
size_t get_chunk_size (const size_t nfrom);
} // end namespace run_sp

namespace proportional {
namespace categorical {

size_t num_edge_types (const std::vector <size_t> &edge_type);

} // end namespace proportional
} // end namespace categorical


Rcpp::NumericMatrix rcpp_get_sp_dists (const Rcpp::DataFrame graph,
Expand Down Expand Up @@ -77,15 +77,15 @@ Rcpp::List rcpp_get_paths (const Rcpp::DataFrame graph,
Rcpp::IntegerVector toi_in,
const std::string& heap_type);

// in run_sp_proportional:
Rcpp::NumericMatrix rcpp_get_sp_dists_proportional (const Rcpp::DataFrame graph,
// in run_sp_categorical:
Rcpp::NumericMatrix rcpp_get_sp_dists_categorical (const Rcpp::DataFrame graph,
const Rcpp::DataFrame vert_map_in,
Rcpp::IntegerVector fromi,
Rcpp::IntegerVector toi_in,
const std::string& heap_type,
const bool proportions_only);

Rcpp::NumericMatrix rcpp_get_sp_dists_prop_threshold (const Rcpp::DataFrame graph,
Rcpp::NumericMatrix rcpp_get_sp_dists_cat_threshold (const Rcpp::DataFrame graph,
const Rcpp::DataFrame vert_map_in,
Rcpp::IntegerVector fromi,
const double dlimit,
Expand Down
Loading

0 comments on commit 776149f

Please sign in to comment.