Add valid-coloring?.
This commit is contained in:
parent
8944f221e1
commit
80831c3b7c
1 changed files with 7 additions and 2 deletions
|
@ -43,7 +43,7 @@
|
|||
floyd-warshall transitive-closure johnson
|
||||
|
||||
coloring coloring/greedy coloring/brelaz
|
||||
order-smallest-last
|
||||
order-smallest-last valid-coloring?
|
||||
|
||||
graphviz)
|
||||
|
||||
|
@ -225,6 +225,8 @@
|
|||
(g:coloring/brelaz (gg g)))
|
||||
(define (order-smallest-last g)
|
||||
(g:order-smallest-last (gg g)))
|
||||
(define (valid-coloring? g coloring)
|
||||
(g:valid-coloring? (gg g) coloring))
|
||||
|
||||
;; 10 Graphviz
|
||||
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
||||
|
@ -341,6 +343,7 @@
|
|||
(Mutable-HashTable Any Number)))]
|
||||
[coloring/brelaz (-> Graph (Mutable-HashTable Any Number))]
|
||||
[order-smallest-last (-> Graph (Listof Any))]
|
||||
[valid-coloring? (-> Graph (HashTable Any Number) Boolean)]
|
||||
|
||||
;; 10 Graphviz
|
||||
[graphviz (->* (Graph)
|
||||
|
@ -558,7 +561,9 @@
|
|||
(check-equal? (hash->ordered-list (coloring/brelaz g0))
|
||||
'((a . 0) (b . 1) (c . 0) (d . 1)))
|
||||
|
||||
(check-equal? (order-smallest-last g0) '(c d a b)))
|
||||
(check-equal? (order-smallest-last g0) '(c d a b))
|
||||
|
||||
(check-true (valid-coloring? g0 #hash((a . 0) (b . 1) (c . 0) (d . 2)))))
|
||||
|
||||
(test-case "10 Graphviz"
|
||||
(define g (directed-graph '((a b) (b c))))
|
||||
|
|
Loading…
Reference in a new issue