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

Function main

codes/cpp/Code_4_05_2.cpp:18–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18int main() {
19 // 入力
20 cin >> N >> M;
21 for (int i = 1; i <= M; i++) {
22 cin >> A[i] >> B[i];
23 G[A[i]].push_back(B[i]);
24 G[B[i]].push_back(A[i]);
25 }
26
27 // 深さ優先探索
28 dfs(1);
29
30 // 連結かどうかの判定(Answer=true のとき連結)
31 bool Answer = true;
32 for (int i = 1; i <= N; i++) {
33 if (visited[i] == false) Answer = false;
34 }
35 if (Answer == true) cout << "The graph is connected." << endl;
36 else cout << "The graph is not connected." << endl;
37 return 0;
38}

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected