Skip to content

Commit d0ce698

Browse files
authored
Merge pull request #53 from r-spatial/n_comp
N comp
2 parents bfb1ebe + 29095b5 commit d0ce698

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: spatialreg
2-
Version: 1.3-4
3-
Date: 2024-06-10
2+
Version: 1.3-5
3+
Date: 2024-06-14
44
Title: Spatial Regression Analysis
55
Encoding: UTF-8
66
Authors@R: c(person("Roger", "Bivand", role = c("cre", "aut"), email = "Roger.Bivand@nhh.no", comment=c(ORCID="0000-0003-2392-6140")),

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Version 1.3-4 (development)
1+
# Version 1.3-5 (development)
2+
3+
* #52 subgraph updates
4+
5+
# Version 1.3-4 (2024-06-10)
26

37
* migrate from ESRI Shapefile to GeoPackage #50
48

R/cyclical.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ isCyclical <- function(nb) {
55
stopifnot(inherits(nb, "nb"))
66
cnb <- card(nb)
77
if (any(cnb == 0)) stop("Neighbours must be connected")
8-
if (n.comp.nb(nb)$nc != 1) stop("Complete connection required")
8+
nc <- attr(nb, "ncomp")
9+
if (is.null(nc)) nc <- n.comp.nb(nb)
10+
if (nc$nc != 1) stop("Complete connection required")
911
res <- 1L
1012
for (i in seq(along=nb)) {
1113
inbs <- nb[[i]]
@@ -29,7 +31,8 @@ isCyclical <- function(nb) {
2931
find_q1_q2 <- function(lw) {
3032
stopifnot(lw$style == "W")
3133
nb <- lw$neighbours
32-
nc <- n.comp.nb(nb)
34+
nc <- attr(nb, "ncomp")
35+
if (is.null(nc)) nc <- n.comp.nb(nb)
3336
members <- tapply(1:length(nb), nc$comp.id, c)
3437
q2 <- 0L
3538
q1 <- nc$nc

R/eigenw.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ subgraph_eigenw <- function(nb, glist=NULL, style="W", zero.policy=NULL,
4848
can.sim <- FALSE
4949
if (style %in% c("W", "S"))
5050
can.sim <- can.be.simmed(nb2listw(nb, glist=glist, style=style))
51-
nc <- n.comp.nb(nb)
51+
nc <- attr(nb, "ncomp")
52+
if (is.null(nc)) nc <- n.comp.nb(nb)
5253
t0 <- table(nc$comp.id)
5354
elist <- vector(mode="list", length=length(t0))
5455
singleton <- names(t0)[which(t0 == 1)]

man/eigenw.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ Jc <- sum(log(1 - rho * k3eig))
6969
# complex eigenvalue Jacobian
7070
Jc
7171
# subgraphs
72-
nc <- spdep::n.comp.nb(k3)
72+
nc <- attr(k3, "ncomp")
73+
if (is.null(nc)) nc <- spdep::n.comp.nb(k3)
7374
nc$nc
7475
table(nc$comp.id)
7576
k3eigSG <- subgraph_eigenw(k3, style="W")

vignettes/nb_igraph.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,16 @@ First we'll see how to get from sparse matrices to graphs. The mode of a symmetr
232232
class(B)
233233
object.size(B)
234234
if (!require("igraph", quietly=FALSE)) dothis <- FALSE
235+
```
236+
237+
```{r, echo=dothis, eval=dothis}
235238
g1 <- graph_from_adjacency_matrix(B, mode="undirected")
236239
class(g1)
237240
object.size(g1)
238241
```
239242
### Converting from graph to symmetric adjacency matrix
240243

241-
We can also convert this graph pack to the same matrix, but note that `get.adjacency` chooses a particular class of sparse matrix to be returned, so that the conversion process typically leads many matrices to fewer graph types, and back to fewer matrix types:
244+
We can also convert this graph back to the same matrix, but note that `as_adjacency_matrix` chooses a particular class of sparse matrix to be returned, so that the conversion process typically leads many matrices to fewer graph types, and back to fewer matrix types:
242245

243246
```{r, echo=dothis, eval=dothis}
244247
# Matrix 1.4-2 vulnerability work-around

0 commit comments

Comments
 (0)