Add dag?.
This commit is contained in:
parent
a40b1ec187
commit
f7c6c89672
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
bfs bfs/generalized fewest-vertices-path
|
bfs bfs/generalized fewest-vertices-path
|
||||||
dfs dfs/generalized
|
dfs dfs/generalized
|
||||||
|
dag?
|
||||||
|
|
||||||
graphviz)
|
graphviz)
|
||||||
|
|
||||||
|
@ -170,6 +171,8 @@
|
||||||
#:process-unvisited process-unvisited
|
#:process-unvisited process-unvisited
|
||||||
#:combine combine
|
#:combine combine
|
||||||
#:return finish))
|
#:return finish))
|
||||||
|
(define (dag? g)
|
||||||
|
(g:dag? (gg g)))
|
||||||
|
|
||||||
;; 10 Graphviz
|
;; 10 Graphviz
|
||||||
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
||||||
|
@ -250,6 +253,7 @@
|
||||||
#:combine (-> Any Any Any)
|
#:combine (-> Any Any Any)
|
||||||
#:return (-> Graph Any Any))
|
#:return (-> Graph Any Any))
|
||||||
Any)]
|
Any)]
|
||||||
|
[dag? (-> Graph Boolean)]
|
||||||
|
|
||||||
;; 10 Graphviz
|
;; 10 Graphviz
|
||||||
[graphviz (->* (Graph)
|
[graphviz (->* (Graph)
|
||||||
|
@ -349,7 +353,9 @@
|
||||||
'((a . 7) (b . 6) (c . 3) (d . 2)))
|
'((a . 7) (b . 6) (c . 3) (d . 2)))
|
||||||
|
|
||||||
(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-false (dag? (directed-graph '((a b) (b a))))))
|
||||||
|
|
||||||
(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