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

Faster flag complex #355

Merged
merged 12 commits into from
May 10, 2023
Merged

Faster flag complex #355

merged 12 commits into from
May 10, 2023

Conversation

maximelucas
Copy link
Collaborator

Adresses #264

flag_complex and random_flag_complex were computing all maximal cliques and then letting add_simplices_from dealing with the max_order parameter.
This means that a small network with large density was already very long to compute, e.g.

H = xgi.random_flag_complex(50, 0.7)

I changed this: only cliques up to max_order are computed and then passed to add_simplices_from.

%timeit H = xgi.random_flag_complex(50, 0.6, seed=1)
# --> 22.6 s ± 198 ms # before
# --> 269 ms ± 690 µs # now

Roughly a 100x speedup, expected to be more for larger and denser graphs.

I also added some tests because the ones we had were testing consistency but not correctness.

@maximelucas
Copy link
Collaborator Author

(The new commits are the last two, not sure why the others appear here, I think they're from a past PR)

@codecov
Copy link

codecov bot commented May 8, 2023

Codecov Report

Patch coverage: 94.44% and project coverage change: -0.04 ⚠️

Comparison is base (a58a4b8) 90.55% compared to head (82d5573) 90.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #355      +/-   ##
==========================================
- Coverage   90.55%   90.51%   -0.04%     
==========================================
  Files          41       41              
  Lines        3016     3025       +9     
==========================================
+ Hits         2731     2738       +7     
- Misses        285      287       +2     
Impacted Files Coverage Δ
xgi/generators/simplicial_complexes.py 96.77% <94.11%> (+0.30%) ⬆️
xgi/generators/classic.py 97.87% <100.00%> (+0.04%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@leotrs leotrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

xgi/generators/classic.py Outdated Show resolved Hide resolved
xgi/generators/simplicial_complexes.py Outdated Show resolved Hide resolved
xgi/generators/simplicial_complexes.py Outdated Show resolved Hide resolved
@maximelucas
Copy link
Collaborator Author

Thanks Leo! Should all be addressed.

@maximelucas maximelucas merged commit 26ba651 into main May 10, 2023
@maximelucas maximelucas deleted the faster-flag-complex branch May 10, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants