(defmethod interface:components ((graph undirected-graph)) (do* ((remaining (interface:vertices graph) (set-difference remaining last-seen)) (interface:components '() (cons last-seen interface:components)) (last-seen '() '())) ((null remaining) interface:components) ;; A component is created by recording all the targets in a ;; depth-first search. (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))))