2024-08-29 18:38:21 +08:00
|
|
|
import{G as k}from"./graph-B8WZCNOo.js";import{be as Pn,aO as Sn,bf as ln,aR as U,bg as On,aU as vn,aT as en,a_ as A,aV as pn,bh as Fn,bi as Vn,bj as An,aN as $,aM as Bn,bk as Gn,bl as Yn,bm as Dn,bn as T,aA as w,aB as jn,az as g,bo as P,bp as S,bq as qn,br as W}from"./index-CFgdrPfe.js";import{c as mn,a as s,h as m,f as M,v as y,r as O}from"./reduce-B3fBEdvQ.js";import{b as wn,a as $n,t as B,m as _,f as X,d as Wn}from"./min-DeP6jwJb.js";function zn(n,e){return n==null?n:Pn(n,mn(e),Sn)}function Un(n,e){return n&&ln(n,mn(e))}function Xn(n,e){return n>e}function F(n,e){var r={};return e=U(e),ln(n,function(i,t,a){On(r,t,e(i,t,a))}),r}function x(n){return n&&n.length?wn(n,vn,Xn):void 0}function H(n,e){return n&&n.length?wn(n,U(e),$n):void 0}function Hn(n,e){var r=n.length;for(n.sort(e);r--;)n[r]=n[r].value;return n}function Jn(n,e){if(n!==e){var r=n!==void 0,i=n===null,t=n===n,a=en(n),o=e!==void 0,u=e===null,d=e===e,f=en(e);if(!u&&!f&&!a&&n>e||a&&o&&d&&!u&&!f||i&&o&&d||!r&&d||!t)return 1;if(!i&&!a&&!f&&n<e||f&&r&&t&&!i&&!a||u&&r&&t||!o&&t||!d)return-1}return 0}function Zn(n,e,r){for(var i=-1,t=n.criteria,a=e.criteria,o=t.length,u=r.length;++i<o;){var d=Jn(t[i],a[i]);if(d){if(i>=u)return d;var f=r[i];return d*(f=="desc"?-1:1)}}return n.index-e.index}function Kn(n,e,r){e.length?e=A(e,function(a){return pn(a)?function(o){return Fn(o,a.length===1?a[0]:a)}:a}):e=[vn];var i=-1;e=A(e,Vn(U));var t=An(n,function(a,o,u){var d=A(e,function(f){return f(a)});return{criteria:d,index:++i,value:a}});return Hn(t,function(a,o){return Zn(a,o,r)})}var Qn=Math.ceil,ne=Math.max;function ee(n,e,r,i){for(var t=-1,a=ne(Qn((e-n)/(r||1)),0),o=Array(a);a--;)o[++t]=n,n+=r;return o}function re(n){return function(e,r,i){return i&&typeof i!="number"&&$(e,r,i)&&(r=i=void 0),e=B(e),r===void 0?(r=e,e=0):r=B(r),i=i===void 0?e<r?1:-1:B(i),ee(e,r,i)}}var N=re(),I=Bn(function(n,e){if(n==null)return[];var r=e.length;return r>1&&$(n,e[0],e[1])?e=[]:r>2&&$(e[0],e[1],e[2])&&(e=[e[0]]),Kn(n,Gn(e,1),[])}),ie=0;function J(n){var e=++ie;return Yn(n)+e}function te(n,e,r){for(var i=-1,t=n.length,a=e.length,o={};++i<t;){var u=i<a?e[i]:void 0;r(o,n[i],u)}return o}function ae(n,e){return te(n||[],e||[],Dn)}class oe{constructor(){var e={};e._next=e._prev=e,this._sentinel=e}dequeue(){var e=this._sentinel,r=e._prev;if(r!==e)return rn(r),r}enqueue(e){var r=this._sentinel;e._prev&&e._next&&rn(e),e._next=r._next,r._next._prev=e,r._next=e,e._prev=r}toString(){for(var e=[],r=this._sentinel,i=r._prev;i!==r;)e.push(JSON.stringify(i,ue)),i=i._prev;return"["+e.join(", ")+"]"}}function rn(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function ue(n,e){if(n!=="_next"&&n!=="_prev")return e}var de=jn(1);function fe(n,e){if(n.nodeCount()<=1)return[];var r=ce(n,e||de),i=se(r.graph,r.buckets,r.zeroIdx);return T(w(i,function(t){return n.outEdges(t.v,t.w)}))}function se(n,e,r){for(var i=[],t=e[e.length-1],a=e[0],o;n.nodeCount();){for(;o=a.dequeue();)G(n,e,r,o);for(;o=t.dequeue();)G(n,e,r,o);if(n.nodeCount()){for(var u=e.length-2;u>0;--u)if(o=e[u].dequeue(),o){i=i.concat(G(n,e,r,o,!0));break}}}return i}function G(n,e,r,i,t){var a=t?[]:void 0;return s(n.inEdges(i.v),function(o){var u=n.edge(o),d=n.node(o.v);t&&a.push({v:o.v,w:o.w}),d.out-=u,z(e,r,d)}),s(n.outEdges(i.v),function(o){var u=n.edge(o),d=o.w,f=n.node(d);f.in-=u,z(e,r,f)}),n.removeNode(i.v),a}function ce(n,e){var r=new k,i=0,t=0;s(n.nodes(),function(u){r.setNode(u,{v:u,in:0,out:0})}),s(n.edges(),function(u){var d=r.edge(u.v,u.w)||0,f=e(u),c=d+f;r.setEdge(u.v,u.w,c),t=Math.max(t,r.node(u.v).out+=f),i=Math.max(i,r.node(u.w).in+=f)});var a=N(t+i+3).map(function(){return new oe}),o=i+1;return s(r.nodes(),function(u){z(a,o,r.node(u))}),{graph:r,buckets:a,zeroIdx:o}}function z(n,e,r){r.out?r.in?n[r.out-r.in+e].enqueue(r):n[n.length-1].enqueue(r):n[0].enqueue(r)}function he(n){var e=n.graph().acyclicer==="greedy"?fe(n,r(n)):le(n);s(e,function(i){var t=n.edge(i);n.removeEdge(i),t.forwardName=i.name,t.reversed=!0,n.setEdge(i.w,i.v,t,J("rev"))});function r(i){return function(t){return i.edge(t).weight}}}function le(n)
|