h)},St=function(e,t,n,r,i,a,o,s){var u,l,c,d,h,f,p,v,g,y,m,b,x,w=[];l=9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,c=3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,d=1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,0===(u=1*n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s)&&(u=1e-5),v=-27*(d/=u)+(l/=u)*(9*(c/=u)-l*l*2),f=(p=(3*c-l*l)/9)*p*p+(v/=54)*v,(h=w)[1]=0,b=l/3,f>0?(y=(y=v+Math.sqrt(f))<0?-Math.pow(-y,1/3):Math.pow(y,1/3),m=(m=v-Math.sqrt(f))<0?-Math.pow(-m,1/3):Math.pow(m,1/3),h[0]=-b+y+m,b+=(y+m)/2,h[4]=h[2]=-b,b=Math.sqrt(3)*(-m+y)/2,h[3]=b,h[5]=-b):(h[5]=h[3]=0,0===f?(x=v<0?-Math.pow(-v,1/3):Math.pow(v,1/3),h[0]=2*x-b,h[4]=h[2]=-(x+b)):(g=(p=-p)*p*p,g=Math.acos(v/Math.sqrt(g)),x=2*Math.sqrt(p),h[0]=-b+x*Math.cos(g/3),h[2]=-b+x*Math.cos((g+2*Math.PI)/3),h[4]=-b+x*Math.cos((g+4*Math.PI)/3)));for(var _=[],E=0;E<6;E+=2)Math.abs(w[E+1])<1e-7&&w[E]>=0&&w[E]<=1&&_.push(w[E]);_.push(1),_.push(0);for(var k,C,S,P=-1,T=0;T<_.length;T++)k=Math.pow(1-_[T],2)*n+2*(1-_[T])*_[T]*i+_[T]*_[T]*o,C=Math.pow(1-_[T],2)*r+2*(1-_[T])*_[T]*a+_[T]*_[T]*s,S=Math.pow(k-e,2)+Math.pow(C-t,2),P>=0?Su?(e-i)*(e-i)+(t-a)*(t-a):l-d},Tt=function(e,t,n){for(var r,i,a,o,s=0,u=0;u=e&&e>=a||r<=e&&e<=a))continue;(e-r)/(a-r)*(o-i)+i>t&&s++}return s%2!=0},Dt=function(e,t,n,r,i,a,o,s,u){var l,c=new Array(n.length);null!=s[0]?(l=Math.atan(s[1]/s[0]),s[0]<0?l+=Math.PI/2:l=-l-Math.PI/2):l=s;for(var d,h=Math.cos(-l),f=Math.sin(-l),p=0;p0){var v=Bt(c,-u);d=Mt(v)}else d=c;return Tt(e,t,d)},Mt=function(e){for(var t,n,r,i,a,o,s,u,l=new Array(e.length/2),c=0;c=0&&p<=1&&g.push(p),v>=0&&v<=1&&g.push(v),0===g.length)return[];var y=g[0]*s[0]+e,m=g[0]*s[1]+t;return g.length>1?g[0]==g[1]?[y,m]:[y,m,g[1]*s[0]+e,g[1]*s[1]+t]:[y,m]},At=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},zt=function(e,t,n,r,i,a,o,s,u){var l=e-i,c=n-e,d=o-i,h=t-a,f=r-t,p=s-a,v=d*h-p*l,g=c*h-f*l,y=p*c-d*f;if(0!==y){var m=v/y,b=g/y,x=-.001;return x<=m&&m<=1.001&&x<=b&&b<=1.001||u?[e+m*c,t+m*f]:[]}return 0===v||0===g?At(e,n,o)===o?[o,s]:At(e,n,i)===i?[i,a]:At(i,o,n)===n?[n,r]:[]:[]},Nt=function(e,t,n,r,i,a,o,s){var u,l,c,d,h,f,p=[],v=new Array(n.length),g=!0;if(null==a&&(g=!1),g){for(var y=0;y0){var m=Bt(v,-s);l=Mt(m)}else l=v}else l=n;for(var b=0;bl&&(l=t)},h=function(e){return u[e]},f=0;f0?w.edgesTo(x)[0]:x.edgesTo(w)[0];var _=r(b);x=x.id(),f[x]>f[y]+_&&(f[x]=f[y]+_,p.nodes.indexOf(x)<0?p.push(x):p.updateItem(x),l[x]=0,u[x]=[]),f[x]==f[y]+_&&(l[x]=l[x]+l[y],u[x].push(y))}else for(var E=0;E0;){for(var P=n.pop(),T=0;T0&&o.push(n[s]);0!==o.length&&i.push(r.collection(o))}return i}(c,u,t,r);return b=function(e){for(var t=0;t5&&void 0!==arguments[5]?arguments[5]:ln,o=r,s=0;s=2?vn(e,t,n,0,hn,fn):vn(e,t,n,0,dn)},squaredEuclidean:function(e,t,n){return vn(e,t,n,0,hn)},manhattan:function(e,t,n){return vn(e,t,n,0,dn)},max:function(e,t,n){return vn(e,t,n,-1/0,pn)}};function yn(e,t,n,r,i,a){var o;return o=D(e)?e:gn[e]||gn.euclidean,0===t&&D(e)?o(i,a):o(t,n,r,i,a)}gn["squared-euclidean"]=gn.squaredEuclidean,gn.squaredeuclidean=gn.squaredEuclidean;var mn=Ie({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),bn=function(e){return mn(e)},xn=function(e,t,n,r,i){var a="kMedoids"!==i?function(e){return n[e]}:function(e){return r[e](n)},o=n,s=t;return yn(e,r.length,a,(function(e){return r[e](t)}),o,s)},wn=function(e,t,n){for(var r=n.length,i=new Array(r),a=new Array(r),o=new Array(t),s=null,u=0;un)return!1;return!0},Cn=function(e,t,n){for(var r=0;ri&&(i=t[u][l],a=l);o[a].push(e[u])}for(var c=0;c=i.threshold||"dendrogram"===i.mode&&1===e.length)return!1;var f,p=t[o],v=t[r[o]];f="dendrogram"===i.mode?{left:p,right:v,key:p.key}:{value:p.value.concat(v.value),key:p.key},e[p.index]=f,e.splice(v.index,1),t[p.key]=f;for(var g=0;gn[v.key][y.key]&&(a=n[v.key][y.key])):"max"===i.linkage?(a=n[p.key][y.key],n[p.key][y.key]o&&(a=u,o=t[i*e+u])}a>0&&r.push(a)}for(var l=0;l1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(n0&&e.splice(0,t)):e=e.slice(t,n);for(var a=0,o=e.length-1;o>=0;o--){var s=e[o];i?isFinite(s)||(e[o]=-1/0,a++):e.splice(o,1)}r&&e.sort((function(e,t){return e-t}));var u=e.length,l=Math.floor(u/2);return u%2!=0?e[l+1+a]:(e[l-1+a]+e[l+a])/2}(e):"mean"===t?function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,i=t;i=S?(P=S,S=D,T=M):D>P&&(P=D);for(var B=0;B0?1:0;E[_%l.minIterations*t+R]=j,L+=j}if(L>0&&(_>=l.minIterations-1||_==l.maxIterations-1)){for(var V=0,F=0;F0&&r.push(i);return r}(t,a,o),Y=function(e,t,n){for(var r=qn(e,t,n),i=0;iu&&(s=l,u=c)}n[i]=a[s]}return qn(e,t,n)}(t,r,W),X={},H=0;H1)}}));var u=Object.keys(t).filter((function(e){return t[e].cutVertex})).map((function(t){return e.getElementById(t)}));return{cut:e.spawn(u),components:i}},Un=function(){var e=this,t={},n=0,r=[],i=[],a=e.spawn(e),o=function o(s){if(i.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach((function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))})),t[s].index===t[s].low){for(var u=e.spawn();;){var l=i.pop();if(u.merge(e.getElementById(l)),t[l].low=t[s].index,t[l].explored=!0,l===s)break}var c=u.edgesWith(u),d=u.merge(c);r.push(d),a=a.difference(d)}};return e.forEach((function(e){if(e.isNode()){var n=e.id();n in t||o(n)}})),{cut:a,components:r}},Zn={};[qe,Ye,Xe,Ue,Ke,$e,tt,Xt,Ut,Kt,$t,un,Bn,jn,Yn,{hierholzer:function(e){if(!B(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n,r,i,a=Xn(e),o=a.root,s=a.directed,u=this,l=!1;o&&(i=T(o)?this.filter(o)[0].id():o[0].id());var c={},d={};s?u.forEach((function(e){var t=e.id();if(e.isNode()){var i=e.indegree(!0),a=e.outdegree(!0),o=i-a,s=a-i;1==o?n?l=!0:n=t:1==s?r?l=!0:r=t:(s>1||o>1)&&(l=!0),c[t]=[],e.outgoers().forEach((function(e){e.isEdge()&&c[t].push(e.id())}))}else d[t]=[void 0,e.target().id()]})):u.forEach((function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(n?r?l=!0:r=t:n=t),c[t]=[],e.connectedEdges().forEach((function(e){return c[t].push(e.id())}))):d[t]=[e.source().id(),e.target().id()]}));var h={found:!1,trail:void 0};if(l)return h;if(r&&n)if(s){if(i&&r!=i)return h;i=r}else{if(i&&r!=i&&n!=i)return h;i||(i=r)}else i||(i=u[0].id());var f=function(e){for(var t,n,r,i=e,a=[e];c[i].length;)t=c[i].shift(),n=d[t][0],i!=(r=d[t][1])?(c[r]=c[r].filter((function(e){return e!=t})),i=r):s||i==n||(c[n]=c[n].filter((function(e){return e!=t})),i=n),a.unshift(t),a.unshift(i);return a},p=[],v=[];for(v=f(i);1!=v.length;)0==c[v[0]].length?(p.unshift(u.getElementById(v.shift())),p.unshift(u.getElementById(v.shift()))):v=f(v.shift()).concat(v);for(var g in p.unshift(u.getElementById(v.shift())),c)if(c[g].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},{hopcroftTarjanBiconnected:Hn,htbc:Hn,htb:Hn,hopcroftTarjanBiconnectedComponents:Hn},{tarjanStronglyConnected:Un,tsc:Un,tscc:Un,tarjanStronglyConnectedComponents:Un}].forEach((function(e){Q(Zn,e)}));var Kn=function e(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))};Kn.prototype={fulfill:function(e){return Gn(this,1,"fulfillValue",e)},reject:function(e){return Gn(this,2,"rejectReason",e)},then:function(e,t){var n=this,r=new Kn;return n.onFulfilled.push(Jn(e,r,"fulfill")),n.onRejected.push(Jn(t,r,"reject")),$n(n),r.proxy}};var Gn=function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,$n(e)),e},$n=function(e){1===e.state?Qn(e,"onFulfilled",e.fulfillValue):2===e.state&&Qn(e,"onRejected",e.rejectReason)},Qn=function(e,t,n){if(0!==e[t].length){var r=e[t];e[t]=[];var i=function(){for(var e=0;e0:void 0}},clearQueue:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n0&&this.spawn(r).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){M(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,i=[],a=0,o=n.length;a