depth-first search: follows paths as far as it can start at a node visit its first (unvisited) neighbor visit the neighbor's first (unvisited) neighbor and so on visit the first neighbor's next (unvisited) neighbor cycle detection topological sort of directed acyclic graph via dfs what's a topological sort? ordering of vertices such that v is after u if (u,v) is an edge in the graph pick a vertex do dfs remember which nodes were visited pick an unvisited node do dfs, finding any new unvisited nodes, append result to previous search repeat until all nodes found