Get all cycles in an undirected graph

I know that works because there’s only 3 parts and it’s not a complex graph, so this doesn’t solve my problem sadly.