Add tsort.
This commit is contained in:
parent
f7c6c89672
commit
ed5fc4d3b8
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
bfs bfs/generalized fewest-vertices-path
|
bfs bfs/generalized fewest-vertices-path
|
||||||
dfs dfs/generalized
|
dfs dfs/generalized
|
||||||
dag?
|
dag? tsort
|
||||||
|
|
||||||
graphviz)
|
graphviz)
|
||||||
|
|
||||||
|
@ -173,6 +173,8 @@
|
||||||
#:return finish))
|
#:return finish))
|
||||||
(define (dag? g)
|
(define (dag? g)
|
||||||
(g:dag? (gg g)))
|
(g:dag? (gg g)))
|
||||||
|
(define (tsort g)
|
||||||
|
(g:tsort (gg g)))
|
||||||
|
|
||||||
;; 10 Graphviz
|
;; 10 Graphviz
|
||||||
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
||||||
|
@ -254,6 +256,7 @@
|
||||||
#:return (-> Graph Any Any))
|
#:return (-> Graph Any Any))
|
||||||
Any)]
|
Any)]
|
||||||
[dag? (-> Graph Boolean)]
|
[dag? (-> Graph Boolean)]
|
||||||
|
[tsort (-> Graph (Listof Any))]
|
||||||
|
|
||||||
;; 10 Graphviz
|
;; 10 Graphviz
|
||||||
[graphviz (->* (Graph)
|
[graphviz (->* (Graph)
|
||||||
|
@ -355,7 +358,9 @@
|
||||||
(check-equal? (dfs/generalized (directed-graph '((a b) (a c) (b d) (c d))))
|
(check-equal? (dfs/generalized (directed-graph '((a b) (a c) (b d) (c d))))
|
||||||
(void))
|
(void))
|
||||||
(check-true (dag? (directed-graph '((a b) (b c)))))
|
(check-true (dag? (directed-graph '((a b) (b c)))))
|
||||||
(check-false (dag? (directed-graph '((a b) (b a))))))
|
(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)))
|
||||||
|
|
||||||
(test-case "10 Graphviz"
|
(test-case "10 Graphviz"
|
||||||
(define g (directed-graph '((a b) (b c))))
|
(define g (directed-graph '((a b) (b c))))
|
||||||
|
|
Loading…
Reference in New Issue