xgi-org / xgi

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

cleanup() not working for simplicial complexes #195

Closed maximelucas closed 1 year ago

maximelucas commented 2 years ago

Because cleanup() uses HyperGraph specific methods and functions: XGIError: Cannot remove_edges_from to SimplicialComplex, use remove_simplices_from instead

mcontisc commented 2 years ago

Actually cleanup does not seem to work even for hypergraphs.

H = xgi.Hypergraph([[1, 2, 3], [4], [5, 6], [6, 7, 8]])
H.cleanup()
> AttributeError: stat "cleanup" not among available node or edge stats

EDIT: This was done on an earlier version. On version 0.4.3, cleanup does work on Hypergraphs. It does not work on Simplicial Complexes.

nwlandry commented 1 year ago

With the changes to the SimplicialComplex class (PR #247), multiedges are not allowed and I believe that singletons are required (although not sure how it's implemented right now). So I think that renumbering IDs and removing isolates is probably what should happen with a cleanup method.

maximelucas commented 1 year ago

Thanks for unearthing this. After PR #247, cleanup() does not raise an error anymore, but I feel its effect is not fully correct (or should be discussed). It can remove the following:

It also relabel by default which seems fine I agree.

leotrs commented 1 year ago

singletons (default): has an unwanted effect IMO. In the SC class, removing a simplex removes all other simplices that it is included in. So removing singletons removes all edges and triangles etc. that it is part of, even though the node corresponding to the singleton still exists. That's not really consistent, because when adding a 2-hyperedge {1,2,3}, the corresponding singletons are not added by add_simplex.

Perhaps we should add a check to cleanup that just ignores the singletons flag and never touches them.