Directed Graph detecting cycle algorithm

Hey! I’m following part 2 of the course but some things do not make sense to me, for example:

When we’re talking about detecting a cycle algorithm in a directed graph, why do we need the set “all”? We already have all the nodes inside the map called “nodes”, we could get the values and use them in the for each loop;

Is this set “all” being used for an interview question or a different way of building this algorithm?

I’m loving the course! Thanks.