pnnl / HyperNetX

Python package for hypergraph analysis and visualization.
https://hypernetx.readthedocs.io
Other
500 stars 86 forks source link

Confusing sorting order in hypergraph nodes #107

Closed goznalo-git closed 1 year ago

goznalo-git commented 1 year ago

Hi there,

I am experiencing a weird behaviour when retrieving the nodelist from the Hypergraph. It is so basic that I do wonder if, rather than being an issue, I am doing something wrong or if I am missing some option, but I can't figure it out.

Take, for instance, the first tutorial notebook. When one runs H.nodes, one is returned EntitySet(:Nodes,['BM', 'JU', 'MP', 'CN', 'TH', 'FN', 'JA', 'BR', 'GP', 'MA', 'JV', 'CH', 'CC'],{'weight': 1.0}). Notice the ordering of the nodes: that is the same order of, for instance, the H.adjacency_matrix() matrix.

On the other hand, if one runs list(H.nodes) or H.nodes.elements or even prints the nodes in a for node in H.nodes: loop, one gets a completely different ordering: ['FN', 'TH', 'JV', 'BM', 'JA', 'JU', 'CH', 'BR', 'CN', 'CC', 'GP', 'MP', 'MA'].

What am I missing? I think this is confusing, to say the least.

Thanks in advance, G

brendapraggastis commented 1 year ago

@goznalo-git HNX 2.0 will be released this coming Saturday on May 13. The return on >>H.nodes is now just the default class message. The return on list(H.nodes) should provide the only ordering you need. Please let us know if the new version does not solve the issue.