Skip to content

Commit

Permalink
replaced clean_indices with as_igraph_vs
Browse files Browse the repository at this point in the history
  • Loading branch information
schochastics committed Jan 19, 2025
1 parent e48d50f commit e5e828b
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions R/indexing.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,24 +169,6 @@ get_submatrix <- function(x, i, j, attr = NULL, sparse = TRUE) {
res
}

clean_indices <- function(x, indices) {
if (is.character(indices)) {
return(match(indices, V(x)$name))
}
if (is.logical(indices)) {
if (length(indices) != vcount(x)) {
indices <- which(rep(indices, length.out = vcount(x)))
} else {
indices <- which(indices)
}
return(indices)
}
if (all(indices < 0)) {
return(seq_len(vcount(x))[indices])
}
indices
}

#' Query and manipulate a graph as it were an adjacency matrix
#'
#' @details
Expand Down Expand Up @@ -328,10 +310,10 @@ clean_indices <- function(x, indices) {

# convert logical, character or negative i/j to proper vertex ids
if (!missing(i)) {
i <- clean_indices(x, i)
i <- as_igraph_vs(x, i)
}
if (!missing(j)) {
j <- clean_indices(x, j)
j <- as_igraph_vs(x, j)
}

if (missing(i) && missing(j)) {
Expand Down

0 comments on commit e5e828b

Please sign in to comment.