Browse Source

Add cc.

master
Sergiu Ivanov 3 months ago
parent
commit
c1e9911bb3
  1. 9
      graph.rkt

9
graph.rkt

@ -35,7 +35,7 @@
bfs bfs/generalized fewest-vertices-path
dfs dfs/generalized
dag? tsort
dag? tsort cc
graphviz)
@ -175,6 +175,8 @@
(g:dag? (gg g)))
(define (tsort g)
(g:tsort (gg g)))
(define (cc g)
(g:cc (gg g)))
;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f])
@ -257,6 +259,7 @@
Any)]
[dag? (-> Graph Boolean)]
[tsort (-> Graph (Listof Any))]
[cc (-> Graph (Listof (Listof Any)))]
;; 10 Graphviz
[graphviz (->* (Graph)
@ -360,7 +363,9 @@
(check-true (dag? (directed-graph '((a b) (b c)))))
(check-false (dag? (directed-graph '((a b) (b a)))))
(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))))
'((e d) (a b c))))
(test-case "10 Graphviz"
(define g (directed-graph '((a b) (b c))))

Loading…
Cancel
Save