Browse Source

Add coloring/brelaz.

master
Sergiu Ivanov 10 months ago
parent
commit
d855753fa3
  1. 9
      graph.rkt

9
graph.rkt

@ -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"

Loading…
Cancel
Save