I'm trying to calculate my graph's modularity based on attributes. First I define the attribute as such:
graph <- set_vertex_attr(graph, "attribute", value = as.numeric(df$attribute))
This line of code is run without returning an error, next I run the modularity function:
modularity(graph, V(graph)$attribute)
I run this code for categorical attributes without any issues, but for numerical attributes (like in the example) I get this error:
Error in modularity.igraph(graph, V(graph)$attribute) : At community.c:919 : Invalid membership vector, Invalid value
Note: my graph was an adjacency matrix (380*380) converted to an igraph object. And the numerical attribute I'm trying to add to the graph contains lots of zeros and values smaller than 1. Any idea what I'm doing wrong?