(defmethod interface:components ((graph undirected-graph)) (iterate (for remaining = (interface:vertices graph) then (set-difference remaining last-seen)) (as last-seen = nil) ; last-seen is reset to nil every time? (while remaining) (with components) (interface:depth-first-search graph (lambda (_ x) (declare (ignore _)) (push x last-seen)) ;; Start the component discovery at any vertex from the remaining. (first remaining)) ;; this returns a list of last-seen sets, which I think is what the original does, but if you ;; want a single set, then this should be "appending" (collecting last-seen)))