-
-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Describe the bug
When trying to compute assortativity for categorical labels attached to nodes, an error is returned when the labels are letters but not when the labels are numbers. It is mentioned that the bug is unexpected and to report it with a reproducible example.
To reproduce
The script below reproduces the bug
library(igraph)
set.seed(2)
g <- sample_gnm(10, 20)
V(g)$random1 <- sample(c(1, 2), 10, replace = T)
V(g)$random2 <- sample(c('1', '2'), 10, replace = T)
V(g)$random3 <- sample(c('A', 'B'), 10, replace = T)
# compute the assortativity of this node attribute
assortativity_nominal(g, types = V(g)$random1) # this is OK
assortativity_nominal(g, types = V(g)$random2) # this is OK
assortativity_nominal(g, types = V(g)$random3) # this leads to the output below
Error in assortativity_nominal(g, types = V(g)$random3) :
At core/core/vector.pmt:126 : Assertion failed: size >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it.
Please restart your R session to avoid crashes or other surprising behavior.
In addition: Warning message:
In assortativity_nominal(g, types = V(g)$random3) :
NAs introduced by coercion
Version information
Which version of igraph are you using and where did you obtain it?
igraph_1.6.0
from CRAN
R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)