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
minor rewrite
Co-authored-by: Leo Torres <[email protected]>
  • Loading branch information
maximelucas and leotrs authored Oct 24, 2022
commit 6ca1bae21e6ba6b44467df2f7d4f941c804b293d
19 changes: 11 additions & 8 deletions xgi/generators/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,17 @@ def flag_complex(G, max_order=2, ps=None, seed=None):
S.add_simplices_from(edges)
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_to_add = [el for el in cliques_d[d+1] if seed.random() <= p]
S.add_simplices_from(cliques_d_to_add, max_order=max_order)
return S

# 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_to_add = [el for el in cliques_d[d+1] if seed.random() <= p]
S.add_simplices_from(cliques_d_to_add, max_order=max_order)

return S

Expand Down