pnnl / HyperNetX

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

is there an efficient way to construct a large hypergraph? #108

Open slotrans opened 1 year ago

slotrans commented 1 year ago

I'm trying to build a hypergraph which has ~3.8M nodes and ~7.1M hyperedges.

My first attempt was to build a dictionary of edge -> nodelist so I could do a simple Hypergraph(dict) as per the docs, but that made no apparent progress.

I then tried to add the edges, then add the nodes. But after ~8 minutes I'm was only at 48000 edges and based on log output the process was getting markedly slower as the hypergraph grew.

I'm now trying an approach where I create a list of Entity objects then add them to an EntitySet, but that latter step has been going for many minutes now.

Skimming the code it seems like all of these bottom out in for loops that add elements, often with several uniqueness tests.

Is there an alternate construction method that I'm missing? Or am I just outside the design bounds trying to build a hypergraph this large?

q923397935 commented 1 year ago

I have the same questions, but i find sparse matrix to construct hypergraph faster than dict, maybe you can try it.