Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/centrality.R
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ arpack <- function(
}
res$values <- res$values[, 1]
}
res$vectors <- res$vectors[, 1:length(res$values)]
res$vectors <- res$vectors[, seq_along(res$values)]
}

res
Expand Down
4 changes: 2 additions & 2 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ as.dendrogram.communities <- function(
}
z <- list()
if (!use.modularity || is.null(object$modularity)) {
object$height <- 1:nrow(merges)
object$height <- seq_len(nrow(merges))
} else {
object$height <- object$modularity[-1]
object$height <- cumsum(object$height - min(object$height))
Expand Down Expand Up @@ -1178,7 +1178,7 @@ as.phylo.communities <- function(x, use.modularity = FALSE, ...) {
merges <- complete.dend(x, use.modularity)

if (!use.modularity || is.null(x$modularity)) {
height <- 1:nrow(merges)
height <- seq_len(nrow(merges))
} else {
height <- x$modularity[-1]
height <- cumsum(height - min(height))
Expand Down
2 changes: 1 addition & 1 deletion R/glet.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function() {
co <- layout_with_kk(g)
par(mar = c(1, 1, 1, 1))
plot(g, layout = co)
for (i in 1:length(gl$Bc)) {
for (i in seq_along(gl$Bc)) {
sel <- gl$Bc[[i]]
V(g)$color <- "white"
V(g)[sel]$color <- "#E495A5"
Expand Down
6 changes: 3 additions & 3 deletions R/hrg.R
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ as.dendrogram.igraphHRG <- function(object, hang = 0.01, ...) {
r
}

oHgt <- 1:nrow(merges)
oHgt <- seq_len(nrow(merges))
hMax <- oHgt[length(oHgt)]
mynames <- if (is.null(object$names)) 1:(nMerge + 1) else object$names
z <- list()
Expand Down Expand Up @@ -634,7 +634,7 @@ as.hclust.igraphHRG <- function(x, ...) {
## the left node.
map2 <- numeric(nrow(merge))
mergeInto <- merge
for (i in 1:nrow(merge)) {
for (i in seq_len(nrow(merge))) {
mr <- mergeInto[i, ]
mr[mr > 0] <- -map2[mr[mr > 0]]
mergeInto[i, ] <- -mr
Expand All @@ -650,7 +650,7 @@ as.hclust.igraphHRG <- function(x, ...) {
mynames <- if (is.null(x$names)) 1:n else x$names
res <- list(
merge = merge,
height = 1:nrow(merge),
height = seq_len(nrow(merge)),
order = order,
labels = mynames,
method = NA_character_,
Expand Down
4 changes: 2 additions & 2 deletions R/tkplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ tk_canvas <- function(tkp.id) {
function(from, to, id) .tkplot.create.edge(tkp.id, from, to, id),
edgematrix[, 1],
edgematrix[, 2],
1:nrow(edgematrix)
seq_len(nrow(edgematrix))
)
}

Expand Down Expand Up @@ -1765,7 +1765,7 @@ tk_canvas <- function(tkp.id) {
pady = 5
)
values[[i]] <- tcltk::tclVar(layout$params[[i]]$default)
for (j in 1:length(layout$params[[i]]$values)) {
for (j in seq_along(layout$params[[i]]$values)) {
tmp <- tcltk::tkradiobutton(
tmp.frame,
variable = values[[i]],
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-assortativity.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test_that("nominal assortativity works", {

el <- as_edgelist(o, names = FALSE)
etm <- matrix(0, nrow = max(V(o)$value) + 1, ncol = max(V(o)$value) + 1)
for (e in 1:nrow(el)) {
for (e in seq_len(nrow(el))) {
t1 <- V(o)$value[el[e, 1]] + 1
t2 <- V(o)$value[el[e, 2]] + 1
etm[t1, t2] <- etm[t1, t2] + 1
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-community.R
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ test_that("cluster_leading_eigen works", {
multiplier,
extra
) {
M <- sapply(1:length(vector), function(x) {
M <- sapply(seq_along(vector), function(x) {
v <- rep(0, length(vector))
v[x] <- 1
multiplier(v)
Expand Down Expand Up @@ -268,7 +268,7 @@ test_that("cluster_leading_eigen works", {
multiplier,
extra
) {
M <- sapply(1:length(vector), function(x) {
M <- sapply(seq_along(vector), function(x) {
v <- rep(0, length(vector))
v[x] <- 1
multiplier(v)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-conversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ test_that("as_biadjacency_matrix() works -- dense", {
test_that("as_biadjacency_matrix() works -- dense named", {
biadj_mat <- matrix(sample(0:1, 35, replace = TRUE, prob = c(3, 1)), ncol = 5)
g <- graph_from_biadjacency_matrix(biadj_mat)
V(g)$name <- letters[1:length(V(g))]
V(g)$name <- letters[seq_along(V(g))]

expect_true(is_named(g))

Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-glet.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ graphlets.project.old <- function(graph, cliques, iter, Mu = NULL) {

## Create vertex-clique list first
vcl <- vector(length = vcount(graph), mode = "list")
for (i in 1:length(clf)) {
for (i in seq_along(clf)) {
for (j in clf[[i]]) {
vcl[[j]] <- c(vcl[[j]], i)
}
Expand All @@ -138,7 +138,7 @@ graphlets.project.old <- function(graph, cliques, iter, Mu = NULL) {
## We will also need a clique-edge list, the edges in the cliques
system.time({
cel <- vector(length = length(clf), mode = "list")
for (i in 1:length(ecl)) {
for (i in seq_along(ecl)) {
for (j in ecl[[i]]) {
cel[[j]] <- c(cel[[j]], i)
}
Expand All @@ -153,10 +153,10 @@ graphlets.project.old <- function(graph, cliques, iter, Mu = NULL) {
w <- numeric(length(ecl))
a <- sapply(clf, function(x) length(x) * (length(x) + 1) / 2)
for (i in 1:iter) {
for (j in 1:length(ecl)) {
for (j in seq_along(ecl)) {
w[j] <- sum(Mu[ecl[[j]]])
}
for (j in 1:length(clf)) {
for (j in seq_along(clf)) {
Mu[j] <- Mu[j] * sum(origw[cel[[j]]] / (w[cel[[j]]] + .0001)) / a[j]
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-make.R
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ test_that("make_bipartite_graph works", {

test_that("make_bipartite_graph works with vertex names", {
types <- c(0, 1, 0, 1, 0, 1)
names(types) <- LETTERS[1:length(types)]
names(types) <- LETTERS[seq_along(types)]
edges <- c("A", "B", "C", "D", "E", "F", "A", "D", "D", "E", "B", "C", "C", "F")
bip_grap <- make_bipartite_graph(types, edges)

Expand Down
Loading