Part 1: If every component of G induces a cycle, then G is regular with all vertices of degree two.

Part 2: If G is regular with all vertices of degree two, then 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