Part 1: If every component of G induces a cycle, then G is regular with all vertices of degree two.
- Assumption: Every component of G induces a cycle.
- Cycles: A cycle is a graph where each vertex has exactly two neighbors. Therefore, in a cycle, every vertex has a degree of 2.
- Components: Components are disconnected parts of a graph. If every component is a cycle, then every vertex in every component must have degree 2.
- Regularity: A graph is regular if all vertices have the same degree. Since every vertex in G has degree 2, G is a regular graph with all vertices of degree 2.
Part 2: If G is regular with all vertices of degree two, then every component of G induces a cycle.
- Assumption: G is regular with all vertices of degree 2.
- Connected Components: Consider any connected component C of G. Since G is regular with degree 2, every vertex in C has degree 2.
- Paths and Cycles:
- Start at any vertex v in C. Since v has degree 2, it has two neighbors.
- Follow a path from v to one of its neighbors. Continue following this path, visiting new vertices.
- Since the component is finite, and every vertex has degree 2, you will eventually revisit a vertex you have already encountered.
- This means you have found a cycle.
- Component as a Cycle:
- Now, we need to show that this cycle is the entire component C.
- Suppose there is a vertex w in C that is not in the cycle. Since w is in the same component as the cycle, there must be a path from w to a vertex in the cycle.
- However, every vertex in the cycle has degree 2, meaning that all edges connected to these vertices are already used to form the cycle.
- Since every node in the graph has degree 2, it is impossible for a vertex not in the cycle to connect to a vertex in the cycle.
- Therefore, there cannot be any vertex outside the cycle, and the component C must be the cycle itself.
- Conclusion: Since this holds for any connected component of G, every component of G induces a cycle.
Therefore, a graph G is regular with all vertices of degree two if and only if every component of G induces a cycle.
🧠Prove it with Python
https://gist.github.com/viadean/ff3c4e67d64c1b57bacc3fd84ea64401
Output
Graph is 2-regular: True
Every component is a cycle: True
Graph H is 2-regular: True
Every component in H is a cycle: True
Graph J is 2-regular: False
Every component in J is a cycle: False