xgi icon indicating copy to clipboard operation
xgi copied to clipboard

Create a frozen hypergraph object

Open leotrs opened this issue 4 years ago • 5 comments

We have discussed implementing a frozen object that would allow every statistic to be cached:

H = some_hyper_graph()

H.adj_tensor()    # compute the tensor
# ...more code here...
H.adj_tensor()    # has to recompute

H.freeze()
H.adj_tensor()    # since H is frozen, it computes the tensor once and *caches it*
# ...more code here...
H.adj_tensor() # no need to recompute!

The point is that after H is frozen, we can essentially cache everything!

H.freeze()
H.max_degree() # compute and cache
H.degree_histogram() # compute and cache
# etc

If at any point the user wants to modify H again, the cache is flushed,

H.thaw() # everything that was cached is erased
H.add_edge([1,2,3])
H.max_degree() # need to recompute
H.freeze()
H.max_degree() # compute and cache

leotrs avatar Dec 16 '21 10:12 leotrs

Looks perfect ;)

iaciac avatar Dec 17 '21 10:12 iaciac

Agreed ^^. I especially like the thaw() function.

nwlandry avatar Dec 20 '21 16:12 nwlandry

I think this is best left until after the basic interface has stabilized a bit. For example #20

leotrs avatar Jan 20 '22 13:01 leotrs

Agreed.

nwlandry avatar Jan 20 '22 18:01 nwlandry