This commit is contained in:
Sergiu Ivanov 2021-10-31 21:43:28 +01:00
parent c1e9911bb3
commit f918eca123
1 changed files with 12 additions and 2 deletions

View File

@ -35,7 +35,7 @@
bfs bfs/generalized fewest-vertices-path bfs bfs/generalized fewest-vertices-path
dfs dfs/generalized dfs dfs/generalized
dag? tsort cc dag? tsort cc cc/bfs scc
graphviz) graphviz)
@ -177,6 +177,10 @@
(g:tsort (gg g))) (g:tsort (gg g)))
(define (cc g) (define (cc g)
(g:cc (gg g))) (g:cc (gg g)))
(define (cc/bfs g)
(g:cc/bfs (gg g)))
(define (scc g)
(g:scc (gg g)))
;; 10 Graphviz ;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f]) (define (graphviz g #:output [output #f] #:colors [colors #f])
@ -260,6 +264,8 @@
[dag? (-> Graph Boolean)] [dag? (-> Graph Boolean)]
[tsort (-> Graph (Listof Any))] [tsort (-> Graph (Listof Any))]
[cc (-> Graph (Listof (Listof Any)))] [cc (-> Graph (Listof (Listof Any)))]
[cc/bfs (-> Graph (Listof (Listof Any)))]
[scc (-> Graph (Listof (Listof Any)))]
;; 10 Graphviz ;; 10 Graphviz
[graphviz (->* (Graph) [graphviz (->* (Graph)
@ -365,7 +371,11 @@
(check-equal? (tsort (directed-graph '((a b) (b c) (a d) (d b)))) (check-equal? (tsort (directed-graph '((a b) (b c) (a d) (d b))))
'(a d b c)) '(a d b c))
(check-equal? (cc (undirected-graph '((a b) (b c) (d e)))) (check-equal? (cc (undirected-graph '((a b) (b c) (d e))))
'((e d) (a b c)))) '((e d) (a b c)))
(check-equal? (cc/bfs (undirected-graph '((a b) (b c) (d e))))
'((e d) (a b c)))
(check-equal? (scc (directed-graph '((a b) (b c) (c a) (c d) (e a))))
'((e) (c b a) (d))))
(test-case "10 Graphviz" (test-case "10 Graphviz"
(define g (directed-graph '((a b) (b c)))) (define g (directed-graph '((a b) (b c))))