Skip to content

Commit

Permalink
address #175
Browse files Browse the repository at this point in the history
  • Loading branch information
rsbivand committed Jan 13, 2025
1 parent b61f6b1 commit 0bd77e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/components.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ n.comp.nb <- function(nb.obj){
}
if (!igraph) {
if (!nb.sym) nb.obj <- make.sym.nb(nb.obj)
comp <- rep(0,length(nb.obj))
comp <- .Call("g_components", nb.obj, as.integer(comp), PACKAGE="spdep")
comp0 <- rep(0,length(nb.obj))
comp <- .Call("g_components", nb.obj, as.integer(comp0), PACKAGE="spdep")
answ <- list(nc=length(unique(comp)), comp.id=comp)
} else {
stopifnot(requireNamespace("igraph", quietly=TRUE))
Expand Down
6 changes: 5 additions & 1 deletion src/dfs_ncomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#define WHITE 0

void dfs(SEXP nblst, SEXP cmpnm, SEXP visited, int curcmp, int nodeid){
int n,i;
int n,i,nvert;

if (nodeid < 0 || nodeid >= Rf_length(nblst))
Rf_error("n.comp.nb: recursive nodeid out of bounds\ninstall spatialreg and igraph to avoid legacy issue");


INTEGER(cmpnm)[nodeid]=curcmp;
INTEGER(visited)[nodeid]=BLACK;
Expand Down

0 comments on commit 0bd77e5

Please sign in to comment.