Add bipartite?.

This commit is contained in:
Sergiu Ivanov 2021-11-07 21:54:54 +01:00
parent 22a5720da0
commit a544407f68
1 changed files with 9 additions and 2 deletions

View File

@ -45,7 +45,7 @@
coloring coloring/greedy coloring/brelaz
order-smallest-last valid-coloring?
maxflow
maxflow bipartite?
graphviz)
@ -233,6 +233,8 @@
;; 9 Maximum Flow
(define (maxflow g source sink)
(g:maxflow (gg g) source sink))
(define (bipartite? g)
(g:bipartite? (gg g)))
;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f])
@ -353,6 +355,7 @@
;; 9 Maximum Flow
[maxflow (-> Graph Any Any (HashTable (List Any Any) Number))]
[bipartite? (-> Graph (U (List (Listof Any) (Listof Any)) False))]
;; 10 Graphviz
[graphviz (->* (Graph)
@ -577,7 +580,11 @@
(test-case "9 Maximum Flow"
(define g0 (weighted-graph/directed '((1 a b) (2 a c) (3 b d) (3 c d))))
(check-equal? (hash->ordered-list (maxflow g0 'a 'd))
'(((a b) . 1) ((c d) . 2) ((b d) . 1) ((a c) . 2))))
'(((a b) . 1) ((c d) . 2) ((b d) . 1) ((a c) . 2)))
(define g1 (directed-graph '((a b) (c b))))
(check-false (bipartite? g0))
(check-equal? (bipartite? g1) '((b) (a c))))
(test-case "10 Graphviz"
(define g (directed-graph '((a b) (b c))))