xgi icon indicating copy to clipboard operation
xgi copied to clipboard

cleanup() not working for simplicial complexes

Open maximelucas opened this issue 2 years ago • 1 comments

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

maximelucas avatar Oct 12 '22 09:10 maximelucas

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.

mcontisc avatar Oct 14 '22 07:10 mcontisc

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.

nwlandry avatar Dec 12 '22 17:12 nwlandry

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:

  • isolates (default): that works fine I think.
  • multiedges (default): works fine but not needed as not allowed in SC class
  • 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.

It also relabel by default which seems fine I agree.

maximelucas avatar Dec 15 '22 09:12 maximelucas

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.

leotrs avatar Apr 05 '23 07:04 leotrs