visited set
RU: множество посещённых вершин
A set (or boolean array) recording which vertices a traversal has already reached. Checking it before visiting a vertex prevents infinite loops on cycles and repeated work.
RU: множество посещённых вершин
A set (or boolean array) recording which vertices a traversal has already reached. Checking it before visiting a vertex prevents infinite loops on cycles and repeated work.