xgi-org/xgi

homogenise large_connected_hypergraph implementations

Closed this issue · 0 comments

To get the GCC, we have the large_connected_hypergraph() function:

connected_nodes = max(connected_components(H), key=len)
if not in_place:
return subhypergraph(H, nodes=connected_nodes).copy()
else:
H.remove_nodes_from(set(H.nodes).difference(connected_nodes))

And we also get the GCC in cleanup() when connected=True, but it's implemented slightly differently:

xgi/xgi/core/hypergraph.py

Lines 1471 to 1474 in e01ddd5

if connected:
from ..algorithms import largest_connected_component
self.remove_nodes_from(self.nodes - largest_connected_component(self))

If there's no reason for this, I think we should make them the same, or even better, call the first one in the second.
It will be easier to maintain and check that both do the same.