Add order-smallest-last.

This commit is contained in:
Sergiu Ivanov 2021-11-07 21:08:05 +01:00
parent d855753fa3
commit 8944f221e1
1 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,7 @@
floyd-warshall transitive-closure johnson floyd-warshall transitive-closure johnson
coloring coloring/greedy coloring/brelaz coloring coloring/greedy coloring/brelaz
order-smallest-last
graphviz) graphviz)
@ -222,6 +223,8 @@
(g:coloring/greedy (gg g) #:order order)) (g:coloring/greedy (gg g) #:order order))
(define (coloring/brelaz g) (define (coloring/brelaz g)
(g:coloring/brelaz (gg g))) (g:coloring/brelaz (gg g)))
(define (order-smallest-last g)
(g:order-smallest-last (gg g)))
;; 10 Graphviz ;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f]) (define (graphviz g #:output [output #f] #:colors [colors #f])
@ -337,6 +340,7 @@
(Values Number (Values Number
(Mutable-HashTable Any Number)))] (Mutable-HashTable Any Number)))]
[coloring/brelaz (-> Graph (Mutable-HashTable Any Number))] [coloring/brelaz (-> Graph (Mutable-HashTable Any Number))]
[order-smallest-last (-> Graph (Listof Any))]
;; 10 Graphviz ;; 10 Graphviz
[graphviz (->* (Graph) [graphviz (->* (Graph)
@ -552,7 +556,9 @@
'((a . 0) (b . 1) (c . 0) (d . 1))) '((a . 0) (b . 1) (c . 0) (d . 1)))
(check-equal? (hash->ordered-list (coloring/brelaz g0)) (check-equal? (hash->ordered-list (coloring/brelaz g0))
'((a . 0) (b . 1) (c . 0) (d . 1)))) '((a . 0) (b . 1) (c . 0) (d . 1)))
(check-equal? (order-smallest-last g0) '(c d a b)))
(test-case "10 Graphviz" (test-case "10 Graphviz"
(define g (directed-graph '((a b) (b c)))) (define g (directed-graph '((a b) (b c))))