Skip to content

Commit 90420ef

Browse files
committed
igraph work-around
1 parent af540cc commit 90420ef

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

R/sparse_mat.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ powerWeights <- function(W, rho, order=250, X, tol=.Machine$double.eps^(3/5)) {
116116

117117
invIrM <- function(neighbours, rho, glist=NULL, style="W", method="solve",
118118
feasible=NULL) {
119-
if(class(neighbours) != "nb") stop("Not a neighbours list")
119+
if(!inherits(neighbours, "nb")) stop("Not a neighbours list")
120120
invIrW(nb2listw(neighbours, glist=glist, style=style), rho=rho,
121121
method=method, feasible=feasible)
122122
}

vignettes/nb_igraph.Rmd

+8-4
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,14 @@ object.size(g1)
240240
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:
241241

242242
```{r, echo=dothis, eval=dothis}
243-
B1 <- get.adjacency(g1)
244-
class(B1)
245-
object.size(B1)
246-
all.equal(B, as(B1, "CsparseMatrix"))
243+
# Matrix 1.4-2 vulnerability work-around
244+
ow <- options("warn")$warn
245+
options("warn"=2L)
246+
B1 <- try(get.adjacency(g1), silent=TRUE)
247+
if (!inherits(B1, "try-error")) print(class(B1))
248+
if (!inherits(B1, "try-error")) print(object.size(B1))
249+
if (!inherits(B1, "try-error")) print(all.equal(B, as(B1, "CsparseMatrix")))
250+
options("warn"=ow)
247251
```
248252

249253
### Graph components in **spdep**

0 commit comments

Comments
 (0)