Modularity function returns error: AttributeError: 'Entity' object has no attribute 'strength'
Closed this issue · 4 comments
When I call print('qH =',hmod.modularity(H, K, strict))
it returns AttributeError: 'Entity' object has no attribute 'strength'
The full code:
import igraph as ig
import hypernetx as hnx
import hypernetx.algorithms.hypergraph_modularity as hmod
H = hnx.Hypergraph(lookup)
H = hmod.precompute_attributes(H)
#%%
K = hmod.kumar(H)
#%%
strict = hmod.strict
## Compute qH
print('qH =',hmod.modularity(H, K, strict))
Lookup is a dictionary of the form: {key1 : (hedge1, hedge2...), key2 : (hedge1, hedge3...)}
Thank you for raising an issue, I will look into it. It looks like a line of code from your original post has been updated from hmod.precompute_attributes(H)
-> H = hmod.precompute_attributes(H)
- just to clarify, you are still receiving the same error message with the updated code?
EDIT: I realize that I was feeding the Hgraph in wrong. I was doing:
{node : (hedge1, hedge2...)}
when I should have been doing {hedge1 : (node1, node2...)}
. Fixing this solved the issue.
Reopening the issue since the change described above just changes the error from being about strength to being about weight.
Resolved