Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove components sort, Kosaraju should be O(n)#1330

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

chubakueno
Copy link
Contributor

sort(component.begin(), component.end()) is linearithmic, which breaks the expected linear complexity of Kosaraju. Line is also superfluous and unnecesary.

aleiva17 and mhayter reacted with thumbs up emoji
sort(component.begin(), component.end()) is linearithmic, which breaks the expected linear complexity of Kosaraju. Line is also superfluous and unnecesary.
@mhayter
Copy link
Contributor

I'm shocked that someone rewrote this and made the code worse... It was correct before it was updated 2 months ago. You're right that there's no need to sort.

@el-sambal
Copy link
Contributor

el-sambal commentedSep 3, 2024
edited
Loading

Sorry, I didn't think about that. The line should indeed be removed, but this sentence should then also be modified (e.g. by removing the word 'sorted'):

When building the adjacency list of the condensation graph, we select the root of each component as the first vertex in its sorted list of vertices (this is an arbitrary choice).

Thanks for catching this mistake!

Modify description to match the removal of sort() in algorithm.
@chubakueno
Copy link
ContributorAuthor

@el-sambal suggestion taken, updated the description!

el-sambal reacted with thumbs up emoji

@mhayter
Copy link
Contributor

Has this code really been tested? The code is called strongy rather than strongly...

@adamant-pwn
Copy link
Member

Thanks for the pull request! Generally, the article was largely rewritten in#1307, and IMO it overall got much better than it was before. Unfortunately, I indeed missed that sorting adds unnecessary overhead in complexity, and that there is a typo in the function name. But other than that, the new code is tested to some extent intest_strongly_connected_components.cpp. Merging the change now.

@adamant-pwnadamant-pwn merged commit7c2466d intocp-algorithms:masterOct 12, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@chubakueno@mhayter@el-sambal@adamant-pwn

[8]ページ先頭

©2009-2025 Movatter.jp