graphs: make init_short_digraph always sort neighbors but without the extra log complexity (2nd try) #38664
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is based on the closed PR #38427 (by myself) that was breaking too much doctests.
This PR improve the
init_short_digraph
function that is used to initializeStaticSparseCGraph
(used for immutableGraph
andDiGraph
).Before, a boolean parameter
sort_neighbors
was used to specify if we wanted to sort the neighbors or not. It implied an extralog
in the complexity (asqsort
was called).With this PR, the neighbors are always sorted at no extra cost. It is done by appending to the neighbors list the vertices in the correct order so the call to
qsort
is not needed anymore.This PR partly reverts #38198 and mostly reverts #37662
Contrary to PR #38427, I did not include the patch that remove the sorting of vertices when StaticSparseGraph are initialized because it was breaking too many doctests. Instead I added a option to disabled said sorting and use it in my doctests to check that the new code works.
📝 Checklist
⌛ Dependencies