grapholscape
Version:
ontology visualization
25 lines (24 loc) • 1.02 MB
JavaScript
/**
* MIT License
*
* Copyright (c) 2018-2024 OBDA Systems
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var Grapholscape=function(e){"use strict";function t(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,i,o=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=c(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}"function"==typeof SuppressedError&&SuppressedError;var h="undefined"==typeof window?null:window,p=h?h.navigator:null;h&&h.document;var g=r(""),f=r({}),m=r((function(){})),v="undefined"==typeof HTMLElement?"undefined":r(HTMLElement),y=function(e){return e&&e.instanceString&&E(e.instanceString)?e.instanceString():null},b=function(e){return null!=e&&r(e)==g},E=function(e){return null!=e&&r(e)===m},w=function(e){return!S(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},x=function(e){return null!=e&&r(e)===f&&!w(e)&&e.constructor===Object},_=function(e){return null!=e&&r(e)===r(1)&&!isNaN(e)},T=function(e){return"undefined"===v?void 0:null!=e&&e instanceof HTMLElement},S=function(e){return C(e)||N(e)},C=function(e){return"collection"===y(e)&&e._private.single},N=function(e){return"collection"===y(e)&&!e._private.single},I=function(e){return"core"===y(e)},O=function(e){return"stylesheet"===y(e)},P=function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},A=function(e){return function(e){return null!=e&&r(e)===f}(e)&&E(e.then)},k=function(e,t){t||(t=function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join("$")});var n=function n(){var r,i=arguments,o=t.apply(this,i),a=n.cache;return(r=a[o])||(r=a[o]=e.apply(this,i)),r};return n.cache={},n},R=k((function(e){return e.replace(/([A-Z])/g,(function(e){return"-"+e.toLowerCase()}))})),L=k((function(e){return e.replace(/(-\w)/g,(function(e){return e[1].toUpperCase()}))})),D=k((function(e,t){return e+t[0].toUpperCase()+t.substring(1)}),(function(e,t){return e+"$"+t})),M=function(e){return P(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},$="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",B="rgb[a]?\\(("+$+"[%]?)\\s*,\\s*("+$+"[%]?)\\s*,\\s*("+$+"[%]?)(?:\\s*,\\s*("+$+"))?\\)",z="rgb[a]?\\((?:"+$+"[%]?)\\s*,\\s*(?:"+$+"[%]?)\\s*,\\s*(?:"+$+"[%]?)(?:\\s*,\\s*(?:"+$+"))?\\)",V="hsl[a]?\\(("+$+")\\s*,\\s*("+$+"[%])\\s*,\\s*("+$+"[%])(?:\\s*,\\s*("+$+"))?\\)",F="hsl[a]?\\((?:"+$+")\\s*,\\s*(?:"+$+"[%])\\s*,\\s*(?:"+$+"[%])(?:\\s*,\\s*(?:"+$+"))?\\)",q=function(e,t){return e<t?-1:e>t?1:0},j=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(null!=r)for(var i=Object.keys(r),o=0;o<i.length;o++){var a=i[o];e[a]=r[a]}}return e},H=function(e){return(w(e)?e:null)||function(e){return G[e.toLowerCase()]}(e)||function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,n,r,i=16;return 4===e.length?(t=parseInt(e[1]+e[1],i),n=parseInt(e[2]+e[2],i),r=parseInt(e[3]+e[3],i)):(t=parseInt(e[1]+e[2],i),n=parseInt(e[3]+e[4],i),r=parseInt(e[5]+e[6],i)),[t,n,r]}}(e)||function(e){var t,n=new RegExp("^"+B+"$").exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var o=n[i];if("%"===o[o.length-1]&&(r[i]=!0),o=parseFloat(o),r[i]&&(o=o/100*255),o<0||o>255)return;t.push(Math.floor(o))}var a=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(a&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t}(e)||function(e){var t,n,r,i,o,a,s,l;function c(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var u=new RegExp("^"+V+"$").exec(e);if(u){if((n=parseInt(u[1]))<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,(r=parseFloat(u[2]))<0||r>100)return;if(r/=100,(i=parseFloat(u[3]))<0||i>100)return;if(i/=100,void 0!==(o=u[4])&&((o=parseFloat(o))<0||o>1))return;if(0===r)a=s=l=Math.round(255*i);else{var d=i<.5?i*(1+r):i+r-i*r,h=2*i-d;a=Math.round(255*c(h,d,n+1/3)),s=Math.round(255*c(h,d,n)),l=Math.round(255*c(h,d,n-1/3))}t=[a,s,l,o]}return t}(e)},G={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},U=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var o=n[i];if(x(o))throw Error("Tried to set map with object key");i<n.length-1?(null==t[o]&&(t[o]={}),t=t[o]):t[o]=e.value}},Y=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var o=n[i];if(x(o))throw Error("Tried to get map with object key");if(null==(t=t[o]))return t}return t};var Q=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var W="object"==typeof Z&&Z&&Z.Object===Object&&Z,X="object"==typeof self&&self&&self.Object===Object&&self,J=W||X||Function("return this")(),K=function(){return J.Date.now()},ee=/\s/;var te=function(e){for(var t=e.length;t--&&ee.test(e.charAt(t)););return t},ne=/^\s+/;var re=function(e){return e?e.slice(0,te(e)+1).replace(ne,""):e},ie=J.Symbol,oe=Object.prototype,ae=oe.hasOwnProperty,se=oe.toString,le=ie?ie.toStringTag:void 0;var ce=function(e){var t=ae.call(e,le),n=e[le];try{e[le]=void 0;var r=!0}catch(e){}var i=se.call(e);return r&&(t?e[le]=n:delete e[le]),i},ue=Object.prototype.toString;var de=function(e){return ue.call(e)},he=ie?ie.toStringTag:void 0;var pe=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":he&&he in Object(e)?ce(e):de(e)};var ge=function(e){return null!=e&&"object"==typeof e};var fe=function(e){return"symbol"==typeof e||ge(e)&&"[object Symbol]"==pe(e)},me=/^[-+]0x[0-9a-f]+$/i,ve=/^0b[01]+$/i,ye=/^0o[0-7]+$/i,be=parseInt;var Ee=function(e){if("number"==typeof e)return e;if(fe(e))return NaN;if(Q(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Q(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=re(e);var n=ve.test(e);return n||ye.test(e)?be(e.slice(2),n?2:8):me.test(e)?NaN:+e},we=Math.max,xe=Math.min;var _e=function(e,t,n){var r,i,o,a,s,l,c=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var n=r,o=i;return r=i=void 0,c=t,a=e.apply(o,n)}function g(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=o}function f(){var e=K();if(g(e))return m(e);s=setTimeout(f,function(e){var n=t-(e-l);return d?xe(n,o-(e-c)):n}(e))}function m(e){return s=void 0,h&&r?p(e):(r=i=void 0,a)}function v(){var e=K(),n=g(e);if(r=arguments,i=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(f,t),u?p(e):a}(l);if(d)return clearTimeout(s),s=setTimeout(f,t),p(l)}return void 0===s&&(s=setTimeout(f,t)),a}return t=Ee(t)||0,Q(n)&&(u=!!n.leading,o=(d="maxWait"in n)?we(Ee(n.maxWait)||0,t):o,h="trailing"in n?!!n.trailing:h),v.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=i=s=void 0},v.flush=function(){return void 0===s?a:m(K())},v},Te=h?h.performance:null,Se=Te&&Te.now?function(){return Te.now()}:function(){return Date.now()},Ce=function(){if(h){if(h.requestAnimationFrame)return function(e){h.requestAnimationFrame(e)};if(h.mozRequestAnimationFrame)return function(e){h.mozRequestAnimationFrame(e)};if(h.webkitRequestAnimationFrame)return function(e){h.webkitRequestAnimationFrame(e)};if(h.msRequestAnimationFrame)return function(e){h.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout((function(){e(Se())}),1e3/60)}}(),Ne=function(e){return Ce(e)},Ie=Se,Oe=9261,Pe=5381,Ae=function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe;!(t=e.next()).done;)n=65599*n+t.value|0;return n},ke=function(e){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oe)+e|0},Re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pe;return(t<<5)+t+e|0},Le=function(e){return 2097152*e[0]+e[1]},De=function(e,t){return[ke(e[0],t[0]),Re(e[1],t[1])]},Me=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return Ae({next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},$e=function(){return Be(arguments)},Be=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=0===n?Me(r):Me(r,t)}return t},ze=!0,Ve=null!=console.warn,Fe=null!=console.trace,qe=Number.MAX_SAFE_INTEGER||9007199254740991,je=function(){return!0},He=function(){return!1},Ge=function(){return 0},Ue=function(){},Ye=function(e){throw new Error(e)},Qe=function(e){if(void 0===e)return ze;ze=!!e},Ze=function(e){Qe()&&(Ve?console.warn(e):(console.log(e),Fe&&console.trace()))},We=function(e){return null==e?e:w(e)?e.slice():x(e)?function(e){return j({},e)}(e):e},Xe=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"-");return t},Je={},Ke=function(){return Je},et=function(e){var t=Object.keys(e);return function(n){for(var r={},i=0;i<t.length;i++){var o=t[i],a=null==n?void 0:n[o];r[o]=void 0===a?e[o]:a}return r}},tt=function(e,t,n){for(var r=e.length-1;r>=0&&(e[r]!==t||(e.splice(r,1),!n));r--);},nt=function(e){e.splice(0,e.length)},rt=function(e,t,n){return n&&(t=D(n,t)),e[t]},it=function(e,t,n,r){n&&(t=D(n,t)),e[t]=r},ot="undefined"!=typeof Map?Map:function(){function e(){i(this,e),this._obj={}}return a(e,[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}]),e}(),at=function(){function e(t){if(i(this,e),this._obj=Object.create(null),this.size=0,null!=t){var n;n=null!=t.instanceString&&t.instanceString()===this.instanceString()?t.toArray():t;for(var r=0;r<n.length;r++)this.add(n[r])}}return a(e,[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(e){var t=this._obj;1!==t[e]&&(t[e]=1,this.size++)}},{key:"delete",value:function(e){var t=this._obj;1===t[e]&&(t[e]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(e){return 1===this._obj[e]}},{key:"toArray",value:function(){var e=this;return Object.keys(this._obj).filter((function(t){return e.has(t)}))}},{key:"forEach",value:function(e,t){return this.toArray().forEach(e,t)}}]),e}(),st="undefined"!==("undefined"==typeof Set?"undefined":r(Set))?Set:at,lt=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&I(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,active:!1,classes:new st,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==i.position.x&&(i.position.x=0),null==i.position.y&&(i.position.y=0),t.renderedPosition){var o=t.renderedPosition,a=e.pan(),s=e.zoom();i.position={x:(o.x-a.x)/s,y:(o.y-a.y)/s}}var l=[];w(t.classes)?l=t.classes:b(t.classes)&&(l=t.classes.split(/\s+/));for(var c=0,u=l.length;c<u;c++){var d=l[c];d&&""!==d&&i.classes.add(d)}this.createEmitter();var h=t.style||t.css;h&&(Ze("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(h)),(void 0===n||n)&&this.restore()}else Ye("An element must be of type `nodes` or `edges`; you specified `"+r+"`")}else Ye("An element must have a core reference and parameters set")},ct=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){var i;x(t)&&!S(t)&&(t=(i=t).roots||i.root,n=i.visit,r=i.directed),r=2!==arguments.length||E(n)?r:n,n=E(n)?n:function(){};for(var o,a=this._private.cy,s=t=b(t)?this.filter(t):t,l=[],c=[],u={},d={},h={},p=0,g=this.byGroup(),f=g.nodes,m=g.edges,v=0;v<s.length;v++){var y=s[v],w=y.id();y.isNode()&&(l.unshift(y),e.bfs&&(h[w]=!0,c.push(y)),d[w]=0)}for(var _=function(){var t=e.bfs?l.shift():l.pop(),i=t.id();if(e.dfs){if(h[i])return"continue";h[i]=!0,c.push(t)}var a,s=d[i],g=u[i],v=null!=g?g.source():null,y=null!=g?g.target():null,b=null==g?void 0:t.same(v)?y[0]:v[0];if(!0===(a=n(t,g,b,p++,s)))return o=t,"break";if(!1===a)return"break";for(var E=t.connectedEdges().filter((function(e){return(!r||e.source().same(t))&&m.has(e)})),w=0;w<E.length;w++){var x=E[w],_=x.connectedNodes().filter((function(e){return!e.same(t)&&f.has(e)})),T=_.id();0===_.length||h[T]||(_=_[0],l.push(_),e.bfs&&(h[T]=!0,c.push(_)),u[T]=x,d[T]=d[i]+1)}};0!==l.length;){var T=_();if("continue"!==T&&"break"===T)break}for(var C=a.collection(),N=0;N<c.length;N++){var I=c[N],O=u[I.id()];null!=O&&C.push(O),C.push(I)}return{path:a.collection(C),found:a.collection(o)}}},ut={breadthFirstSearch:ct({bfs:!0}),depthFirstSearch:ct({dfs:!0})};ut.bfs=ut.breadthFirstSearch,ut.dfs=ut.depthFirstSearch;var dt=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){(function(){var t,n,r,i,o,a,s,l,c,u,d,h,p,g,f;r=Math.floor,u=Math.min,n=function(e,t){return e<t?-1:e>t?1:0},c=function(e,t,i,o,a){var s;if(null==i&&(i=0),null==a&&(a=n),i<0)throw new Error("lo must be non-negative");for(null==o&&(o=e.length);i<o;)a(t,e[s=r((i+o)/2)])<0?o=s:i=s+1;return[].splice.apply(e,[i,i-i].concat(t)),t},a=function(e,t,r){return null==r&&(r=n),e.push(t),g(e,0,e.length-1,r)},o=function(e,t){var r,i;return null==t&&(t=n),r=e.pop(),e.length?(i=e[0],e[0]=r,f(e,0,t)):i=r,i},l=function(e,t,r){var i;return null==r&&(r=n),i=e[0],e[0]=t,f(e,0,r),i},s=function(e,t,r){var i;return null==r&&(r=n),e.length&&r(e[0],t)<0&&(t=(i=[e[0],t])[0],e[0]=i[1],f(e,0,r)),t},i=function(e,t){var i,o,a,s,l,c;for(null==t&&(t=n),l=[],o=0,a=(s=function(){c=[];for(var t=0,n=r(e.length/2);0<=n?t<n:t>n;0<=n?t++:t--)c.push(t);return c}.apply(this).reverse()).length;o<a;o++)i=s[o],l.push(f(e,i,t));return l},p=function(e,t,r){var i;if(null==r&&(r=n),-1!==(i=e.indexOf(t)))return g(e,0,i,r),f(e,i,r)},d=function(e,t,r){var o,a,l,c,u;if(null==r&&(r=n),!(a=e.slice(0,t)).length)return a;for(i(a,r),l=0,c=(u=e.slice(t)).length;l<c;l++)o=u[l],s(a,o,r);return a.sort(r).reverse()},h=function(e,t,r){var a,s,l,d,h,p,g,f,m;if(null==r&&(r=n),10*t<=e.length){if(!(l=e.slice(0,t).sort(r)).length)return l;for(s=l[l.length-1],d=0,p=(g=e.slice(t)).length;d<p;d++)r(a=g[d],s)<0&&(c(l,a,0,null,r),l.pop(),s=l[l.length-1]);return l}for(i(e,r),m=[],h=0,f=u(t,e.length);0<=f?h<f:h>f;0<=f?++h:--h)m.push(o(e,r));return m},g=function(e,t,r,i){var o,a,s;for(null==i&&(i=n),o=e[r];r>t&&i(o,a=e[s=r-1>>1])<0;)e[r]=a,r=s;return e[r]=o},f=function(e,t,r){var i,o,a,s,l;for(null==r&&(r=n),o=e.length,l=t,a=e[t],i=2*t+1;i<o;)(s=i+1)<o&&!(r(e[i],e[s])<0)&&(i=s),e[t]=e[i],i=2*(t=i)+1;return e[t]=a,g(e,l,t,r)},t=function(){function e(e){this.cmp=null!=e?e:n,this.nodes=[]}return e.push=a,e.pop=o,e.replace=l,e.pushpop=s,e.heapify=i,e.updateItem=p,e.nlargest=d,e.nsmallest=h,e.prototype.push=function(e){return a(this.nodes,e,this.cmp)},e.prototype.pop=function(){return o(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return-1!==this.nodes.indexOf(e)},e.prototype.replace=function(e){return l(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return s(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return i(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return p(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return 0===this.nodes.length},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t;return(t=new e).nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e}(),e.exports=t}).call(Z)})),ht=dt,pt=et({root:null,weight:function(e){return 1},directed:!1}),gt={dijkstra:function(e){if(!x(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=pt(e),r=n.root,i=n.weight,o=n.directed,a=this,s=i,l=b(r)?this.filter(r)[0]:r[0],c={},u={},d={},h=this.byGroup(),p=h.nodes,g=h.edges;g.unmergeBy((function(e){return e.isLoop()}));for(var f=function(e){return c[e.id()]},m=function(e,t){c[e.id()]=t,v.updateItem(e)},v=new ht((function(e,t){return f(e)-f(t)})),y=0;y<p.length;y++){var E=p[y];c[E.id()]=E.same(l)?0:1/0,v.push(E)}for(var w=function(e,t){for(var n,r=(o?e.edgesTo(t):e.edgesWith(t)).intersect(g),i=1/0,a=0;a<r.length;a++){var l=r[a],c=s(l);(c<i||!n)&&(i=c,n=l)}return{edge:n,dist:i}};v.size()>0;){var _=v.pop(),T=f(_),S=_.id();if(d[S]=T,T!==1/0)for(var C=_.neighborhood().intersect(p),N=0;N<C.length;N++){var I=C[N],O=I.id(),P=w(_,I),A=T+P.dist;A<f(I)&&(m(I,A),u[O]={node:_,edge:P.edge})}}return{distanceTo:function(e){var t=b(e)?p.filter(e)[0]:e[0];return d[t.id()]},pathTo:function(e){var t=b(e)?p.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(t.length>0)for(n.unshift(t);u[i];){var o=u[i];n.unshift(o.edge),n.unshift(o.node),i=(r=o.node).id()}return a.spawn(n)}}}},ft={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,o=new Array(i),a=n,s=function(e){for(var t=0;t<o.length;t++){if(o[t].has(e))return t}},l=0;l<i;l++)o[l]=this.spawn(n[l]);for(var c=r.sort((function(t,n){return e(t)-e(n)})),u=0;u<c.length;u++){var d=c[u],h=d.source()[0],p=d.target()[0],g=s(h),f=s(p),m=o[g],v=o[f];g!==f&&(a.merge(d),m.merge(v),o.splice(f,1))}return a}},mt=et({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),vt={aStar:function(e){var t=this.cy(),n=mt(e),r=n.root,i=n.goal,o=n.heuristic,a=n.directed,s=n.weight;r=t.collection(r)[0],i=t.collection(i)[0];var l,c,u=r.id(),d=i.id(),h={},p={},g={},f=new ht((function(e,t){return p[e.id()]-p[t.id()]})),m=new st,v={},y={},b=function(e,t){f.push(e),m.add(t)};b(r,u),h[u]=0,p[u]=o(r);for(var E,w=0;f.size()>0;){if(l=f.pop(),c=l.id(),m.delete(c),w++,c===d){for(var x=[],_=i,T=d,S=y[T];x.unshift(_),null!=S&&x.unshift(S),null!=(_=v[T]);)S=y[T=_.id()];return{found:!0,distance:h[c],path:this.spawn(x),steps:w}}g[c]=!0;for(var C=l._private.edges,N=0;N<C.length;N++){var I=C[N];if(this.hasElementWithId(I.id())&&(!a||I.data("source")===c)){var O=I.source(),P=I.target(),A=O.id()!==c?O:P,k=A.id();if(this.hasElementWithId(k)&&!g[k]){var R=h[c]+s(I);E=k,m.has(E)?R<h[k]&&(h[k]=R,p[k]=R+o(A),v[k]=l,y[k]=I):(h[k]=R,p[k]=R+o(A),b(A,k),v[k]=l,y[k]=I)}}}}return{found:!1,distance:void 0,path:void 0,steps:w}}},yt=et({weight:function(e){return 1},directed:!1}),bt={floydWarshall:function(e){for(var t=this.cy(),n=yt(e),r=n.weight,i=n.directed,o=r,a=this.byGroup(),s=a.nodes,l=a.edges,c=s.length,u=c*c,d=function(e){return s.indexOf(e)},h=function(e){return s[e]},p=new Array(u),g=0;g<u;g++){var f=g%c,m=(g-f)/c;p[g]=m===f?0:1/0}for(var v=new Array(u),y=new Array(u),E=0;E<l.length;E++){var w=l[E],x=w.source()[0],_=w.target()[0];if(x!==_){var T=d(x),S=d(_),C=T*c+S,N=o(w);if(p[C]>N&&(p[C]=N,v[C]=S,y[C]=w),!i){var I=S*c+T;!i&&p[I]>N&&(p[I]=N,v[I]=T,y[I]=w)}}}for(var O=0;O<c;O++)for(var P=0;P<c;P++)for(var A=P*c+O,k=0;k<c;k++){var R=P*c+k,L=O*c+k;p[A]+p[L]<p[R]&&(p[R]=p[A]+p[L],v[R]=v[A])}var D=function(e){return d(function(e){return(b(e)?t.filter(e):e)[0]}(e))},M={distance:function(e,t){var n=D(e),r=D(t);return p[n*c+r]},path:function(e,n){var r=D(e),i=D(n),o=h(r);if(r===i)return o.collection();if(null==v[r*c+i])return t.collection();var a,s=t.collection(),l=r;for(s.merge(o);r!==i;)l=r,r=v[r*c+i],a=y[l*c+r],s.merge(a),s.merge(h(r));return s}};return M}},Et=et({weight:function(e){return 1},directed:!1,root:null}),wt={bellmanFord:function(e){var t=this,n=Et(e),r=n.weight,i=n.directed,o=n.root,a=r,s=this,l=this.cy(),c=this.byGroup(),u=c.edges,d=c.nodes,h=d.length,p=new ot,g=!1,f=[];o=l.collection(o)[0],u.unmergeBy((function(e){return e.isLoop()}));for(var m=u.length,v=function(e){var t=p.get(e.id());return t||(t={},p.set(e.id(),t)),t},y=function(e){return(b(e)?l.$(e):e)[0]},E=0;E<h;E++){var w=d[E],x=v(w);w.same(o)?x.dist=0:x.dist=1/0,x.pred=null,x.edge=null}for(var _=!1,T=function(e,t,n,r,i,o){var a=r.dist+o;a<i.dist&&!n.same(r.edge)&&(i.dist=a,i.pred=e,i.edge=n,_=!0)},S=1;S<h;S++){_=!1;for(var C=0;C<m;C++){var N=u[C],I=N.source(),O=N.target(),P=a(N),A=v(I),k=v(O);T(I,0,N,A,k,P),i||T(O,0,N,k,A,P)}if(!_)break}if(_)for(var R=[],L=0;L<m;L++){var D=u[L],M=D.source(),$=D.target(),B=a(D),z=v(M).dist,V=v($).dist;if(z+B<V||!i&&V+B<z){if(g||(Ze("Graph contains a negative weight cycle for Bellman-Ford"),g=!0),!1===e.findNegativeWeightCycles)break;var F=[];z+B<V&&F.push(M),!i&&V+B<z&&F.push($);for(var q=F.length,j=0;j<q;j++){var H=F[j],G=[H];G.push(v(H).edge);for(var U=v(H).pred;-1===G.indexOf(U);)G.push(U),G.push(v(U).edge),U=v(U).pred;for(var Y=(G=G.slice(G.indexOf(U)))[0].id(),Q=0,Z=2;Z<G.length;Z+=2)G[Z].id()<Y&&(Y=G[Z].id(),Q=Z);(G=G.slice(Q).concat(G.slice(0,Q))).push(G[0]);var W=G.map((function(e){return e.id()})).join(",");-1===R.indexOf(W)&&(f.push(s.spawn(G)),R.push(W))}}}return{distanceTo:function(e){return v(y(e)).dist},pathTo:function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,r=[],i=y(e);;){if(null==i)return t.spawn();var a=v(i),l=a.edge,c=a.pred;if(r.unshift(i[0]),i.same(n)&&r.length>0)break;null!=l&&r.unshift(l),i=c}return s.spawn(r)},hasNegativeWeightCycle:g,negativeWeightCycles:f}}},xt=Math.sqrt(2),_t=function(e,t,n){0===n.length&&Ye("Karger-Stein must be run on a connected (sub)graph");for(var r=n[e],i=r[1],o=r[2],a=t[i],s=t[o],l=n,c=l.length-1;c>=0;c--){var u=l[c],d=u[1],h=u[2];(t[d]===a&&t[h]===s||t[d]===s&&t[h]===a)&&l.splice(c,1)}for(var p=0;p<l.length;p++){var g=l[p];g[1]===s?(l[p]=g.slice(),l[p][1]=a):g[2]===s&&(l[p]=g.slice(),l[p][2]=a)}for(var f=0;f<t.length;f++)t[f]===s&&(t[f]=a);return l},Tt=function(e,t,n,r){for(;n>r;){var i=Math.floor(Math.random()*t.length);t=_t(i,e,t),n--}return t},St={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy((function(e){return e.isLoop()}));var i=n.length,o=r.length,a=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),s=Math.floor(i/xt);if(!(i<2)){for(var l=[],c=0;c<o;c++){var u=r[c];l.push([c,n.indexOf(u.source()),n.indexOf(u.target())])}for(var d=1/0,h=[],p=new Array(i),g=new Array(i),f=new Array(i),m=function(e,t){for(var n=0;n<i;n++)t[n]=e[n]},v=0;v<=a;v++){for(var y=0;y<i;y++)g[y]=y;var b=Tt(g,l.slice(),i,s),E=b.slice();m(g,f);var w=Tt(g,b,s,2),x=Tt(f,E,s,2);w.length<=x.length&&w.length<d?(d=w.length,h=w,m(g,p)):x.length<=w.length&&x.length<d&&(d=x.length,h=x,m(f,p))}for(var _=this.spawn(h.map((function(e){return r[e[0]]}))),T=this.spawn(),S=this.spawn(),C=p[0],N=0;N<p.length;N++){var I=p[N],O=n[N];I===C?T.merge(O):S.merge(O)}var P=function(t){var n=e.spawn();return t.forEach((function(t){n.merge(t),t.connectedEdges().forEach((function(t){e.contains(t)&&!_.contains(t)&&n.merge(t)}))})),n},A=[P(T),P(S)];return{cut:_,components:A,partition1:T,partition2:S}}Ye("At least 2 nodes are required for Karger-Stein algorithm")}},Ct=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},Nt=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},It=function(e){return{x:e[0],y:e[1]}},Ot=function(e,t){return Math.atan2(t,e)-Math.PI/2},Pt=Math.log2||function(e){return Math.log(e)/Math.log(2)},At=function(e){return e>0?1:e<0?-1:0},kt=function(e,t){return Math.sqrt(Rt(e,t))},Rt=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},Lt=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},Dt=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},Mt=function(e,t,n,r){return{x:Dt(e.x,t.x,n.x,r),y:Dt(e.y,t.y,n.y,r)}},$t=function(e,t,n){return Math.max(e,Math.min(n,t))},Bt=function(e){if(null==e)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},zt=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},Vt=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},Ft=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},qt=function(e){var t,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===o.length)t=n=r=i=o[0];else if(2===o.length)t=r=o[0],i=n=o[1];else if(4===o.length){var a=l(o,4);t=a[0],n=a[1],r=a[2],i=a[3]}return e.x1-=i,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},jt=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},Ht=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2<t.x1)&&(!(t.x2<e.x1)&&(!(e.y2<t.y1)&&(!(t.y2<e.y1)&&(!(e.y1>t.y2)&&!(t.y1>e.y2)))))))},Gt=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},Ut=function(e,t){return Gt(e,t.x1,t.y1)&&Gt(e,t.x2,t.y2)},Yt=function(e,t,n,r,i,o,a){var s,l,c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"auto",u="auto"===c?hn(i,o):c,d=i/2,h=o/2,p=(u=Math.min(u,d,h))!==d,g=u!==h;if(p){var f=r-h-a;if((s=an(e,t,n,r,n-d+u-a,f,n+d-u+a,f,!1)).length>0)return s}if(g){var m=n+d+a;if((s=an(e,t,n,r,m,r-h+u-a,m,r+h-u+a,!1)).length>0)return s}if(p){var v=r+h+a;if((s=an(e,t,n,r,n-d+u-a,v,n+d-u+a,v,!1)).length>0)return s}if(g){var y=n-d-a;if((s=an(e,t,n,r,y,r-h+u-a,y,r+h-u+a,!1)).length>0)return s}var b=n-d+u,E=r-h+u;if((l=rn(e,t,n,r,b,E,u+a)).length>0&&l[0]<=b&&l[1]<=E)return[l[0],l[1]];var w=n+d-u,x=r-h+u;if((l=rn(e,t,n,r,w,x,u+a)).length>0&&l[0]>=w&&l[1]<=x)return[l[0],l[1]];var _=n+d-u,T=r+h-u;if((l=rn(e,t,n,r,_,T,u+a)).length>0&&l[0]>=_&&l[1]>=T)return[l[0],l[1]];var S=n-d+u,C=r+h-u;return(l=rn(e,t,n,r,S,C,u+a)).length>0&&l[0]<=S&&l[1]>=C?[l[0],l[1]]:[]},Qt=function(e,t,n,r,i,o,a){var s=a,l=Math.min(n,i),c=Math.max(n,i),u=Math.min(r,o),d=Math.max(r,o);return l-s<=e&&e<=c+s&&u-s<=t&&t<=d+s},Zt=function(e,t,n,r,i,o,a,s,l){var c=Math.min(n,a,i)-l,u=Math.max(n,a,i)+l,d=Math.min(r,s,o)-l,h=Math.max(r,s,o)+l;return!(e<c||e>u||t<d||t>h)},Wt=function(e,t,n,r,i,o,a,s){var l=[];!function(e,t,n,r,i){var o,a,s,l,c,u,d,h;0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),o=(a=(3*n-t*t)/9)*a*a+(s/=54)*s,i[1]=0,d=t/3,o>0?(c=(c=s+Math.sqrt(o))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),u=(u=s-Math.sqrt(o))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),i[0]=-d+c+u,d+=(c+u)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-u+c)/2,i[3]=d,i[5]=-d):(i[5]=i[3]=0,0===o?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),i[0]=2*h-d,i[4]=i[2]=-(h+d)):(l=(a=-a)*a*a,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(a),i[0]=-d+h*Math.cos(l/3),i[2]=-d+h*Math.cos((l+2*Math.PI)/3),i[4]=-d+h*Math.cos((l+4*Math.PI)/3)))}(1*n*n-4*n*i+2*n*a+4*i*i-4*i*a+a*a+r*r-4*r*o+2*r*s+4*o*o-4*o*s+s*s,9*n*i-3*n*n-3*n*a-6*i*i+3*i*a+9*r*o-3*r*r-3*r*s-6*o*o+3*o*s,3*n*n-6*n*i+n*a-n*e+2*i*i+2*i*e-a*e+3*r*r-6*r*o+r*s-r*t+2*o*o+2*o*t-s*t,1*n*i-n*n+n*e-i*e+r*o-r*r+r*t-o*t,l);for(var c=[],u=0;u<6;u+=2)Math.abs(l[u+1])<1e-7&&l[u]>=0&&l[u]<=1&&c.push(l[u]);c.push(1),c.push(0);for(var d,h,p,g=-1,f=0;f<c.length;f++)d=Math.pow(1-c[f],2)*n+2*(1-c[f])*c[f]*i+c[f]*c[f]*a,h=Math.pow(1-c[f],2)*r+2*(1-c[f])*c[f]*o+c[f]*c[f]*s,p=Math.pow(d-e,2)+Math.pow(h-t,2),g>=0?p<g&&(g=p):g=p;return g},Xt=function(e,t,n,r,i,o){var a=[e-n,t-r],s=[i-n,o-r],l=s[0]*s[0]+s[1]*s[1],c=a[0]*a[0]+a[1]*a[1],u=a[0]*s[0]+a[1]*s[1],d=u*u/l;return u<0?c:d>l?(e-i)*(e-i)+(t-o)*(t-o):c-d},Jt=function(e,t,n){for(var r,i,o,a,s=0,l=0;l<n.length/2;l++)if(r=n[2*l],i=n[2*l+1],l+1<n.length/2?(o=n[2*(l+1)],a=n[2*(l+1)+1]):(o=n[2*(l+1-n.length/2)],a=n[2*(l+1-n.length/2)+1]),r==e&&o==e);else{if(!(r>=e&&e>=o||r<=e&&e<=o))continue;(e-r)/(o-r)*(a-i)+i>t&&s++}return s%2!=0},Kt=function(e,t,n,r,i,o,a,s,l){var c,u=new Array(n.length);null!=s[0]?(c=Math.atan(s[1]/s[0]),s[0]<0?c+=Math.PI/2:c=-c-Math.PI/2):c=s;for(var d,h=Math.cos(-c),p=Math.sin(-c),g=0;g<u.length/2;g++)u[2*g]=o/2*(n[2*g]*h-n[2*g+1]*p),u[2*g+1]=a/2*(n[2*g+1]*h+n[2*g]*p),u[2*g]+=r,u[2*g+1]+=i;if(l>0){var f=tn(u,-l);d=en(f)}else d=u;return Jt(e,t,d)},en=function(e){for(var t,n,r,i,o,a,s,l,c=new Array(e.length/2),u=0;u<e.length/4;u++){t=e[4*u],n=e[4*u+1],r=e[4*u+2],i=e[4*u+3],u<e.length/4-1?(o=e[4*(u+1)],a=e[4*(u+1)+1],s=e[4*(u+1)+2],l=e[4*(u+1)+3]):(o=e[0],a=e[1],s=e[2],l=e[3]);var d=an(t,n,r,i,o,a,s,l,!0);c[2*u]=d[0],c[2*u+1]=d[1]}return c},tn=function(e,t){for(var n,r,i,o,a=new Array(2*e.length),s=0;s<e.length/2;s++){n=e[2*s],r=e[2*s+1],s<e.length/2-1?(i=e[2*(s+1)],o=e[2*(s+1)+1]):(i=e[0],o=e[1]);var l=o-r,c=-(i-n),u=Math.sqrt(l*l+c*c),d=l/u,h=c/u;a[4*s]=n+d*t,a[4*s+1]=r+h*t,a[4*s+2]=i+d*t,a[4*s+3]=o+h*t}return a},nn=function(e,t,n,r,i,o,a){return e-=i,t-=o,(e/=n/2+a)*e+(t/=r/2+a)*t<=1},rn=function(e,t,n,r,i,o,a){var s=[n-e,r-t],l=[e-i,t-o],c=s[0]*s[0]+s[1]*s[1],u=2*(l[0]*s[0]+l[1]*s[1]),d=u*u-4*c*(l[0]*l[0]+l[1]*l[1]-a*a);if(d<0)return[];var h=(-u+Math.sqrt(d))/(2*c),p=(-u-Math.sqrt(d))/(2*c),g=Math.min(h,p),f=Math.max(h,p),m=[];if(g>=0&&g<=1&&m.push(g),f>=0&&f<=1&&m.push(f),0===m.length)return[];var v=m[0]*s[0]+e,y=m[0]*s[1]+t;return m.length>1?m[0]==m[1]?[v,y]:[v,y,m[1]*s[0]+e,m[1]*s[1]+t]:[v,y]},on=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},an=function(e,t,n,r,i,o,a,s,l){var c=e-i,u=n-e,d=a-i,h=t-o,p=r-t,g=s-o,f=d*h-g*c,m=u*h-p*c,v=g*u-d*p;if(0!==v){var y=f/v,b=m/v,E=-.001;return E<=y&&y<=1.001&&E<=b&&b<=1.001||l?[e+y*u,t+y*p]:[]}return 0===f||0===m?on(e,n,a)===a?[a,s]:on(e,n,i)===i?[i,o]:on(i,a,n)===n?[n,r]:[]:[]},sn=function(e,t,n,r,i,o,a,s){var l,c,u,d,h,p,g=[],f=new Array(n.length),m=!0;if(null==o&&(m=!1),m){for(var v=0;v<f.length/2;v++)f[2*v]=n[2*v]*o+r,f[2*v+1]=n[2*v+1]*a+i;if(s>0){var y=tn(f,-s);c=en(y)}else c=f}else c=n;for(var b=0;b<c.length/2;b++)u=c[2*b],d=c[2*b+1],b<c.length/2-1?(h=c[2*(b+1)],p=c[2*(b+1)+1]):(h=c[0],p=c[1]),0!==(l=an(e,t,r,i,u,d,h,p)).length&&g.push(l[0],l[1]);return g},ln=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(r[0]*r[0]+r[1]*r[1]),o=(i-n)/i;return o<0&&(o=1e-5),[t[0]+o*r[0],t[1]+o*r[1]]},cn=function(e,t){var n=dn(e,t);return n=un(n)},un=function(e){for(var t,n,r=e.length/2,i=1/0,o=1/0,a=-1/0,s=-1/0,l=0;l<r;l++)t=e[2*l],n=e[2*l+1],i=Math.min(i,t),a=Math.max(a,t),o=Math.min(o,n),s=Math.max(s,n);for(var c=2/(a-i),u=2/(s-o),d=0;d<r;d++)t=e[2*d]=e[2*d]*c,n=e[2*d+1]=e[2*d+1]*u,i=Math.min(i,t),a=Math.max(a,t),o=Math.min(o,n),s=Math.max(s,n);if(o<-1)for(var h=0;h<r;h++)n=e[2*h+1]=e[2*h+1]+(-1-o);return e},dn=function(e,t){var n=1/e*2*Math.PI,r=e%2==0?Math.PI/2+n/2:Math.PI/2;r+=t;for(var i,o=new Array(2*e),a=0;a<e;a++)i=a*n+r,o[2*a]=Math.cos(i),o[2*a+1]=Math.sin(-i);return o},hn=function(e,t){return Math.min(e/4,t/4,8)},pn=function(e,t){return Math.min(e/10,t/10,8)},gn=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},fn=et({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),mn={pageRank:function(e){for(var t=fn(e),n=t.dampingFactor,r=t.precision,i=t.iterations,o=t.weight,a=this._private.cy,s=this.byGroup(),l=s.nodes,c=s.edges,u=l.length,d=u*u,h=c.length,p=new Array(d),g=new Array(u),f=(1-n)/u,m=0;m<u;m++){for(var v=0;v<u;v++){p[m*u+v]=0}g[m]=0}for(var y=0;y<h;y++){var b=c[y],E=b.data("source"),w=b.data("target");if(E!==w){var x=l.indexOfId(E),_=l.indexOfId(w),T=o(b);p[_*u+x]+=T,g[x]+=T}}for(var S=1/u+f,C=0;C<u;C++)if(0===g[C])for(var N=0;N<u;N++){p[N*u+C]=S}else for(var I=0;I<u;I++){var O=I*u+C;p[O]=p[O]/g[C]+f}for(var P,A=new Array(u),k=new Array(u),R=0;R<u;R++)A[R]=1;for(var L=0;L<i;L++){for(var D=0;D<u;D++)k[D]=0;for(var M=0;M<u;M++)for(var $=0;$<u;$++){var B=M*u+$;k[M]+=p[B]*A[$]}Lt(k),P=A,A=k,k=P;for(var z=0,V=0;V<u;V++){var F=P[V]-A[V];z+=F*F}if(z<r)break}return{rank:function(e){return e=a.collection(e)[0],A[l.indexOf(e)]}}}},vn=et({root:null,weight:function(e){return 1},directed:!1,alpha:0}),yn={degreeCentralityNormalized:function(e){e=vn(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var i={},o={},a=0,s=0,l=0;l<r;l++){var c=n[l],u=c.id();e.root=c;var d=this.degreeCentrality(e);a<d.indegree&&(a=d.indegree),s<d.outdegree&&(s=d.outdegree),i[u]=d.indegree,o[u]=d.outdegree}return{indegree:function(e){return 0==a?0:(b(e)&&(e=t.filter(e)),i[e.id()]/a)},outdegree:function(e){return 0===s?0:(b(e)&&(e=t.filter(e)),o[e.id()]/s)}}}for(var h={},p=0,g=0;g<r;g++){var f=n[g];e.root=f;var m=this.degreeCentrality(e);p<m.degree&&(p=m.degree),h[f.id()]=m.degree}return{degree:function(e){return 0===p?0:(b(e)&&(e=t.filter(e)),h[e.id()]/p)}}},degreeCentrality:function(e){e=vn(e);var t=this.cy(),n=this,r=e,i=r.root,o=r.weight,a=r.directed,s=r.alpha;if(i=t.collection(i)[0],a){for(var l=i.connectedEdges(),c=l.filter((function(e){return e.target().same(i)&&n.has(e)})),u=l.filter((function(e){return e.source().same(i)&&n.has(e)})),d=c.length,h=u.length,p=0,g=0,f=0;f<c.length;f++)p+=o(c[f]);for(var m=0;m<u.length;m++)g+=o(u[m]);return{indegree:Math.pow(d,1-s)*Math.pow(p,s),outdegree:Math.pow(h,1-s)*Math.pow(g,s)}}for(var v=i.connectedEdges().intersection(n),y=v.length,b=0,E=0;E<v.length;E++)b+=o(v[E]);return{degree:Math.pow(y,1-s)*Math.pow(b,s)}}};yn.dc=yn.degreeCentrality,yn.dcn=yn.degreeCentralityNormalised=yn.degreeCentralityNormalized;var bn=et({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),En={closenessCentralityNormalized:function(e){for(var t=bn(e),n=t.harmonic,r=t.weight,i=t.directed,o=this.cy(),a={},s=0,l=this.nodes(),c=this.floydWarshall({weight:r,directed:i}),u=0;u<l.length;u++){for(var d=0,h=l[u],p=0;p<l.length;p++)if(u!==p){var g=c.distance(h,l[p]);d+=n?1/g:g}n||(d=1/d),s<d&&(s=d),a[h.id()]=d}return{closeness:function(e){return 0==s?0:(e=b(e)?o.filter(e)[0].id():e.id(),a[e]/s)}}},closenessCentrality:function(e){var t=bn(e),n=t.root,r=t.weight,i=t.directed,o=t.harmonic;n=this.filter(n)[0];for(var a=this.dijkstra({root:n,weight:r,directed:i}),s=0,l=this.nodes(),c=0;c<l.length;c++){var u=l[c];if(!u.same(n)){var d=a.distanceTo(u);s+=o?1/d:d}}return o?s:1/s}};En.cc=En.closenessCentrality,En.ccn=En.closenessCentralityNormalised=En.closenessCentralityNormalized;var wn=et({weight:null,directed:!1}),xn={betweennessCentrality:function(e){for(var t=wn(e),n=t.directed,r=t.weight,i=null!=r,o=this.cy(),a=this.nodes(),s={},l={},c=0,u=function(e,t){l[e]=t,t>c&&(c=t)},d=function(e){return l[e]},h=0;h<a.length;h++){var p=a[h],g=p.id();s[g]=n?p.outgoers().nodes():p.openNeighborhood().nodes(),u(g,0)}for(var f=function(e){for(var t=a[e].id(),n=[],l={},c={},h={},p=new ht((function(e,t){return h[e]-h[t]})),g=0;g<a.length;g++){var f=a[g].id();l[f]=[],c[f]=0,h[f]=1/0}for(c[t]=1,h[t]=0,p.push(t);!p.empty();){var m=p.pop();if(n.push(m),i)for(var v=0;v<s[m].length;v++){var y=s[m][v],b=o.getElementById(m),E=void 0;E=b.edgesTo(y).length>0?b.edgesTo(y)[0]:y.edgesTo(b)[0];var w=r(E);y=y.id(),h[y]>h[m]+w&&(h[y]=h[m]+w,p.nodes.indexOf(y)<0?p.push(y):p.updateItem(y),c[y]=0,l[y]=[]),h[y]==h[m]+w&&(c[y]=c[y]+c[m],l[y].push(m))}else for(var x=0;x<s[m].length;x++){var _=s[m][x].id();h[_]==1/0&&(p.push(_),h[_]=h[m]+1),h[_]==h[m]+1&&(c[_]=c[_]+c[m],l[_].push(m))}}for(var T={},S=0;S<a.length;S++)T[a[S].id()]=0;for(;n.length>0;){for(var C=n.pop(),N=0;N<l[C].length;N++){var I=l[C][N];T[I]=T[I]+c[I]/c[C]*(1+T[C])}C!=a[e].id()&&u(C,d(C)+T[C])}},m=0;m<a.length;m++)f(m);var v={betweenness:function(e){var t=o.collection(e).id();return d(t)},betweennessNormalized:function(e){if(0==c)return 0;var t=o.collection(e).id();return d(t)/c}};return v.betweennessNormalised=v.betweennessNormalized,v}};xn.bc=xn.betweennessCentrality;var _n=et({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),Tn=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},Sn=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var i=0;i<t;i++)n+=e[i*t+r];for(var o=0;o<t;o++)e[o*t+r]=e[o*t+r]/n}},Cn=function(e,t,n){for(var r=new Array(n*n),i=0;i<n;i++){for(var o=0;o<n;o++)r[i*n+o]=0;for(var a=0;a<n;a++)for(var s=0;s<n;s++)r[i*n+s]+=e[i*n+a]*t[a*n+s]}return r},Nn=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=Cn(e,r,t);return e},In=function(e,t,n){for(var r=new Array(t*t),i=0;i<t*t;i++)r[i]=Math.pow(e[i],n);return Sn(r,t),r},On=function(e,t,n,r){for(var i=0;i<n;i++){if(Math.round(e[i]*Math.pow(10,r))/Math.pow(10,r)!==Math.round(t[i]*Math.pow(10,r))/Math.pow(10,r))return!1}return!0},Pn=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},An=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=function(e){return _n(e)}(e),o={},a=0;a<t.length;a++)o[t[a].id()]=a;for(var s,l=t.length,c=l*l,u=new Array(c),d=0;d<c;d++)u[d]=0;for(var h=0;h<n.length;h++){var p=n[h],g=o[p.source().id()],f=o[p.target().id()],m=Tn(p,i.attributes);u[g*l+f]+=m,u[f*l+g]+=m}!function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n}(u,l,i.multFactor),Sn(u,l);for(var v=!0,y=0;v&&y<i.maxIterations;)v=!1,s=Nn(u,l,i.expandFactor),u=In(s,l,i.inflateFactor),On(u,s,c,4)||(v=!0),y++;var b=function(e,t,n,r){for(var i=[],o=0;o<t;o++){for(var a=[],s=0;s<t;s++)Math.round(1e3*e[o*t+s])/1e3>0&&a.push(n[s]);0!==a.length&&i.push(r.collection(a))}return i}(u,l,t,r);return b=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&Pn(e[t],e[n])&&e.splice(n,1);return e}(b),b},kn={markovClustering:An,mcl:An},Rn=function(e){return e},Ln=function(e,t){return Math.abs(t-e)},Dn=function(e,t,n){return e+Ln(t,n)},Mn=function(e,t,n){return e+Math.pow(n-t,2)},$n=function(e){return Math.sqrt(e)},Bn=function(e,t,n){return Math.max(e,Ln(t,n))},zn=function(e,t,n,r,i){for(var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:Rn,a=r,s=0;s<e;s++)a=i(a,t(s),n(s));return o(a)},Vn={euclidean:function(e,t,n){return e>=2?zn(e,t,n,0,Mn,$n):zn(e,t,n,0,Dn)},squaredEuclidean:function(e,t,n){return zn(e,t,n,0,Mn)},manhattan:function(e,t,n){return zn(e,t,n,0,Dn)},max:function(e,t,n){return zn(e,t,n,-1/0,Bn)}};function Fn(e,t,n,r,i,o){var a;return a=E(e)?e:Vn[e]||Vn.euclidean,0===t&&E(e)?a(i,o):a(t,n,r,i,o)}Vn["squared-euclidean"]=Vn.squaredEuclidean,Vn.squaredeuclidean=Vn.squaredEuclidean;var qn=et({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),jn=function(e){return qn(e)},Hn=function(e,t,n,r,i){var o="kMedoids"!==i?function(e){return n[e]}:function(e){return r[e](n)},a=n,s=t;return Fn(e,r.length,o,(function(e){return r[e](t)}),a,s)},Gn=function(e,t,n){for(var r=n.length,i=new Array(r),o=new Array(r),a=new Array(t),s=null,l=0;l<r;l++)i[l]=e.min(n[l]).value,o[l]=e.max(n[l]).value;for(var c=0;c<t;c++){s=[];for(var u=0;u<r;u++)s[u]=Math.random()*(o[u]-i[u])+i[u];a[c]=s}return a},Un=function(e,t,n,r,i){for(var o=1/0,a=0,s=0;s<t.length;s++){var l=Hn(n,e,t[s],r,i);l<o&&(o=l,a=s)}return a},Yn=function(e,t,n){for(var r=[],i=null,o=0;o<t.length;o++)n[(i=t[o]).id()]===e&&r.push(i);return r},Qn=function(e,t,n){return Math.abs(t-e)<=n},Zn=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++){if(Math.abs(e[r][i]-t[r][i])>n)return!1}return!0},Wn=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},Xn=function(e,t){var n=new Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var i=e[Math.floor(Math.random()*e.length)];Wn(i,n,r);)i=e[Math.floor(Math.random()*e.length)];n[r]=i}else for(var o=0;o<t;o++)n[o]=e[Math.floor(Math.random()*e.length)];return n},Jn=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=Hn("manhattan",t[i],e,n,"kMedoids");return r},Kn=function(e,t,n,r,i){for(var o,a,s=0;s<t.length;s++)for(var l=0;l<e.length;l++)r[s][l]=Math.pow(n[s][l],i.m);for(var c=0;c<e.length;c++)for(var u=0;u<i.attributes.length;u++){o=0,a=0;for(var d=0;d<t.length;d++)o+=r[d][c]*i.attributes[u](t[d]),a+=r[d][c];e[c][u]=o/a}},er=function(e,t,n,r,i){for(var o=0;o<e.length;o++)t[o]=e[o].slice();for(var a,s,l,c=2/(i.m-1),u=0;u<n.length;u++)for(var d=0;d<r.length;d++){a=0;for(var h=0;h<n.length;h++)s=Hn(i.distance,r[d],n[u],i.attributes,"cmeans"),l=Hn(i.distance,r[d],n[h],i.attributes,"cmeans"),a+=Math.pow(s/l,c);e[d][u]=1/a}},tr=function(e){var t,n,r,i,o,a=this.cy(),s=this.nodes(),l=jn(e);i=new Array(s.length);for(var c=0;c<s.length;c++)i[c]=new Array(l.k);r=new Array(s.length);for(var u=0;u<s.length;u++)r[u]=new Array(l.k);for(var d=0;d<s.length;d++){for(var h=0,p=0;p<l.k;p++)r[d][p]=Math.random(),h+=r[d][p];for(var g=0;g<l.k;g++)r[d][g]=r[d][g]/h}n=new Array(l.k);for(var f=0;f<l.k;f++)n[f]=new Array(l.attributes.length);o=new Array(s.length);for(var m=0;m<s.length;m++)o[m]=new Array(l.k);for(var v=!0,y=0;v&&y<l.maxIterations;)v=!1,Kn(n,s,r,o,l),er(r,i,n,s,l),Zn(r,i,l.sensitivityThreshold)||(v=!0),y++;return t=function(e,t,n,r){for(var i,o,a=new Array(n.k),s=0;s<a.length;s++)a[s]=[];for(var l=0;l<t.length;l++){i=-1/0,o=-1;for(var c=0;c<t[0].length;c++)t[l][c]>i&&(i=t[l][c],o=c);a[o].push(e[l])}for(var u=0;u<a.length;u++)a[u]=r.collection(a[u]);return a}(s,r,l,a),{clusters:t,degreeOfMembership:r}},nr={kMeans:function(e){var t,n=this.cy(),i=this.nodes(),o=null,a=jn(e),s=new Array(a.k),l={};a.testMode?"number"==typeof a.testCentroids?(a.testCentroids,t=Gn(i,a.k,a.attributes)):t="object"===r(a.testCentroids)?a.testCentroids:Gn(i,a.k,a.attributes):t=Gn(i,a.k,a.attributes);for(var c=!0,u=0;c&&u<a.maxIterations;){for(var d=0;d<i.length;d++)l[(o=i[d]).id()]=Un(o,t,a.distance,a.attributes,"kMeans");c=!1;for(var h=0;h<a.k;h++){var p=Yn(h,i,l);if(0!==p.length){for(var g=a.attributes.length,f=t[h],m=new Array(g),v=new Array(g),y=0;y<g;y++){v[y]=0;for(var b=0;b<p.length;b++)o=p[b],v[y]+=a.attributes[y](o);m[y]=v[y]/p.length,Qn(m[y],f[y],a.sensitivityThreshold)||(c=!0)}t[h]=m,s[h]=n.collection(p)}}u++}return s},kMedoids:function(e){var t,n,i=this.cy(),o=this.nodes(),a=null,s=jn(e),l=new Array(s.k),c={},u=new Array(s.k);s.testMode?"number"==typeof s.testCentroids||(t="object"===r(s.testCentroids)?s.testCentroids:Xn(o,s.k)):t=Xn(o,s.k);for(var d=!0,h=0;d&&h<s.maxIterations;){for(var p=0;p<o.length;p++)c[(a=o[p]).id()]=Un(a,t,s.distance,s.attributes,"kMedoids");d=!1;for(var g=0;g<t.length;g++){var f=Yn(g,o,c);if(0!==f.length){u[g]=Jn(t[g],f,s.attributes);for(var m=0;m<f.length;m++)(n=Jn(f[m],f,s.attributes))<u[g]&&(u[g]=n,t[g]=f[m],d=!0);l[g]=i.collection(f)}}h++}return l},fuzzyCMeans:tr,fcm:tr},rr=et({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),ir={single:"