Create Number of Connected Components in an Undirected Graph.md#21
Open
irohafternoon wants to merge 1 commit intomainfrom
Open
Create Number of Connected Components in an Undirected Graph.md#21irohafternoon wants to merge 1 commit intomainfrom
irohafternoon wants to merge 1 commit intomainfrom
Conversation
Fuminiton
reviewed
Apr 17, 2025
| TraverseVertexes(next_vertex, adjacency_list, visited_vertexes); | ||
| } | ||
| } | ||
| }; |
| } | ||
| } | ||
| }; | ||
| ``` |
There was a problem hiding this comment.
bfsとdfsのどちらでも解ける場合は、自分はdfsの方がシンプルな気がします。
bfsは同じ深さのものを見たい意図があるような感じがするので。
Owner
Author
There was a problem hiding this comment.
ありがとうございます。
おっしゃるイメージ、私も共感しています。
oda
reviewed
Apr 18, 2025
| std::stack<int> node_to_visit; | ||
| node_to_visit.push(start); | ||
| while (!node_to_visit.empty()) { | ||
| auto node = node_to_visit.top(); |
There was a problem hiding this comment.
私は int は auto にしません。
std::vector::const_iterator みたいに長いならばともかく、元が十分に短いならばそのほうが読みやすいので。
しかし、少し古い C++ を書いていたので最近の潮流は知らないです。
Owner
Author
There was a problem hiding this comment.
ありがとうございます。
おっしゃる通り短いものについては型を明示したほうが分かりやすいと思いますので、autoは使わずに宣言していこうと思います
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Problem
Number of Connected Components in an Undirected Graph
Next Problem
Word Ladder