(define (find-route orig dest G) (local ((define (neighbours v G) (cond [(empty? G) (error 'neighbours (string-append (symbol->string v) " not in graph"))] [else (cond [(symbol=? v (first (first G))) (second (first G))] [else (neighbours v (rest G))])])) (define (find-route-helper orig dest seen still-to-visit G) (cond [(and (empty? still-to-visit) (empty? (neighbours orig G))) false] [(member dest seen) still-to-visit] [(empty? (neighbours orig G)) (find-route-helper (first still-to-visit) dest seen (second (rest still-to-visit)) G)] [else (find-route-helper (first (neighbours orig G)) dest (append (neighbours orig G) seen) (append (list (first seen) (rest (neighbours orig G))) (list still-to-visit)) G)]))) (find-route-helper orig dest (list orig) empty G))) (define testGraph '((A (B1 B2)) (B1 (C)) (B2 (C)) (C (D1 D2)) (D1 (E)) (D2 (E)) (E ()) (F ()))) (equal? (find-route 'A 'F testGraph) false) (equal? (find-route 'A 'C testGraph) '(A B1 C))