Why can this not be solved using a DFS by maintaining a step count along the way. If we find a node with a smaller step count, the length of the cycle is (step_count_child - step_count_current + 1)?
I had a question what if this question wasn't to find the shortest cycle but the longest in an undirected graph?Doing the way by breadth first search would it not exclude a larger cycle if that cycle comprised of two or more smaller cycles?
Did you get all the way around?
Why can this not be solved using a DFS by maintaining a step count along the way. If we find a node with a smaller step count, the length of the cycle is (step_count_child - step_count_current + 1)?
I had a question what if this question wasn't to find the shortest cycle but the longest in an undirected graph?Doing the way by breadth first search would it not exclude a larger cycle if that cycle comprised of two or more smaller cycles?
That's a totally different problem, and it would depend on a lot of definitions, but probably exponential