Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial clique complex #200

Merged
merged 9 commits into from
Oct 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review suggestion
  • Loading branch information
maximelucas committed Oct 24, 2022
commit 231e1863a6e699d5a77ca1eb5b24a8c7e5af5006
9 changes: 6 additions & 3 deletions xgi/generators/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

"""

from collections import defaultdict
from itertools import combinations
from warnings import warn

Expand Down Expand Up @@ -210,7 +211,7 @@ def flag_complex(G, max_order=2, ps=None, seed=None):
nodes = G.nodes()
edges = G.edges()

# compute all triangles to fill
# compute all cliques to fill
max_cliques = list(nx.find_cliques(G))

S = SimplicialComplex()
Expand All @@ -219,10 +220,12 @@ def flag_complex(G, max_order=2, ps=None, seed=None):
if not ps: # promote all cliques
S.add_simplices_from(max_cliques, max_order=max_order)
else: # promote cliques with a given probability
cliques_d = defaultdict(list)
for x in max_cliques:
cliques_d[len(x)].append(x)
for i, p in enumerate(ps[:max_order - 1]):
d = i + 2 # simplex order
cliques_d = [x for x in max_cliques if len(x) == d + 1]
cliques_d_to_add = [el for el in cliques_d if if seed.random() <= p]
cliques_d_to_add = [el for el in cliques_d[d+1] if if seed.random() <= p]
S.add_simplices_from(cliques_d_to_add, max_order=max_order)

return S
Expand Down