stocnet / manynet

Many Ways to Make, Manipulate, and Map Myriad Networks
https://stocnet.github.io/manynet/
Other
12 stars 0 forks source link

net_components seems to not handle strings as actor types. #100

Closed SimonMontfort closed 1 week ago

SimonMontfort commented 1 month ago

I want to compute the connected components of a two-mode network.

library(manynet)

nw12 <- network.initialize(20, dir = FALSE, bipartite = 5)
set.seed(1)
nw12[,] <- sample(c(1, 0), 20, replace = TRUE)

g <- as_igraph(nw12)

V(g)$type <- c(rep("actor", 5), rep("event", 15)) 
net_components(g)

produces the error

Error in !igraph::V(.data)$type : invalid argument type

when I transform to logical it works

V(g)$type <- V(g)$type == "actor"
net_components(g)
[1] 1
jhollway commented 1 week ago

$type is a reserved variable that expects the format to be logical. This is due to how {igraph} processes bipartite/twomode networks.