From 87b5edfa6bac48ab408acec907aa830805ea4468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Sun, 11 Feb 2018 13:09:35 +0100 Subject: [PATCH] rebuild --- lib/maxback.js | 438 -------------------------------------- lib/maxback/_contract.js | 118 ++++++++++ lib/maxback/_order.js | 203 ++++++++++++++++++ lib/maxback/_smallcuts.js | 117 ++++++++++ lib/maxback/index.js | 36 ++++ lib/maxback/maxback.js | 41 ++++ lib/maxback/mb.js | 21 ++ lib/outgoingedges.js | 137 ++++++++++++ 8 files changed, 673 insertions(+), 438 deletions(-) delete mode 100644 lib/maxback.js create mode 100644 lib/maxback/_contract.js create mode 100644 lib/maxback/_order.js create mode 100644 lib/maxback/_smallcuts.js create mode 100644 lib/maxback/index.js create mode 100644 lib/maxback/maxback.js create mode 100644 lib/maxback/mb.js create mode 100644 lib/outgoingedges.js diff --git a/lib/maxback.js b/lib/maxback.js deleted file mode 100644 index 24176a0..0000000 --- a/lib/maxback.js +++ /dev/null @@ -1,438 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = maxback; - -var _jsItertools = require('@aureooms/js-itertools'); - -var _jsCompare = require('@aureooms/js-compare'); - -var _jsPairingHeap = require('@aureooms/js-pairing-heap'); - -var _adj = require('./adj'); - -var _adj2 = _interopRequireDefault(_adj); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _marked = /*#__PURE__*/regeneratorRuntime.mark(_cuts), - _marked2 = /*#__PURE__*/regeneratorRuntime.mark(_constructcut), - _marked3 = /*#__PURE__*/regeneratorRuntime.mark(_order); - -/** - * M...-B... poly-time algorithm. - * - * @param edges List of edges of a undirected unweighted connected loopless multigraph G. - * @returns {Array} A minimum cut of G. - */ -function maxback(edges) { - var G = (0, _adj2.default)(edges); - return _maxback(G); -} - -function _maxback(G) { - return (0, _jsItertools.min)((0, _jsCompare.len)(_jsCompare.increasing), _cuts(G), undefined); -} - -function _cuts(G) { - var ordering, cut; - return regeneratorRuntime.wrap(function _cuts$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if (!(G.size >= 2)) { - _context.next = 8; - break; - } - - ordering = (0, _jsItertools.list)(_order(G)); - cut = (0, _jsItertools.list)(_constructcut(G, ordering)); - _context.next = 5; - return cut; - - case 5: - - G = _contract(G, ordering); - - _context.next = 0; - break; - - case 8: - case 'end': - return _context.stop(); - } - } - }, _marked, this); -} - -function _contract(G, ordering) { - - var x = ordering[ordering.length - 2]; - var y = ordering[ordering.length - 1]; - - var H = new Map(); - - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = (0, _jsItertools.head)(ordering, -2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var u = _step.value; - - var n = []; - H.set(u, n); - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = G.get(u)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var _v2 = _step4.value; - n.push(_v2 === y ? x : _v2); - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - var nx = []; - H.set(x, nx); - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = G.get(x)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var v = _step2.value; - if (v !== y) nx.push(v); - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = G.get(y)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var _v = _step3.value; - if (_v !== x && _v !== y) nx.push(_v); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } - - return H; -} - -function _constructcut(G, ordering) { - var u, _iteratorNormalCompletion5, _didIteratorError5, _iteratorError5, _iterator5, _step5, v; - - return regeneratorRuntime.wrap(function _constructcut$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - u = ordering[ordering.length - 1]; - _iteratorNormalCompletion5 = true; - _didIteratorError5 = false; - _iteratorError5 = undefined; - _context2.prev = 4; - _iterator5 = G.get(u)[Symbol.iterator](); - - case 6: - if (_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done) { - _context2.next = 13; - break; - } - - v = _step5.value; - _context2.next = 10; - return [u, v]; - - case 10: - _iteratorNormalCompletion5 = true; - _context2.next = 6; - break; - - case 13: - _context2.next = 19; - break; - - case 15: - _context2.prev = 15; - _context2.t0 = _context2['catch'](4); - _didIteratorError5 = true; - _iteratorError5 = _context2.t0; - - case 19: - _context2.prev = 19; - _context2.prev = 20; - - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - - case 22: - _context2.prev = 22; - - if (!_didIteratorError5) { - _context2.next = 25; - break; - } - - throw _iteratorError5; - - case 25: - return _context2.finish(22); - - case 26: - return _context2.finish(19); - - case 27: - case 'end': - return _context2.stop(); - } - } - }, _marked2, this, [[4, 15, 19, 27], [20,, 22, 26]]); -} - -function _order(G) { - var heap, refs, _iteratorNormalCompletion6, _didIteratorError6, _iteratorError6, _iterator6, _step6, v, _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, _, u, _iteratorNormalCompletion8, _didIteratorError8, _iteratorError8, _iterator8, _step8, _v3, ref; - - return regeneratorRuntime.wrap(function _order$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - heap = new _jsPairingHeap.PairingHeap((0, _jsCompare.attr)(_jsCompare.decreasing, 'key')); - refs = new Map(); - _iteratorNormalCompletion6 = true; - _didIteratorError6 = false; - _iteratorError6 = undefined; - _context3.prev = 5; - - - for (_iterator6 = G.keys()[Symbol.iterator](); !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { - v = _step6.value; - refs.set(v, heap.push({ key: 0, value: v })); - }_context3.next = 13; - break; - - case 9: - _context3.prev = 9; - _context3.t0 = _context3['catch'](5); - _didIteratorError6 = true; - _iteratorError6 = _context3.t0; - - case 13: - _context3.prev = 13; - _context3.prev = 14; - - if (!_iteratorNormalCompletion6 && _iterator6.return) { - _iterator6.return(); - } - - case 16: - _context3.prev = 16; - - if (!_didIteratorError6) { - _context3.next = 19; - break; - } - - throw _iteratorError6; - - case 19: - return _context3.finish(16); - - case 20: - return _context3.finish(13); - - case 21: - _iteratorNormalCompletion7 = true; - _didIteratorError7 = false; - _iteratorError7 = undefined; - _context3.prev = 24; - _iterator7 = G[Symbol.iterator](); - - case 26: - if (_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done) { - _context3.next = 63; - break; - } - - _ = _step7.value; - u = heap.pop().value; - _context3.next = 31; - return u; - - case 31: - refs.delete(u); - - // update keys - _iteratorNormalCompletion8 = true; - _didIteratorError8 = false; - _iteratorError8 = undefined; - _context3.prev = 35; - _iterator8 = G.get(u)[Symbol.iterator](); - - case 37: - if (_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done) { - _context3.next = 46; - break; - } - - _v3 = _step8.value; - - if (refs.has(_v3)) { - _context3.next = 41; - break; - } - - return _context3.abrupt('continue', 43); - - case 41: - ref = refs.get(_v3); - // max heap so decrease-key is used for + - - heap.decreasekey(ref, { - key: ref.value.key + 1, - value: ref.value.value - }); - - case 43: - _iteratorNormalCompletion8 = true; - _context3.next = 37; - break; - - case 46: - _context3.next = 52; - break; - - case 48: - _context3.prev = 48; - _context3.t1 = _context3['catch'](35); - _didIteratorError8 = true; - _iteratorError8 = _context3.t1; - - case 52: - _context3.prev = 52; - _context3.prev = 53; - - if (!_iteratorNormalCompletion8 && _iterator8.return) { - _iterator8.return(); - } - - case 55: - _context3.prev = 55; - - if (!_didIteratorError8) { - _context3.next = 58; - break; - } - - throw _iteratorError8; - - case 58: - return _context3.finish(55); - - case 59: - return _context3.finish(52); - - case 60: - _iteratorNormalCompletion7 = true; - _context3.next = 26; - break; - - case 63: - _context3.next = 69; - break; - - case 65: - _context3.prev = 65; - _context3.t2 = _context3['catch'](24); - _didIteratorError7 = true; - _iteratorError7 = _context3.t2; - - case 69: - _context3.prev = 69; - _context3.prev = 70; - - if (!_iteratorNormalCompletion7 && _iterator7.return) { - _iterator7.return(); - } - - case 72: - _context3.prev = 72; - - if (!_didIteratorError7) { - _context3.next = 75; - break; - } - - throw _iteratorError7; - - case 75: - return _context3.finish(72); - - case 76: - return _context3.finish(69); - - case 77: - case 'end': - return _context3.stop(); - } - } - }, _marked3, this, [[5, 9, 13, 21], [14,, 16, 20], [24, 65, 69, 77], [35, 48, 52, 60], [53,, 55, 59], [70,, 72, 76]]); -} -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tYXhiYWNrLmpzIl0sIm5hbWVzIjpbIm1heGJhY2siLCJfY3V0cyIsIl9jb25zdHJ1Y3RjdXQiLCJfb3JkZXIiLCJlZGdlcy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3QgdiBvZiBHLmdldCh1KSApIHtcblx0XHRcdGlmICghcmVmcy5oYXModikpIGNvbnRpbnVlO1xuXHRcdFx0Y29uc3QgcmVmID0gcmVmcy5nZXQodik7XG5cdFx0XHQvLyBtYXggaGVhcCBzbyBkZWNyZWFzZS1rZXkgaXMgdXNlZCBmb3IgK1xuXHRcdFx0aGVhcC5kZWNyZWFzZWtleShyZWYsIHtcblx0XHRcdFx0a2V5IDogcmVmLnZhbHVlLmtleSArIDEgLFxuXHRcdFx0XHR2YWx1ZSA6IHJlZi52YWx1ZS52YWx1ZVxuXHRcdFx0fSApO1xuXHRcdH1cblxuXHR9XG5cbn1cbiJdfQ== \ No newline at end of file diff --git a/lib/maxback/_contract.js b/lib/maxback/_contract.js new file mode 100644 index 0000000..d96c623 --- /dev/null +++ b/lib/maxback/_contract.js @@ -0,0 +1,118 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _contract; + +var _jsItertools = require('@aureooms/js-itertools'); + +function _contract(G, ordering) { + + var x = ordering[ordering.length - 2]; + var y = ordering[ordering.length - 1]; + + var H = new Map(); + + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = (0, _jsItertools.head)(ordering, -2)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var u = _step.value; + + var n = []; + H.set(u, n); + var _iteratorNormalCompletion4 = true; + var _didIteratorError4 = false; + var _iteratorError4 = undefined; + + try { + for (var _iterator4 = G.get(u)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { + var _v2 = _step4.value; + n.push(_v2 === y ? x : _v2); + } + } catch (err) { + _didIteratorError4 = true; + _iteratorError4 = err; + } finally { + try { + if (!_iteratorNormalCompletion4 && _iterator4.return) { + _iterator4.return(); + } + } finally { + if (_didIteratorError4) { + throw _iteratorError4; + } + } + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + var nx = []; + H.set(x, nx); + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = G.get(x)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var v = _step2.value; + if (v !== y) nx.push(v); + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = G.get(y)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var _v = _step3.value; + if (_v !== x && _v !== y) nx.push(_v); + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + + return H; +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL19jb250cmFjdC5qcyJdLCJuYW1lcyI6WyJfY29udHJhY3QiLCJHIiwib3JkZXJpbmciLCJ4IiwibGVuZ3RoIiwieSIsIkgiLCJNYXAiLCJ1IiwibiIsInNldCIsImdldCIsInYiLCJwdXNoIiwibngiXSwibWFwcGluZ3MiOiI7Ozs7O2tCQUV3QkEsUzs7QUFGeEI7O0FBRWUsU0FBU0EsU0FBVCxDQUFxQkMsQ0FBckIsRUFBd0JDLFFBQX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eCkgKSBpZiAoIHYgIT09IHkgKSBueC5wdXNoKHYpO1xuXHRmb3IgKCBjb25zdCB2IG9mIEcuZ2V0KHkpICkgaWYgKCB2ICE9PSB4ICYmIHYgIT09IHkgKSBueC5wdXNoKHYpO1xuXHRyZXR1cm4gSDtcblxufVxuIl19 \ No newline at end of file diff --git a/lib/maxback/_order.js b/lib/maxback/_order.js new file mode 100644 index 0000000..a40d9fd --- /dev/null +++ b/lib/maxback/_order.js @@ -0,0 +1,203 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _order; + +var _jsCompare = require('@aureooms/js-compare'); + +var _jsPairingHeap = require('@aureooms/js-pairing-heap'); + +var _marked = /*#__PURE__*/regeneratorRuntime.mark(_order); + +function _order(G) { + var heap, refs, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, v, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _, max, u, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, _v, ref; + + return regeneratorRuntime.wrap(function _order$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + heap = new _jsPairingHeap.PairingHeap((0, _jsCompare.attr)(_jsCompare.decreasing, 'key')); + refs = new Map(); + _iteratorNormalCompletion = true; + _didIteratorError = false; + _iteratorError = undefined; + _context.prev = 5; + + + for (_iterator = G.keys()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + v = _step.value; + refs.set(v, heap.push({ key: 0, value: v })); + }_context.next = 13; + break; + + case 9: + _context.prev = 9; + _context.t0 = _context['catch'](5); + _didIteratorError = true; + _iteratorError = _context.t0; + + case 13: + _context.prev = 13; + _context.prev = 14; + + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + + case 16: + _context.prev = 16; + + if (!_didIteratorError) { + _context.next = 19; + break; + } + + throw _iteratorError; + + case 19: + return _context.finish(16); + + case 20: + return _context.finish(13); + + case 21: + _iteratorNormalCompletion2 = true; + _didIteratorError2 = false; + _iteratorError2 = undefined; + _context.prev = 24; + _iterator2 = G[Symbol.iterator](); + + case 26: + if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { + _context.next = 64; + break; + } + + _ = _step2.value; + max = heap.pop(); + u = max.value; + _context.next = 32; + return [u, max.key]; + + case 32: + refs.delete(u); + + // update keys + _iteratorNormalCompletion3 = true; + _didIteratorError3 = false; + _iteratorError3 = undefined; + _context.prev = 36; + _iterator3 = G.get(u)[Symbol.iterator](); + + case 38: + if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) { + _context.next = 47; + break; + } + + _v = _step3.value; + + if (refs.has(_v)) { + _context.next = 42; + break; + } + + return _context.abrupt('continue', 44); + + case 42: + ref = refs.get(_v); + // max heap so decrease-key is used for + + + heap.decreasekey(ref, { + key: ref.value.key + 1, + value: ref.value.value + }); + + case 44: + _iteratorNormalCompletion3 = true; + _context.next = 38; + break; + + case 47: + _context.next = 53; + break; + + case 49: + _context.prev = 49; + _context.t1 = _context['catch'](36); + _didIteratorError3 = true; + _iteratorError3 = _context.t1; + + case 53: + _context.prev = 53; + _context.prev = 54; + + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + + case 56: + _context.prev = 56; + + if (!_didIteratorError3) { + _context.next = 59; + break; + } + + throw _iteratorError3; + + case 59: + return _context.finish(56); + + case 60: + return _context.finish(53); + + case 61: + _iteratorNormalCompletion2 = true; + _context.next = 26; + break; + + case 64: + _context.next = 70; + break; + + case 66: + _context.prev = 66; + _context.t2 = _context['catch'](24); + _didIteratorError2 = true; + _iteratorError2 = _context.t2; + + case 70: + _context.prev = 70; + _context.prev = 71; + + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + + case 73: + _context.prev = 73; + + if (!_didIteratorError2) { + _context.next = 76; + break; + } + + throw _iteratorError2; + + case 76: + return _context.finish(73); + + case 77: + return _context.finish(70); + + case 78: + case 'end': + return _context.stop(); + } + } + }, _marked, this, [[5, 9, 13, 21], [14,, 16, 20], [24, 66, 70, 78], [36, 49, 53, 61], [54,, 56, 60], [71,, 73, 77]]); +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL19vcmRlci5qcyJdLCJuYW1lcyI6WyJfb3JkZXIiLCJHIiwiaGVhcCIsInJlZnMiLCJNYXAiLCJrZXlzIiwidiIsInNldCIsInB1c2giLCJrZXkiLCJ2YWx1ZSIsIl8iLCJtYXgiLCJwb3AiLCJ1IiwiZGVsZXRlIiwiZ2V0IiwiaGFzIiwicmVmIiwiZGVjcmVhc2VrZXkiXSwibWFwcGluZ3MiOiI7Ozs7O2tCQUd5QkEsTTs7QUFIekI7O0FBQ0E7O21EQUV5QkEsTTs7QUFBVixTQUFVQSxNQUFWLENBQW1CQyxDQUFuQjtBQUFBOztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBRVJDLFNBRlEsR0FFRCwrQkFBaUIsNENBQW1CLEtBQW5CLENBQWpCLENBRkM7QUFHUkMsU0FIUSxHQUdELElBQUlDLEdBQUosRUFIQztBQUFBO0FBQUE7QUFBQTtBQUFBOzs7QUFLZCxzQkFBaUJILEVBQUVJLElBQUYsRUFBakI7QUFBWUMsT0FBWjtBQUE0QkgsV0FBS0ksR0FBTCxDQUFTRCxDQUFULEVBQVlKLEtBQUtNLElBQUwsQ0FBVSxFQUFFQyxLQUFNLENBQVIsRUFBWUMsT0FBUUosQ0FBcEIsRUFBVixDQUFaO0FBQTVCLE1BTGM7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBO0FBQUE7QUFBQTs7QUFBQTtBQUFBO0FBQUE7O0FBQUE7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTs7QUFBQTs7QUFBQTtBQUFBOztBQUFBO0FBQUE7O0FBQUE7QUFBQTtBQUFBO0FB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ZvciArXG5cdFx0XHRoZWFwLmRlY3JlYXNla2V5KHJlZiwge1xuXHRcdFx0XHRrZXkgOiByZWYudmFsdWUua2V5ICsgMSAsXG5cdFx0XHRcdHZhbHVlIDogcmVmLnZhbHVlLnZhbHVlXG5cdFx0XHR9ICk7XG5cdFx0fVxuXG5cdH1cblxufVxuIl19 \ No newline at end of file diff --git a/lib/maxback/_smallcuts.js b/lib/maxback/_smallcuts.js new file mode 100644 index 0000000..f77fd77 --- /dev/null +++ b/lib/maxback/_smallcuts.js @@ -0,0 +1,117 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +exports.default = _smallcuts; + +var _jsItertools = require('@aureooms/js-itertools'); + +var _order2 = require('./_order'); + +var _order3 = _interopRequireDefault(_order2); + +var _contract2 = require('./_contract'); + +var _contract3 = _interopRequireDefault(_contract2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _marked = /*#__PURE__*/regeneratorRuntime.mark(_smallcuts); + +function _smallcuts(G) { + var H, id, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, v, ordering, x, y, U, V; + + return regeneratorRuntime.wrap(function _smallcuts$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + H = G; + id = new Map(); + _iteratorNormalCompletion = true; + _didIteratorError = false; + _iteratorError = undefined; + _context.prev = 5; + + for (_iterator = G.keys()[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + v = _step.value; + id.set(v, [v]); + }_context.next = 13; + break; + + case 9: + _context.prev = 9; + _context.t0 = _context['catch'](5); + _didIteratorError = true; + _iteratorError = _context.t0; + + case 13: + _context.prev = 13; + _context.prev = 14; + + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + + case 16: + _context.prev = 16; + + if (!_didIteratorError) { + _context.next = 19; + break; + } + + throw _iteratorError; + + case 19: + return _context.finish(16); + + case 20: + return _context.finish(13); + + case 21: + if (!(H.size >= 2)) { + _context.next = 33; + break; + } + + ordering = (0, _jsItertools.list)((0, _order3.default)(H)); + x = ordering[ordering.length - 2][0]; + y = ordering[ordering.length - 1][0]; + U = new Set((0, _jsItertools.chain)((0, _jsItertools.map)(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + u = _ref2[0], + _ = _ref2[1]; + + return id.get(u); + }, (0, _jsItertools.head)(ordering, -1)))); + V = new Set(id.get(y)); + _context.next = 29; + return { 'partition': [U, V], 'size': ordering[ordering.length - 1][1] }; + + case 29: + + id.set(x, id.get(x).concat(id.get(y))); + + H = (0, _contract3.default)(H, (0, _jsItertools.list)((0, _jsItertools.map)(function (_ref3) { + var _ref4 = _slicedToArray(_ref3, 2), + u = _ref4[0], + _ = _ref4[1]; + + return u; + }, ordering))); + + _context.next = 21; + break; + + case 33: + case 'end': + return _context.stop(); + } + } + }, _marked, this, [[5, 9, 13, 21], [14,, 16, 20]]); +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL19zbWFsbGN1dHMuanMiXSwibmFtZXMiOlsiX3NtYWxsY3V0cyIsIkciLCJIIiwiaWQiLCJNYXAiLCJrZXlzIiwidiIsInNldCIsInNpemUiLCJvcmRlcmluZyIsIngiLCJsZW5ndGgiLCJ5IiwiVSIsIlNldCIsInUiLCJfIiwiZ2V0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XG5cblx0bGV0IEggPSBHO1xuXHRjb25zdCBpZCA9IG5ldyBNYXAoKTtcblx0Zm9yICggY29uc3QgdiBvZiBHLmtleXMoKSkgaWQuc2V0KHYsW3ZdKTtcblxuXHR3aGlsZSAoIEguc2l6ZSA+PSAyICkge1xuXG5cdFx0Y29uc3Qgb3JkZXJpbmcgPSBsaXN0KF9vcmRlcihIKSk7XG5cdFx0Y29uc3QgeCA9IG9yZGVyaW5nW29yZGVyaW5nLmxlbmd0aC0yXVswXTtcblx0XHRjb25zdCB5ID0gb3JkZXJpbmdbb3JkZXJpbmcubGVuZ3RoLTFdWzBdO1xuXG5cdFx0Y29uc3QgVSA9IG5ldyBTZXQoY2hhaW4obWFwKCAoW3UsX10pID0+IGlkLmdldCh1KSAsIGhlYWQob3JkZXJpbmcsLTEpICkgKSk7XG5cdFx0Y29uc3QgViA9IG5ldyBTZXQoaWQuZ2V0KHkpKTtcblxuXHRcdHlpZWxkIHsgJ3BhcnRpdGlvbicgOiBbIFUgLCBWIF0gLCAnc2l6ZScgOiBvcmRlcmluZ1tvcmRlcmluZy5sZW5ndGgtMV1bMV0gfSA7XG5cblx0XHRpZC5zZXQoeCwgaWQuZ2V0KHgpLmNvbmNhdChpZC5nZXQoeSkpKTtcblxuXHRcdEggPSBfY29udHJhY3QoSCwgbGlzdChtYXAoKFt1LF9dKSA9PiB1ICwgb3JkZXJpbmcpKSk7XG5cblx0fVxuXG59XG4iXX0= \ No newline at end of file diff --git a/lib/maxback/index.js b/lib/maxback/index.js new file mode 100644 index 0000000..d2e2887 --- /dev/null +++ b/lib/maxback/index.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.mb = exports.maxback = exports._smallcuts = exports._order = exports._contract = undefined; + +var _contract2 = require('./_contract'); + +var _contract3 = _interopRequireDefault(_contract2); + +var _order2 = require('./_order'); + +var _order3 = _interopRequireDefault(_order2); + +var _smallcuts2 = require('./_smallcuts'); + +var _smallcuts3 = _interopRequireDefault(_smallcuts2); + +var _maxback = require('./maxback'); + +var _maxback2 = _interopRequireDefault(_maxback); + +var _mb = require('./mb'); + +var _mb2 = _interopRequireDefault(_mb); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = _maxback2.default; +exports._contract = _contract3.default; +exports._order = _order3.default; +exports._smallcuts = _smallcuts3.default; +exports.maxback = _maxback2.default; +exports.mb = _mb2.default; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL2luZGV4LmpzIl0sIm5hbWVzIjpbIl9jb250cmFjdCIsIl9vcmRlciIsIl9zbWFsbGN1dHMiLCJtYXhiYWNrIiwibWIiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7OztBQUNBOzs7O0FBQ0E7Ozs7QUFDQTs7OztBQUNBOzs7Ozs7O1FBS0NBLFM7UUFDQUMsTTtRQUNBQyxVO1FBQ0FDLE87UUFDQUMsRSIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBfY29udHJhY3QgZnJvbSAnLi9fY29udHJhY3QnIDtcbmltcG9ydCBfb3JkZXIgZnJvbSAnLi9fb3JkZXInIDtcbmltcG9ydCBfc21hbGxjdXRzIGZyb20gJy4vX3NtYWxsY3V0cycgO1xuaW1wb3J0IG1heGJhY2sgZnJvbSAnLi9tYXhiYWNrJyA7XG5pbXBvcnQgbWIgZnJvbSAnLi9tYicgO1xuXG5leHBvcnQgZGVmYXVsdCBtYXhiYWNrIDtcblxuZXhwb3J0IHtcblx0X2NvbnRyYWN0ICxcblx0X29yZGVyICxcblx0X3NtYWxsY3V0cyAsXG5cdG1heGJhY2sgLFxuXHRtYiAsXG59IDtcbiJdfQ== \ No newline at end of file diff --git a/lib/maxback/maxback.js b/lib/maxback/maxback.js new file mode 100644 index 0000000..d76456c --- /dev/null +++ b/lib/maxback/maxback.js @@ -0,0 +1,41 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +exports.default = maxback; + +var _adj = require('../adj'); + +var _adj2 = _interopRequireDefault(_adj); + +var _mb2 = require('./mb'); + +var _mb3 = _interopRequireDefault(_mb2); + +var _outgoingedges = require('../outgoingedges'); + +var _outgoingedges2 = _interopRequireDefault(_outgoingedges); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Nagamochi-Ibaraki poly-time algorithm. + * + * @param edges List of edges of a undirected unweighted connected loopless multigraph G. + * @returns {Array} A minimum cut of G. + */ +function maxback(edges) { + var G = (0, _adj2.default)(edges); + + var _mb = (0, _mb3.default)(G), + _mb$partition = _slicedToArray(_mb.partition, 2), + U = _mb$partition[0], + _ = _mb$partition[1]; + + return (0, _outgoingedges2.default)(G, U); +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL21heGJhY2suanMiXSwibmFtZXMiOlsibWF4YmFjayIsImVkZ2VzIiwiRyIsInBhcnRpdGlvbiIsIlUiLCJfIl0sIm1hcHBpbmdzIjoiOzs7Ozs7OztrQkFVd0JBLE87O0FBVnhCOzs7O0FBQ0E7Ozs7QUFDQTs7Ozs7O0FBRUE7Ozs7OztBQU1lLFNBQVNBLE9BQVQsQ0FBbUJDLEtBQW5CLEVBQTJCO0FBQ3pDLE1BQU1DLElBQUksbUJBQUtELEtBQUwsQ0FBVjs7QUFEeUMsWUFFUCxrQkFBSUMsQ0FBSixDQUZPO0FBQUEseUNBRWpDQyxTQUZpQztBQUFBLE1BRW5CQyxDQUZtQjtBQUFBLE1BRWZDLENBRmU7O0FBR3pDLFNBQU8sNkJBQWVILENBQWYsRUFBbUJFLENBQW5CLENBQVA7QUFDQSIsImZpbGUiOiJtYXhiYWNrLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGFkaiBmcm9tICcuLi9hZGonO1xuaW1wb3J0IG1iIGZyb20gJy4vbWInO1xuaW1wb3J0IG91dGdvaW5nZWRnZXMgZnJvbSAnLi4vb3V0Z29pbmdlZGdlcyc7XG5cbi8qKlxuICogTmFnYW1vY2hpLUliYXJha2kgcG9seS10aW1lIGFsZ29yaXRobS5cbiAqXG4gKiBAcGFyYW0gZWRnZXMgTGlzdCBvZiBlZGdlcyBvZiBhIHVuZGlyZWN0ZWQgdW53ZWlnaHRlZCBjb25uZWN0ZWQgbG9vcGxlc3MgbXVsdGlncmFwaCBHLlxuICogQHJldHVybnMge0FycmF5fSBBIG1pbmltdW0gY3V0IG9mIEcuXG4gKi9cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIG1heGJhY2sgKCBlZGdlcyApIHtcblx0Y29uc3QgRyA9IGFkaiggZWRnZXMgKSA7XG5cdGNvbnN0IHsgcGFydGl0aW9uIDogWyBVICwgXyBdIH0gPSBtYiggRyApIDtcblx0cmV0dXJuIG91dGdvaW5nZWRnZXMoIEcgLCBVICkgO1xufVxuIl19 \ No newline at end of file diff --git a/lib/maxback/mb.js b/lib/maxback/mb.js new file mode 100644 index 0000000..2d6e53d --- /dev/null +++ b/lib/maxback/mb.js @@ -0,0 +1,21 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = mb; + +var _jsItertools = require('@aureooms/js-itertools'); + +var _jsCompare = require('@aureooms/js-compare'); + +var _smallcuts2 = require('./_smallcuts'); + +var _smallcuts3 = _interopRequireDefault(_smallcuts2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function mb(G) { + return (0, _jsItertools.min)((0, _jsCompare.attr)(_jsCompare.increasing, 'size'), (0, _smallcuts3.default)(G), undefined); +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYXhiYWNrL21iLmpzIl0sIm5hbWVzIjpbIm1iIiwiRyIsInVuZGVmaW5lZCJdLCJtYXBwaW5ncyI6Ijs7Ozs7a0JBS3dCQSxFOztBQUx4Qjs7QUFDQTs7QUFFQTs7Ozs7O0FBRWUsU0FBU0EsRUFBVCxDQUFjQyxDQUFkLEVBQWtCO0FBQ2hDLFFBQU8sc0JBQUssNENBQW1CLE1BQW5CLENBQUwsRUFBbUMseUJBQVdBLENBQVgsQ0FBbkMsRUFBbURDLFNBQW5ELENBQVA7QUFDQSIsImZpbGUiOiJtYi5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IG1pbiB9IGZyb20gJ0BhdXJlb29tcy9qcy1pdGVydG9vbHMnIDtcbmltcG9ydCB7IGF0dHIgLCBpbmNyZWFzaW5nIH0gZnJvbSAnQGF1cmVvb21zL2pzLWNvbXBhcmUnIDtcblxuaW1wb3J0IF9zbWFsbGN1dHMgZnJvbSAnLi9fc21hbGxjdXRzJyA7XG5cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIG1iICggRyApIHtcblx0cmV0dXJuIG1pbiggYXR0ciggaW5jcmVhc2luZyAsICdzaXplJyApICwgX3NtYWxsY3V0cyhHKSAsIHVuZGVmaW5lZCApIDtcbn1cbiJdfQ== \ No newline at end of file diff --git a/lib/outgoingedges.js b/lib/outgoingedges.js new file mode 100644 index 0000000..7188389 --- /dev/null +++ b/lib/outgoingedges.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = outgoingedges; + +var _marked = /*#__PURE__*/regeneratorRuntime.mark(outgoingedges); + +function outgoingedges(G, U) { + var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, u, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, v; + + return regeneratorRuntime.wrap(function outgoingedges$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _iteratorNormalCompletion = true; + _didIteratorError = false; + _iteratorError = undefined; + _context.prev = 3; + _iterator = U[Symbol.iterator](); + + case 5: + if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { + _context.next = 37; + break; + } + + u = _step.value; + _iteratorNormalCompletion2 = true; + _didIteratorError2 = false; + _iteratorError2 = undefined; + _context.prev = 10; + _iterator2 = G.get(u)[Symbol.iterator](); + + case 12: + if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { + _context.next = 20; + break; + } + + v = _step2.value; + + if (U.has(v)) { + _context.next = 17; + break; + } + + _context.next = 17; + return [u, v]; + + case 17: + _iteratorNormalCompletion2 = true; + _context.next = 12; + break; + + case 20: + _context.next = 26; + break; + + case 22: + _context.prev = 22; + _context.t0 = _context["catch"](10); + _didIteratorError2 = true; + _iteratorError2 = _context.t0; + + case 26: + _context.prev = 26; + _context.prev = 27; + + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + + case 29: + _context.prev = 29; + + if (!_didIteratorError2) { + _context.next = 32; + break; + } + + throw _iteratorError2; + + case 32: + return _context.finish(29); + + case 33: + return _context.finish(26); + + case 34: + _iteratorNormalCompletion = true; + _context.next = 5; + break; + + case 37: + _context.next = 43; + break; + + case 39: + _context.prev = 39; + _context.t1 = _context["catch"](3); + _didIteratorError = true; + _iteratorError = _context.t1; + + case 43: + _context.prev = 43; + _context.prev = 44; + + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + + case 46: + _context.prev = 46; + + if (!_didIteratorError) { + _context.next = 49; + break; + } + + throw _iteratorError; + + case 49: + return _context.finish(46); + + case 50: + return _context.finish(43); + + case 51: + case "end": + return _context.stop(); + } + } + }, _marked, this, [[3, 39, 43, 51], [10, 22, 26, 34], [27,, 29, 33], [44,, 46, 50]]); +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9vdXRnb2luZ2VkZ2VzLmpzIl0sIm5hbWVzIjpbIm91dGdvaW5nZWRnZXMiLCJHIiwiVSIsInUiLCJnZXQiLCJ2IiwiaGFzIl0sIm1hcHBpbmdzIjoiOzs7OztrQkFBeUJBLGE7O21EQUFBQSxhOztBQUFWLFNBQVVBLGFBQVYsQ0FBMEJDLENBQTFCLEVBQThCQyxDQUE5QjtBQUFBOztBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQSxpQkFDR0EsQ0FESDs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUNGQyxNQURFO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQSxrQkFDd0JGLEVBQUVHLEdBQUYsQ0FBTUQsQ0FBTixDQUR4Qjs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUNtQkUsTUFEbkI7O0FBQUEsU0FDeUNILEVBQUVJLEdBQUYsQ0FBTUQsQ0FBTixDQUR6QztBQUFBO0FBQUE7QUFBQTs7QUFBQTtBQUFBLFlBQzBELENBQUVGLENBQUYsRUFBTUUsQ0FBTixDQUQxRDs7QUFBQTtBQUFBO0FBQUE7QUFBQTs7QUFBQTtBQUFBO0FBQUE7O0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTs7QUFBQTtBQUFBO0FBQUE7O0FBQUE7QUFBQTtBQUFBOztBQUFBO0FBQUE7O0FBQUE7QUFBQTtBQUFBO0FBQUE7O0FBQUE7O0FBQUE7QUFBQTs7QUFBQTtBQUFBOztBQUF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