(define (acyclic? graph) (if (null? graph) #t (let ((sink (find-sink graph))) (if sink (acyclic? (remove-node (first sink) graph)) #f)))) (define (find-sink graph) (if (null? graph) #f (if (sink? (first graph)) (first graph) (find-sink (rest graph))))) (define (sink? node) (null? (rest node))) (define (remove-node sink graph) (if (null? graph) () (if (equal? sink (first (first graph))) (remove-node sink (rest graph)) (cons (remove-target sink (first graph)) (remove-node sink (rest graph)))))) (define (remove-target sink node) (cons (first node) (remove-elements sink (rest node)))) (define (remove-elements sink L) (if (null? L) () (if (equal? sink (first L)) (remove-elements sink (rest L)) (cons (first L) (remove-elements sink (rest L)))))) (define g1 '((a b c) (b c d) (c e) (d b e) (e))) (define g2 '((a b c) (b c d) (c e) (d e) (e)))