xgi
xgi copied to clipboard
Create a frozen hypergraph object
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
Looks perfect ;)
Agreed ^^. I especially like the thaw() function.
I think this is best left until after the basic interface has stabilized a bit. For example #20
Agreed.