Browse Source

Add valid-coloring?.

master
Sergiu Ivanov 9 months ago
parent
commit
80831c3b7c
  1. 9
      graph.rkt

9
graph.rkt

@ -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…
Cancel
Save