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

Avoid materializing intermediate adjacency list #372

Merged
merged 3 commits into from
May 2, 2024

Conversation

simsurace
Copy link
Contributor

@simsurace simsurace commented May 2, 2024

For graphs where the adjacency is not stored, this can lead to a lot of allocations when iterating over edges.

Before PR:

julia> g
{58089, 120148} directed simple Int32 graph

julia> typeof(g)
StaticGraphs.StaticDiGraph{Int32, Int32}

julia> @time collect(Graphs.edges(g));
 21.959129 seconds (330.20 k allocations: 260.015 GiB, 27.19% gc time, 0.21% compilation time)

After PR:

julia> @time collect(Graphs.edges(g));
  0.000396 seconds (3 allocations: 938.844 KiB)

@KristofferC
Copy link

Couldn't this be done in the iterate above as well?

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.27%. Comparing base (48c42c7) to head (4efde07).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #372      +/-   ##
==========================================
- Coverage   97.28%   97.27%   -0.01%     
==========================================
  Files         118      118              
  Lines        6876     6874       -2     
==========================================
- Hits         6689     6687       -2     
  Misses        187      187              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

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

Gotta love a 12-line PR with a times-one-gazillion speedup

@gdalle gdalle merged commit 599ef81 into JuliaGraphs:master May 2, 2024
9 of 12 checks passed
@simsurace simsurace deleted the patch-1 branch May 2, 2024 11:17
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.

3 participants