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

adjacency_matrix: Collect neighbors before sorting them #71

Merged
merged 2 commits into from Dec 23, 2021

Conversation

Keno
Copy link
Contributor

@Keno Keno commented Nov 17, 2021

The neighbors list may be an iterator that is not sortable. Make
sure to collect it first to get an array back.

The neighbors list may be an iterator that is not sortable. Make
sure to collect it first to get an array back.
@codecov
Copy link

codecov bot commented Nov 17, 2021

Codecov Report

Merging #71 (b344392) into master (4b184cc) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #71      +/-   ##
==========================================
+ Coverage   99.46%   99.48%   +0.02%     
==========================================
  Files         106      107       +1     
  Lines        5556     5595      +39     
==========================================
+ Hits         5526     5566      +40     
+ Misses         30       29       -1     

@etiennedeg etiennedeg merged commit acb3d16 into JuliaGraphs:master Dec 23, 2021
@@ -59,7 +59,7 @@ function _adjacency_matrix(g::AbstractGraph, T::DataType, neighborfn::Function,
nz -= 1
end
end
dsts = sort(collect(neighborfn(g, j))) # TODO for most graphs it might not be necessary to sort
dsts = sort!(collect(neighborfn(g, j))) # TODO for most graphs it might not be necessary to sort
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In place sort! can be algorithmically a fair bit slower than the out of place version.

Copy link
Member

Choose a reason for hiding this comment

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

From my benchmark, it seemed to be rather equivalent and to allocate less, but you are probably more knowledgeable than me

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.

None yet

2 participants