UNPKG

maximum-matching

Version:

Implementation of Blossom's Algorithm for Maximum Matching

18 lines (17 loc) 747 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.maximumMatching = exports.maximumMatchingGraph = void 0; const MatchingGraph_1 = require("./MatchingGraph"); const findAugmentingPath_1 = require("./findAugmentingPath"); function maximumMatchingGraph(graph) { const matchingGraph = MatchingGraph_1.MatchingGraph.createFrom(graph); let augmentingPath; while ((augmentingPath = (0, findAugmentingPath_1.findAugmentingPath)(matchingGraph))) matchingGraph.augmentWith(augmentingPath); return matchingGraph; } exports.maximumMatchingGraph = maximumMatchingGraph; function maximumMatching(graph) { return maximumMatchingGraph(graph).matching(); } exports.maximumMatching = maximumMatching;