公式

E - Cycle Graph? 解説 by en_translator


The given graph is a cycle graph if and only if the following two conditions are met:

  • The degree of every vertex is \(2\).
  • The graph is connected.

This can be determined using DFS (Depth-First Search), BFS (Breadth-First Search), or DSU (Disjoint Set Union).

Example of wrong solution 1

  • The degree of every vertex is \(2\).

Counterexample

6 6
1 2
2 3
3 1
4 5
5 6
6 4

Example of wrong solution 2

  • Connected.
  • \(N=M\).

Counterexample

4 4
1 2
2 3
3 1
1 4

投稿日時:
最終更新: