xgi-org / xgi

CompleX Group Interactions (XGI) is a Python package for higher-order networks.
https://xgi.readthedocs.io
Other
171 stars 27 forks source link

to_line_graph function leads to KeyError #557

Closed pgberlureau closed 3 days ago

pgberlureau commented 5 days ago

Hello,

I think it would be better to iterate over

combinations(edge_label_dict.keys(), 2)

instead of

combinations(H.edges.members(), 2)

It solves a KeyError i have when i call to_line_graph on the following hypergraph:

h = xgi.Hypergraph({0: [(6.019592999999995, 47.2350647), (6.019592999999853, 47.2350647), (6.01959299999999, 47.2350647), (6.019592999999993, 47.2350647), (6.0195929999999755, 47.2350647)], 1: [(6.019592999999995, 47.2350647), (6.019592999999853, 47.2350647), (6.01959299999999, 47.2350647), (6.019592999999993, 47.2350647), (6.0195929999999755, 47.2350647)]})

thomasrobiglio commented 5 days ago

Thank you @pgberlureau for pointing this out! I replicated your error, and from a first look (I quickly implemented it in my local version of xgi), it seems that the solution you suggest works well.

We will soon open a PR to solve this bug, if you wish to do it yourself you are more than welcome to do so :)

pgberlureau commented 5 days ago

No problem, I can do it :)