Add coloring/brelaz.

This commit is contained in:
Sergiu Ivanov 2021-11-01 10:13:52 +01:00
parent 2460d56d04
commit d855753fa3

View file

@ -42,7 +42,7 @@
bellman-ford dijkstra dag-shortest-paths
floyd-warshall transitive-closure johnson
coloring coloring/greedy
coloring coloring/greedy coloring/brelaz
graphviz)
@ -220,6 +220,8 @@
(g:coloring (gg g) num-colors #:order order))
(define (coloring/greedy g #:order [order 'smallest-last])
(g:coloring/greedy (gg g) #:order order))
(define (coloring/brelaz g)
(g:coloring/brelaz (gg g)))
;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f])
@ -334,7 +336,7 @@
'smallest-last))
(Values Number
(Mutable-HashTable Any Number)))]
[coloring/brelaz (-> Graph (Mutable-HashTable Any Number))]
;; 10 Graphviz
[graphviz (->* (Graph)
@ -547,6 +549,9 @@
(define-values (ncolors colors) (coloring/greedy g0))
(check-equal? ncolors 2)
(check-equal? (hash->ordered-list colors)
'((a . 0) (b . 1) (c . 0) (d . 1)))
(check-equal? (hash->ordered-list (coloring/brelaz g0))
'((a . 0) (b . 1) (c . 0) (d . 1))))
(test-case "10 Graphviz"