cppRouting
cppRouting copied to clipboard
warning on some graphs
Hi, I was running some tests in a lib, and I found the next warning which seems to be new:
Warning message:
In cbind(from, to) :
number of rows of result is not a multiple of vector length (arg 1)
I does not know how/why happens, here a reprex:
library(wrapr)
sfnet2cppRouting <- function(
network,
weight) {
cppRouting_graph <- cppRouting::makegraph(
network %.>%
sfnetworks::activate(., "edges") %.>%
sf::st_as_sf(.) %.>%
sf::st_drop_geometry(.) %.>%
as.data.frame(.) %.>%
dplyr::transmute(., .data$from, .data$to, cost = .data[[weight]]),
directed = igraph::is_directed(network)
)
# }
original_nodes <- network %.>%
sfnetworks::activate(., "nodes") %.>%
sf::st_as_sf(.)
if (nrow(original_nodes) != cppRouting_graph$nbnode) {
stop("The net was simplified by cppRouting, the nodes assignation can be broken.")
}
cppRouting_graph
}
network <- local({
file <- "net_flat_5_sfnet-0.6.3.gpkg"
sfnetworks::sfnetwork(
sf::st_read(file, layer = "nodes", quiet = TRUE),
sf::st_read(file, layer = "edges", quiet = TRUE),
directed = FALSE
)
})
ret <- cppRouting::get_multi_paths(
Graph = sfnet2cppRouting(network, "weight"),
from = c(1, 2, 3),
to = c(5, 6, 7, 8)
)
Warning message:
In cbind(from, to) :
number of rows of result is not a multiple of vector length (arg 1)
Network used: net_flat_5_sfnet-0.6.3.zip
Thx!
Matrix products: default BLAS: /usr/lib64/libblas.so.3.11.0 LAPACK: /usr/lib64/liblapack.so.3.11.0
locale:
[1] LC_CTYPE=es_CL.utf8 LC_NUMERIC=C
[3] LC_TIME=es_CL.utf8 LC_COLLATE=es_CL.utf8
[5] LC_MONETARY=es_CL.utf8 LC_MESSAGES=es_CL.utf8
[7] LC_PAPER=es_CL.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_CL.utf8 LC_IDENTIFICATION=C
time zone: Chile/Continental tzcode source: system (glibc)
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] wrapr_2.1.0
loaded via a namespace (and not attached):
[1] crayon_1.5.2 vctrs_0.6.5 sfnetworks_0.6.3 cli_3.6.2
[5] rlang_1.1.2 DBI_1.1.3 KernSmooth_2.23-22 purrr_1.0.2
[9] generics_0.1.3 sf_1.0-15 RcppParallel_5.1.7 glue_1.6.2
[13] colorspace_2.1-0 cppRouting_3.1 lwgeom_0.2-13 e1071_1.7-14
[17] scales_1.3.0 fansi_1.0.6 sfheaders_0.4.3 grid_4.3.2
[21] munsell_0.5.0 classInt_0.4-10 tibble_3.2.1 lifecycle_1.0.4
[25] compiler_4.3.2 dplyr_1.1.4 igraph_1.6.0 Rcpp_1.0.11
[29] pkgconfig_2.0.3 tidyr_1.3.0 R6_2.5.1 class_7.3-22
[33] tidyselect_1.2.0 utf8_1.2.4 pillar_1.9.0 magrittr_2.0.3
[37] tidygraph_1.2.3 gtable_0.3.4 tools_4.3.2 proxy_0.4-27
[41] ggplot2_3.4.4 units_0.8-5
Yes, my bad. It occurs when get_multi_paths
function is called, more precisely when we check if there are NA
s in from
and to
.
It will be fixed.