|
|
@ -32,7 +32,7 @@ |
|
|
|
undirected-graph directed-graph |
|
|
|
matrix-graph? |
|
|
|
|
|
|
|
bfs |
|
|
|
bfs fewest-vertices-path |
|
|
|
|
|
|
|
graphviz) |
|
|
|
|
|
|
@ -114,6 +114,8 @@ |
|
|
|
;; 4.1 Breadth-first Search |
|
|
|
(define (bfs g source) |
|
|
|
(g:bfs (gg g) source)) |
|
|
|
(define (fewest-vertices-path G source target) |
|
|
|
(g:fewest-vertices-path (gg G) source target)) |
|
|
|
|
|
|
|
;; 10 Graphviz |
|
|
|
(define (graphviz g #:output [output #f] #:colors [colors #f]) |
|
|
@ -166,6 +168,7 @@ |
|
|
|
;; 4.1 Breadth-first Search |
|
|
|
[bfs (-> Graph Any (Values (Mutable-HashTable Any Number) |
|
|
|
(Mutable-HashTable Any Any)))] |
|
|
|
[fewest-vertices-path (-> Graph Any Any (U (Listof Any) False))] |
|
|
|
|
|
|
|
;; 10 Graphviz |
|
|
|
[graphviz (->* (Graph) |
|
|
@ -246,7 +249,9 @@ |
|
|
|
;; 4.1 Breadth-first Search |
|
|
|
(define-values (bfs-lens bfs-tree) (bfs (directed-graph '((a b) (b c))) 'a)) |
|
|
|
(check-equal? (hash->ordered-list bfs-lens) '((a . 0) (b . 1) (c . 2))) |
|
|
|
(check-equal? (hash->ordered-list bfs-tree) '((a . #f) (b . a) (c . b)))) |
|
|
|
(check-equal? (hash->ordered-list bfs-tree) '((a . #f) (b . a) (c . b))) |
|
|
|
(check-equal? (fewest-vertices-path (directed-graph '((a b) (b c) (c d))) 'a 'd) |
|
|
|
'(a b c d))) |
|
|
|
|
|
|
|
(test-case "10 Graphviz" |
|
|
|
(define g (directed-graph '((a b) (b c)))) |
|
|
|