MCPcopy Create free account
hub / github.com/E869120/math-algorithm-book / dfs

Function dfs

codes/cpp/Code_4_05_2.cpp:10–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8bool visited[100009]; // visited[pos]=false のとき頂点 x が白色、true のとき灰色
9
10void dfs(int pos) {
11 visited[pos] = true;
12 // for (int i : G[pos]) のような書き方を「範囲 for 文」といいます。(APG4b 2.01 節)
13 for (int i : G[pos]) {
14 if (visited[i] == false) dfs(i);
15 }
16}
17
18int main() {
19 // 入力

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected