xgi
xgi copied to clipboard
cleanup() not working for simplicial complexes
Because cleanup()
uses HyperGraph specific methods and functions:
XGIError: Cannot remove_edges_from to SimplicialComplex, use remove_simplices_from instead
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.
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.
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.
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.