From 5a7431f8cf613de7cab1224aadbba90cfa1d8822 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 7 Nov 2021 22:38:10 +0100 Subject: [PATCH] Add maximum-bipartite-matching?. --- graph.rkt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/graph.rkt b/graph.rkt index adbd752..6a19a0f 100644 --- a/graph.rkt +++ b/graph.rkt @@ -45,7 +45,7 @@ coloring coloring/greedy coloring/brelaz order-smallest-last valid-coloring? - maxflow bipartite? + maxflow bipartite? maximum-bipartite-matching graphviz) @@ -235,6 +235,8 @@ (g:maxflow (gg g) source sink)) (define (bipartite? g) (g:bipartite? (gg g))) + (define (maximum-bipartite-matching g) + (g:maximum-bipartite-matching (gg g))) ;; 10 Graphviz (define (graphviz g #:output [output #f] #:colors [colors #f]) @@ -356,6 +358,7 @@ ;; 9 Maximum Flow [maxflow (-> Graph Any Any (HashTable (List Any Any) Number))] [bipartite? (-> Graph (U (List (Listof Any) (Listof Any)) False))] + [maximum-bipartite-matching (-> Graph (Listof (List Any Any)))] ;; 10 Graphviz [graphviz (->* (Graph) @@ -584,7 +587,8 @@ (define g1 (directed-graph '((a b) (c b)))) (check-false (bipartite? g0)) - (check-equal? (bipartite? g1) '((b) (a c)))) + (check-equal? (bipartite? g1) '((b) (a c))) + (check-equal? (maximum-bipartite-matching g1) '((c b)))) (test-case "10 Graphviz" (define g (directed-graph '((a b) (b c))))