Skip to content

Commit

Permalink
Merge pull request #61 from ropensci/fix/deprecated-igraph-clusters
Browse files Browse the repository at this point in the history
Fix/replace igraph clusters with components
  • Loading branch information
robitalec committed Apr 14, 2024
2 parents 2edd03c + d80980b commit 625d6d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions R/group_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ group_lines <-
}
dimnames(inter) <- list(sfLines[[id]], sfLines[[id]])
g <- igraph::graph_from_adjacency_matrix(inter)
ovr <- igraph::clusters(g)$membership
ovr <- igraph::components(g)$membership
out <- data.table::data.table(names(ovr),
unlist(ovr))
data.table::setnames(out, c('ID', 'group'))
Expand Down Expand Up @@ -237,7 +237,7 @@ group_lines <-
}
dimnames(inter) <- list(lns[[id]], lns[[id]])
g <- igraph::graph_from_adjacency_matrix(inter)
ovr <- igraph::clusters(g)$membership
ovr <- igraph::components(g)$membership
ovrDT <- data.table::data.table(ID = names(ovr),
group = unlist(ovr))
} else {
Expand Down Expand Up @@ -291,7 +291,7 @@ group_lines <-
}
dimnames(inter) <- list(lns[[id]], lns[[id]])
g <- igraph::graph_from_adjacency_matrix(inter)
ovr <- igraph::clusters(g)$membership
ovr <- igraph::components(g)$membership
out <- data.table::data.table(names(ovr),
unlist(ovr))
data.table::setnames(out, c(..id, 'withinGroup'))
Expand Down
4 changes: 2 additions & 2 deletions R/group_polys.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ group_polys <-
inter <- sf::st_intersects(sfPolys, sfPolys, sparse = FALSE)
dimnames(inter) <- list(sfPolys[[id]], sfPolys[[id]])
g <- igraph::graph_from_adjacency_matrix(inter)
ovr <- igraph::clusters(g)$membership
ovr <- igraph::components(g)$membership
out <- data.table::data.table(names(ovr),
as.integer(unlist(ovr)))
data.table::setnames(out, c(id, 'group'))
Expand Down Expand Up @@ -244,7 +244,7 @@ group_polys <-
inter <- sf::st_intersects(sfPolys, sfPolys, sparse = FALSE)
dimnames(inter) <- list(sfPolys[[..id]], sfPolys[[..id]])
g <- igraph::graph_from_adjacency_matrix(inter)
ovr <- igraph::clusters(g)$membership
ovr <- igraph::components(g)$membership
out <- data.table::data.table(names(ovr),
as.integer(unlist(ovr)))
data.table::setnames(out, c(id, 'withinGroup'))
Expand Down
2 changes: 1 addition & 1 deletion R/group_pts.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ group_pts <- function(DT = NULL,
method = 'euclidean'))
graphAdj <-
igraph::graph_from_adjacency_matrix(distMatrix <= threshold)
igraph::clusters(graphAdj)$membership
igraph::components(graphAdj)$membership
},
by = c(splitBy, timegroup), .SDcols = c(coords, id)]
DT[, group := .GRP,
Expand Down

0 comments on commit 625d6d3

Please sign in to comment.