Skip to content

Create Number of Connected Components in an Undirected Graph.md#21

Open
irohafternoon wants to merge 1 commit intomainfrom
Number-of-Connected-Components-in-an-Undirected-Graph
Open

Create Number of Connected Components in an Undirected Graph.md#21
irohafternoon wants to merge 1 commit intomainfrom
Number-of-Connected-Components-in-an-Undirected-Graph

Conversation

@irohafternoon
Copy link
Copy Markdown
Owner

TraverseVertexes(next_vertex, adjacency_list, visited_vertexes);
}
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

いいと思います。

}
}
};
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bfsとdfsのどちらでも解ける場合は、自分はdfsの方がシンプルな気がします。
bfsは同じ深さのものを見たい意図があるような感じがするので。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ありがとうございます。
おっしゃるイメージ、私も共感しています。

std::stack<int> node_to_visit;
node_to_visit.push(start);
while (!node_to_visit.empty()) {
auto node = node_to_visit.top();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

私は int は auto にしません。
std::vector::const_iterator みたいに長いならばともかく、元が十分に短いならばそのほうが読みやすいので。
しかし、少し古い C++ を書いていたので最近の潮流は知らないです。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ありがとうございます。
おっしゃる通り短いものについては型を明示したほうが分かりやすいと思いますので、autoは使わずに宣言していこうと思います

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