Skip to content

Commit

Permalink
add acknowledgement
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed May 13, 2024
1 parent b54f527 commit 913fca6
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions xgi/algorithms/connected.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,6 @@ def node_connected_component(H, n):
raise XGIError("Specified node is not in the hypergraph!")


def _plain_bfs(H, source):
"""A fast BFS node generator"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
seen.add(v)
nextlevel.update(H.nodes.neighbors(v))
return seen


def largest_connected_hypergraph(H, in_place=False):
"""
A function to find the largest connected hypergraph from a data set.
Expand Down Expand Up @@ -242,3 +228,21 @@ def largest_connected_hypergraph(H, in_place=False):
return subhypergraph(H, nodes=connected_nodes).copy()
else:
H.remove_nodes_from(set(H.nodes).difference(connected_nodes))


def _plain_bfs(H, source):
"""A fast BFS node generator
Source:
https://networkx.org/documentation/stable/_modules/networkx/algorithms/components/connected.html
"""
seen = set()
nextlevel = {source}
while nextlevel:
thislevel = nextlevel
nextlevel = set()
for v in thislevel:
if v not in seen:
seen.add(v)
nextlevel.update(H.nodes.neighbors(v))
return seen

0 comments on commit 913fca6

Please sign in to comment.