Partial implementation of depth-first search (no animation)