`x` can either be the matrix, the number of nodes or a vector of nodes. If x is a list, it is assumed that the first element of the list is the vector of row-nodes, and the second element the vector of column-nodes. If x is a numeric vector of length 2, it is assumed that x is the dimensions of the matrix.

mat2vec_ix(x = NULL, directed = NULL, selfloops = NULL, arr.ind = FALSE)

Arguments

x

either a matrix, the number of nodes, or the vector containing the nodes

directed

a boolean argument specifying whether object is directed or not. When absent it is inferred from `x`.

selfloops

a boolean argument specifying whether the model should incorporate selfloops. When absent it is inferred from `x`.

arr.ind

boolean, return vector of indices or tuple with array indices? defaults to FALSE

Value

a boolean matrix that can be used to mask adjacency matrices.

Examples

el <- data.frame(from= c('a','b','b','c','d','d'), to = c('b','c','d','a','b','a'), attr= c( 12, 6, 12 , 6 , 6 , 6 )) adj <- el2adj(el) mat2vec_ix(adj, directed = TRUE, selfloops=FALSE)
#> [1] 2 3 4 5 7 8 9 10 12 13 14 15
mat2vec_ix(adj)
#> [1] 2 3 4 5 7 8 9 10 12 13 14 15
mat2vec_ix(x=nrow(adj), directed = TRUE, selfloops=FALSE)
#> [1] 2 3 4 5 7 8 9 10 12 13 14 15
mat2vec_ix(x=rownames(adj), directed = TRUE, selfloops=FALSE)
#> [1] 2 3 4 5 7 8 9 10 12 13 14 15