In this visualization, we demonstrate how Depth-First Search (DFS) uses three colors to track vertex states:
- White: Unvisited vertices
- Gray: Vertices currently being processed (DFS has started but not finished with them)
- Black: Completed vertices (DFS has finished processing them and all their descendants)
A cycle is detected when DFS encounters a gray vertex again during traversal.
Initialize the graph with all vertices colored white (unvisited).