@antv/algorithm
Advanced tools
Comparing version 0.1.0-beta.2 to 0.1.0-beta.3
@@ -1,2 +0,2 @@ | ||
(this.webpackChunkAlgorithm=this.webpackChunkAlgorithm||[]).push([[1],{1:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var n=r(989),o=r.n(n);function i(){return o()('(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>re,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>m,findAllPath:()=>M,findShortestPath:()=>N,floydWarshall:()=>j,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>v,labelPropagation:()=>k,louvain:()=>x,minimumSpanningTree:()=>T,pageRank:()=>q});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new a,i=e.edges,s=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),d(e,s,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||c(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},v=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function g(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;d(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&g(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){g(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const m=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},v=0;v<l;v++)p();c[t]=[t];var g={};for(var b in h)h[b]!==1/0&&L(t,b,c,g);var E={};for(var b in g)E[b]=g[b][0];return{length:h,path:E,allPaths:g}};function L(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=L(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(y(f,[t]))}}n[t]=o}var N=function(e,t,r,n,o){var i=m(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},M=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));h.push(v),g=s.pop(),u[g]=!1,f.pop()}}else{var g=s.pop();u[g]=!1,f.pop()}}return h};const j=function(e,t){for(var n=r(e,t),o=[],i=n.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==n[a][d]&&n[a][d]?o[a][d]=n[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o},k=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var y=[];return Object.keys(f).forEach((function(e){y.push(f[e])})),{clusters:y,clusterEdges:b}};var w=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const x=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},v=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,E=0;g=w(a,c,l,v),!(Math.abs(g-b)<o||E>100);)b=g,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var y=0,m=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(y+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(m+=e[n]||1)})),r.sumTot=y,o.sumTot=m}}));Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var y=[],m={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,y.push(s)}}));var L=[];return Object.keys(f).forEach((function(e){L.push(f[e])})),{clusters:L,clusterEdges:y}},I=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var O=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=O),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new I(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const T=function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(e,t)},q=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},v={},g=0;g<c;++g)p[E=(M=u[g]).id]=1/c,v[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<c;++g){var E=(M=u[g]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var y=d(E,h,"source"),m=0;m<y.length;++m){var L=y[m],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,g=0;g<c;++g){var M;n=p[E=(M=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v};var F={}.toString;const A=function(e,t){return F.call(e)==="[object "+t+"]"},D=function(e){return Array.isArray?Array.isArray(e):A(e,"Array")};Object.keys;var R=Array.prototype;R.splice,R.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const U=function e(t){if("object"!=typeof t||null===t)return t;var r;if(D(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var G="-1",z=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},B=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),H=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new B(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new z(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new z(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),_=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new _(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new H(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new _(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,v=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new _(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var y={};c=!1;var m=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,m=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,m=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!c)return!0;var M=e.findMinLabel(y);i.dfsEdgeList.push(new _(m,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(U(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new _(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new _(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new _(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,v=0;v<p;v++){var g=o[c[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};const re=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=j(e,r),u=j(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,v=$(t.nodes,i),g=v.nodeMap,b=v.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,g).edgeLabelMap;o||(o=Math.max.apply(Math,y(u[0],[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),k=Y(M,L,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?Q:o,a=e.edgeLabelProp,d=void 0===a?Q:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new H(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:k,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(k).forEach((function(r){var n=k[r],o=Z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),S=O.structure,C=O.structureCountMap,P=t.nodes[0],T=P[i],q=p[T],F={},A={},D={},R={},U={};Object.keys(b).forEach((function(r,n){U[r]=[];var o=-1/0,d=b[r],s={};d.forEach((function(e){var t=h[P.id+"-"+e.id];t&&U[r].push(t),o<t&&(o=t),s[P.id+"-"+e.id]={start:0,end:g[e.id].idx,distance:t}})),U[r]=U[r].sort((function(e,t){return e-t})),A=Y(s,N,t,A);var u=[];if(Object.keys(s).forEach((function(e){if(D[e])u.push(D[e]);else{var t=A[e];D[e]=Z(t,S,i,a),u.push(D[e])}})),u=u.sort((function(e,t){return t-e})),R[P.id+"-"+r]=u,r!==T)for(var c=function(t){var n=q[t],o=L[l[n.id].idx],d=o.nodeLabelCountMap[r],s=b[r].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var h=!1,c=0;c<s;c++)if(d.dists[c]>U[r][c]){h=!0;break}if(h)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),k=Y(p,L,e,k);var v=[];Object.keys(p).forEach((function(e){if(C[e])v.push(C[e]);else{var t=k[e];C[e]=Z(t,S,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(c=0;c<s;c++)if(v[c]<u[c]){g=!0;break}return g?(q.splice(t,1),"continue"):void 0},p=q.length-1;p>=0;p--)c(p)}));var G=[];q.forEach((function(r){for(var n=l[r.id].idx,d=X(e.nodes,s[n],n,i,o).neighbors,u=d.length,h=!1,c=function(n){if(d.length+1<t.nodes.length)return h=!0,{value:void 0};var o=d[n],s=o[i];if(!b[s]||!b[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!U[s]||!U[s].length)return d.splice(n,1),"continue";var c=f[u];if(c>U[s][U[s].length-1])return d.splice(n,1),"continue";var p=C[u]?C[u]:function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)}(e,r,o,l,c,L,S,i,a,C,k),v=P.id+"-"+s;if(p<R[v][R[v].length-1])return d.splice(n,1),"continue";var E=F[s];return void 0===E&&(E=1/0,b[s].forEach((function(e){var t=g[e.id].degree;E>t&&(E=t)})),F[s]=E),l[o.id].degree<E?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=c(p);if("object"==typeof v)return v.value}h||G.push({nodes:[r].concat(d)})}));var z=m(t,P.id,!1).length,B={};r?(Object.keys(z).forEach((function(e){var t=g[e].node[i];B[t]?B[t].push(z[e]):B[t]=[z[e]]})),Object.keys(B).forEach((function(e){B[e].sort((function(e,t){return e-t}))}))):B=U;for(var _=function(n){var o=G[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var c=Object.keys(E).length,p=!1,v=0;v<c;v++){var y=Object.keys(E)[v];if(!h[y]||h[y]<E[y].length){p=!0;break}}if(p)return G.splice(n,1),"continue";var L=f.length;if(L<t.edges.length)return G.splice(n,1),"break";var N=!1,M=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],c=!1;return o.forEach((function(e){var t=g[e.source].node,n=g[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=L-1;v>=0&&"break"!==M(v);v--);if(N)return G.splice(n,1),"continue";o.edges=f;var j=m(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];return s[t]--,s[t]<b[t].length?void(N=!0):(o.nodes.splice(u[e].idx,1),void(u[e]=void 0))}var r=l[e].node[i];if(!B[r]||!B[r].length||j[e]>B[r][B[r].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(N=!0);o.nodes.splice(u[e].idx,1),u[e]=void 0}}})),N)return G.splice(n,1),"continue";for(var k=!0,w=0;k&&!N;){if(k=!1,u[d.id].degree<g[P.id].degree){N=!0;break}if(s[d[i]]<b[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,S=I[i];if(O<F[S]){if(s[I[i]]--,s[I[i]]<b[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,k=!0}}if(N||!k&&0!==w)break;for(var C=(L=f.length)-1;C>=0;C--){var T=f[C];if(!u[T.source]||!u[T.target]){f.splice(C,1);var q=T[a];if(h[q]--,u[T.source]&&u[T.source].degree--,u[T.target]&&u[T.target].degree--,E[q]&&h[q]<E[q].length){N=!0;break}k=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(G.splice(n,1),"continue"):void 0},K=G.length-1;K>=0&&"break"!==_(K);K--);var W=G.length,re=function(e){var t=G[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=G[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&G.splice(e,1)},o=W-1;o>e;o--)n(o);W=G.length};for(K=0;K<=W-1;K++)re(K);return G}}};var ne=self;ne.onmessage=function(e){var r=e.data,n=r.type,o=r.data;if("function"!=typeof t[n])ne.postMessage({type:"FAILURE"});else{var i=t[n].apply(t,o);ne.postMessage({type:"SUCCESS",data:i})}}})();\n//# sourceMappingURL=index.worker.js.map',"Worker",void 0,r.p+"index.worker.js")}},989:e=>{"use strict";e.exports=function(e,t,r,n){try{try{var o;try{o=new window.Blob([e])}catch(t){(o=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(e),o=o.getBlob()}var i=window.URL||window.webkitURL,a=i.createObjectURL(o),d=new window[t](a,r);return i.revokeObjectURL(a),d}catch(n){return new window[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new window[t](n,r)}}}}]); | ||
(this.webpackChunkAlgorithm=this.webpackChunkAlgorithm||[]).push([[1],{1:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var n=r(989),o=r.n(n);function i(){return o()('(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>re,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>m,findAllPath:()=>M,findShortestPath:()=>N,floydWarshall:()=>j,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>v,labelPropagation:()=>k,louvain:()=>x,minimumSpanningTree:()=>T,pageRank:()=>q});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new a,i=e.edges,s=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),d(e,s,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||c(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},v=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function g(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;d(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&g(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){g(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const m=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},v=0;v<l;v++)p();c[t]=[t];var g={};for(var b in h)h[b]!==1/0&&L(t,b,c,g);var E={};for(var b in g)E[b]=g[b][0];return{length:h,path:E,allPaths:g}};function L(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=L(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(y(f,[t]))}}n[t]=o}var N=function(e,t,r,n,o){var i=m(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},M=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));h.push(v),g=s.pop(),u[g]=!1,f.pop()}}else{var g=s.pop();u[g]=!1,f.pop()}}return h};const j=function(e,t){for(var n=r(e,t),o=[],i=n.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==n[a][d]&&n[a][d]?o[a][d]=n[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o},k=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var y=[];return Object.keys(f).forEach((function(e){y.push(f[e])})),{clusters:y,clusterEdges:b}};var w=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const x=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},v=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,E=0;g=w(a,c,l,v),!(Math.abs(g-b)<o||E>100);)b=g,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var y=0,m=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(y+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(m+=e[n]||1)})),r.sumTot=y,o.sumTot=m}}));Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var y=[],m={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,y.push(s)}}));var L=[];return Object.keys(f).forEach((function(e){L.push(f[e])})),{clusters:L,clusterEdges:y}},I=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var O=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=O),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new I(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const T=function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(e,t)},q=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},v={},g=0;g<c;++g)p[E=(M=u[g]).id]=1/c,v[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<c;++g){var E=(M=u[g]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var y=d(E,h,"source"),m=0;m<y.length;++m){var L=y[m],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,g=0;g<c;++g){var M;n=p[E=(M=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v};var F={}.toString;const A=function(e,t){return F.call(e)==="[object "+t+"]"},D=function(e){return Array.isArray?Array.isArray(e):A(e,"Array")};Object.keys;var R=Array.prototype;R.splice,R.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const U=function e(t){if("object"!=typeof t||null===t)return t;var r;if(D(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var G="-1",z=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},B=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),H=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new B(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new z(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new z(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),_=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new _(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new H(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new _(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,v=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new _(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var y={};c=!1;var m=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,m=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,m=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!c)return!0;var M=e.findMinLabel(y);i.dfsEdgeList.push(new _(m,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(U(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new _(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new _(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new _(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,v=0;v<p;v++){var g=o[c[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};const re=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=j(e,r),u=j(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,v=$(t.nodes,i),g=v.nodeMap,b=v.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,g).edgeLabelMap;o||(o=Math.max.apply(Math,y(u[0],[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),k=Y(M,L,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?Q:o,a=e.edgeLabelProp,d=void 0===a?Q:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new H(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:k,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(k).forEach((function(r){var n=k[r],o=Z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),S=O.structure,C=O.structureCountMap,P=t.nodes[0],T=P[i],q=p[T],F={},A={},D={},R={},U={};Object.keys(b).forEach((function(r,n){U[r]=[];var o=-1/0,d=b[r],s={};d.forEach((function(e){var t=h[P.id+"-"+e.id];t&&U[r].push(t),o<t&&(o=t),s[P.id+"-"+e.id]={start:0,end:g[e.id].idx,distance:t}})),U[r]=U[r].sort((function(e,t){return e-t})),A=Y(s,N,t,A);var u=[];if(Object.keys(s).forEach((function(e){if(D[e])u.push(D[e]);else{var t=A[e];D[e]=Z(t,S,i,a),u.push(D[e])}})),u=u.sort((function(e,t){return t-e})),R[P.id+"-"+r]=u,r!==T)for(var c=function(t){var n=q[t],o=L[l[n.id].idx],d=o.nodeLabelCountMap[r],s=b[r].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var h=!1,c=0;c<s;c++)if(d.dists[c]>U[r][c]){h=!0;break}if(h)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),k=Y(p,L,e,k);var v=[];Object.keys(p).forEach((function(e){if(C[e])v.push(C[e]);else{var t=k[e];C[e]=Z(t,S,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(c=0;c<s;c++)if(v[c]<u[c]){g=!0;break}return g?(q.splice(t,1),"continue"):void 0},p=q.length-1;p>=0;p--)c(p)}));var G=[];q.forEach((function(r){for(var n=l[r.id].idx,d=X(e.nodes,s[n],n,i,o).neighbors,u=d.length,h=!1,c=function(n){if(d.length+1<t.nodes.length)return h=!0,{value:void 0};var o=d[n],s=o[i];if(!b[s]||!b[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!U[s]||!U[s].length)return d.splice(n,1),"continue";var c=f[u];if(c>U[s][U[s].length-1])return d.splice(n,1),"continue";var p=C[u]?C[u]:function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)}(e,r,o,l,c,L,S,i,a,C,k),v=P.id+"-"+s;if(p<R[v][R[v].length-1])return d.splice(n,1),"continue";var E=F[s];return void 0===E&&(E=1/0,b[s].forEach((function(e){var t=g[e.id].degree;E>t&&(E=t)})),F[s]=E),l[o.id].degree<E?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=c(p);if("object"==typeof v)return v.value}h||G.push({nodes:[r].concat(d)})}));var z=m(t,P.id,!1).length,B={};r?(Object.keys(z).forEach((function(e){var t=g[e].node[i];B[t]?B[t].push(z[e]):B[t]=[z[e]]})),Object.keys(B).forEach((function(e){B[e].sort((function(e,t){return e-t}))}))):B=U;for(var _=function(n){var o=G[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var c=Object.keys(E).length,p=!1,v=0;v<c;v++){var y=Object.keys(E)[v];if(!h[y]||h[y]<E[y].length){p=!0;break}}if(p)return G.splice(n,1),"continue";var L=f.length;if(L<t.edges.length)return G.splice(n,1),"break";var N=!1,M=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],c=!1;return o.forEach((function(e){var t=g[e.source].node,n=g[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=L-1;v>=0&&"break"!==M(v);v--);if(N)return G.splice(n,1),"continue";o.edges=f;var j=m(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[t].length)return void(N=!0);var r=o.nodes.indexOf(u[e].node);return o.nodes.splice(r,1),void(u[e]=void 0)}var n=l[e].node[i];if(!B[n]||!B[n].length||j[e]>B[n][B[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(N=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),N)return G.splice(n,1),"continue";for(var k=!0,w=0;k&&!N;){if(k=!1,u[d.id].degree<g[P.id].degree){N=!0;break}if(s[d[i]]<b[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,S=I[i];if(O<F[S]){if(s[I[i]]--,s[I[i]]<b[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,k=!0}}if(N||!k&&0!==w)break;for(var C=(L=f.length)-1;C>=0;C--){var T=f[C];if(!u[T.source]||!u[T.target]){f.splice(C,1);var q=T[a];if(h[q]--,u[T.source]&&u[T.source].degree--,u[T.target]&&u[T.target].degree--,E[q]&&h[q]<E[q].length){N=!0;break}k=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(G.splice(n,1),"continue"):void 0},K=G.length-1;K>=0&&"break"!==_(K);K--);var W=G.length,re=function(e){var t=G[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=G[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&G.splice(e,1)},o=W-1;o>e;o--)n(o);W=G.length};for(K=0;K<=W-1;K++)re(K);return G}}};var ne=self;ne.onmessage=function(e){var r=e.data,n=r.type,o=r.data;if("function"!=typeof t[n])ne.postMessage({type:"FAILURE"});else{var i=t[n].apply(t,o);ne.postMessage({type:"SUCCESS",data:i})}}})();\n//# sourceMappingURL=index.worker.js.map',"Worker",void 0,r.p+"index.worker.js")}},989:e=>{"use strict";e.exports=function(e,t,r,n){try{try{var o;try{o=new window.Blob([e])}catch(t){(o=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder)).append(e),o=o.getBlob()}var i=window.URL||window.webkitURL,a=i.createObjectURL(o),d=new window[t](a,r);return i.revokeObjectURL(a),d}catch(n){return new window[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new window[t](n,r)}}}}]); | ||
//# sourceMappingURL=1.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Algorithm=t():e.Algorithm=t()}(this,(function(){return(()=>{"use strict";var e,t,r={537:(e,t,r)=>{r.d(t,{default:()=>J});const n=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var o=function(e,t){return e===t},i=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const a=function(){function e(e){void 0===e&&(e=o),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new i(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new i(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),d=function(){function e(){this.linkedList=new a}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var s=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},u=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},f=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const h=c;function l(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;s(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&l(e,o,t,n)})),n.leave({current:t,previous:r})}function p(e,t,r){l(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const g=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,s=[],f={},c={},h={};i.forEach((function(e,r){var n=e.id;s.push(n),c[n]=1/0,n===t&&(c[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(c,i,f),o=t.id;if(f[o]=!0,c[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):u(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;c[a]>c[t.id]+d?(c[a]=c[t.id]+d,h[a]=[t.id]):c[a]===c[t.id]+d&&h[a].push(t.id)}))},v=0;v<l;v++)p();h[t]=[t];var g={};for(var m in c)c[m]!==1/0&&b(t,m,h,g);var y={};for(var m in g)y[m]=g[m][0];return{length:c,path:y,allPaths:g}};function b(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=b(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(v(f,[t]))}}n[t]=o}const m=function(e,t){for(var r=n(e,t),o=[],i=r.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==r[a][d]&&r[a][d]?o[a][d]=r[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o};var y=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const E=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var L=function(e,t){return e-t};const N=function(){function e(e){void 0===e&&(e=L),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var k=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],s=new Set;s.add(d);var f=new N((function(e,r){return t?e.weight-r.weight:0}));for(u(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var c=f.delMin(),h=c.source,l=c.target;s.has(h)&&s.has(l)||(r.push(c),s.has(h)||(s.add(h),u(h,a).forEach((function(e){f.insert(e)}))),s.has(l)||(s.add(l),u(l,a).forEach((function(e){f.insert(e)}))))}return r},j=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new E(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,c=u.target;s.connected(f,c)||(r.push(u),s.union(f,c))}return r};var M={}.toString;const w=function(e,t){return M.call(e)==="[object "+t+"]"},x=function(e){return Array.isArray?Array.isArray(e):w(e,"Array")};Object.keys;var I=Array.prototype;I.splice,I.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const O=function e(t){if("object"!=typeof t||null===t)return t;var r;if(x(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var A="-1",S=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},C=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=A),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),P=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new C(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new S(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new S(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),T=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||A,edgeLabel:n||"-1",nodeLabel2:o||A}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),D=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new T(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new P(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==A&&r.addNode(t,i),d!==A&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),q=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),F=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,c=void 0!==f&&f,h=e.verbose,l=void 0!==h&&h;this.graphs=t,this.dfsCode=new D,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=c,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],c=i[f.to].label;t.to===f.to||r>c||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=c)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new D,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new T(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,c={},h=!1,l=0,p=r?-1:0,v=function(t){if(h)return"break";a.forEach((function(r){var o=new q(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(c[a.label]||(c[a.label]={projected:[],edgeLabel:a.label}),c[a.label].projected.push({graphId:n.id,edge:c,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,h=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(h){var b=e.findMinLabel(c);i.dfsEdgeList.push(new T(f,l,A,b.edgeLabel,A));var m=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[m]===i.dfsEdgeList[m]&&s(c[b.edgeLabel].projected)}var y={};h=!1;var E=0;a.forEach((function(t){var r=new q(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(h=!0,E=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(h)return"break";var r=d[t];a.forEach((function(t){var a=new q(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(h=!0,E=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!h)return!0;var k=e.findMinLabel(y);i.dfsEdgeList.push(new T(E,f+1,A,k.edgeLabel,k.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[k.edgeLabel+"-"+k.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(O(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new q(e),c=n.length-1;c>=0;c--){var h=t.findBackwardEdge(s,f.edges[n[c]],f.edges[n[0]],f);if(h){var l=t.dfsCode.dfsEdgeList[n[c]].fromNode+"-"+h.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[c]].fromNode,edgeLabel:h.label}),d[l].projected.push({graphId:e.graphId,edge:h,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(c=0;c<n.length;c++)p(c)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new T(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new T(n,o+1,A,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var c=o[u]||0;c++,o[u]=c}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,c=r+"-"+n+"-"+f+"-"+o,h=n+"-"+f+"-"+o;if(!i[h]){var l=i[h]||0;l++,i[h]=l}d[c]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new T(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),R="cluster";var G=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(U(i,e,t,r,n))})),o},U=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},B=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var c=new Set(f),h=u.filter((function(e){return c.has(e)}));if(h&&h.length){for(var l={},p=h.length,v=0;v<p;v++){var g=o[h[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},_=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},W=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+f]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},$=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};var H="SUCCESS";const K=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new Promise((function(n,o){r.e(1).then(r.bind(r,1)).then((function(r){var i=new r.default;i.postMessage({type:e,data:t}),i.onmessage=function(e){var t=e.data,r=t.data,a=t.type;H===a?n(r):o(),i.terminate()}}))}))}},J={getAdjMatrix:n,breadthFirstSearch:function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new d,i=e.edges,a=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),s(e,a,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()},connectedComponent:function(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},d={},u={},f=[],c=0,h=function(e){d[e.id]=c,u[e.id]=c,c+=1,i.push(e),a[e.id]=!0;for(var t=s(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(d[o]||0===d[o])a[o]&&(u[e.id]=Math.min(u[e.id],d[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&h(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===d[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];d[v.id]||0===d[v.id]||h(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},d=[],u=function(e){d.push(e),a[e.id]=!0;for(var t=s(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var c=r[f];if(!a[c.id]){u(c);for(var h=[];d.length>0;)h.push(d.pop());i.push(h)}}return i}(e)},getDegree:h,getInDegree:function(e,t){return c(e)[t]?c(e)[t].inDegree:0},getOutDegree:function(e,t){return c(e)[t]?c(e)[t].outDegree:0},detectCycle:function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)p(e,Object.keys(o)[0],d);return t},depthFirstSearch:p,dijkstra:g,findAllPath:function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,d=[t],u=((o={})[t]=!0,o),f=[],c=[],h=n?s(t,a,"target"):s(t,a);for(f.push(h);d.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(d.push(p),u[p]=!0,h=n?s(p,a,"target"):s(p,a),f.push(h.filter((function(e){return!u[e]})))),d[d.length-1]===r){var v=d.map((function(e){return e}));c.push(v),g=d.pop(),u[g]=!1,f.pop()}}else{var g=d.pop();u[g]=!1,f.pop()}}return c},findShortestPath:function(e,t,r,n,o){var i=g(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},floydWarshall:m,labelPropagation:function(e,t,r,o){void 0===t&&(t=!1),void 0===r&&(r="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u={},c={};a.forEach((function(e,t){var r=f();e.clusterId=r,u[r]={id:r,nodes:[e]},c[e.id]={node:e,idx:t}}));var h=n(e,t),l=[],p={};h.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=c[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=u[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),f=u[o[s]];f.nodes.push(t),t.clusterId=f.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(u).forEach((function(e){var t=u[e];t.nodes&&t.nodes.length||delete u[e]}));var b=[],m={};s.forEach((function(e){var t=e.source,n=e.target,o=e[r]||1,i=c[t].node.clusterId,a=c[n].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,b.push(s)}}));var y=[];return Object.keys(u).forEach((function(e){y.push(u[e])})),{clusters:y,clusterEdges:b}},louvain:function(e,t,r,o){void 0===t&&(t=!1),void 0===r&&(r="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u={},c={};a.forEach((function(e,t){var r=f();e.clusterId=r,u[r]={id:r,nodes:[e]},c[e.id]={node:e,idx:t}}));var h=n(e,t),l=[],p={},v=0;h.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,m=0;g=y(a,h,l,v),!(Math.abs(g-b)<o||m>100);)b=g,m++,Object.keys(u).forEach((function(e){var t=0;s.forEach((function(n){var o=n.source,i=n.target,a=c[o].node.clusterId,d=c[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=n[r]||1)})),u[e].sumTot=t})),a.forEach((function(e,t){var n,o=u[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=c[e.id].idx;d+=h[t][r]||0}));var f=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(r){var o=c[r].node.clusterId;if(o!==e.clusterId){var d=u[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=c[e.id].idx;l+=h[t][r]||0}));var p=l-d.sumTot*a-f;p>i&&(i=p,n=d)}}})),i>0){n.nodes.push(e);var b=e.clusterId;e.clusterId=n.id;var m=o.nodes.indexOf(e);o.nodes.splice(m,1);var y=0,E=0;s.forEach((function(e){var t=e.source,o=e.target,i=c[t].node.clusterId,a=c[o].node.clusterId;(i===n.id&&a!==n.id||a===n.id&&i!==n.id)&&(y+=e[r]||1),(i===b&&a!==b||a===b&&i!==b)&&(E+=e[r]||1)})),n.sumTot=y,o.sumTot=E}}));Object.keys(u).forEach((function(e){var t=u[e];t.nodes&&t.nodes.length||delete u[e]}));var E=[],L={};s.forEach((function(e){var t=e.source,n=e.target,o=e[r]||1,i=c[t].node.clusterId,a=c[n].node.clusterId,d=i+"---"+a;if(L[d])L[d].weight+=o,L[d].count++;else{var s={source:i,target:a,weight:o,count:1};L[d]=s,E.push(s)}}));var N=[];return Object.keys(u).forEach((function(e){N.push(u[e])})),{clusters:N,clusterEdges:E}},minimumSpanningTree:function(e,t,r){return r?{prim:k,kruskal:j}[r](e,t):j(e,t)},pageRank:function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,d=e.nodes,u=void 0===d?[]:d,f=e.edges,c=void 0===f?[]:f,l=u.length,p={},v={},g=0;g<l;++g)p[m=(k=u[g]).id]=1/l,v[m]=1/l;for(var b=h(e);a>0&&o>t;){for(i=0,g=0;g<l;++g){var m=(k=u[g]).id;if(n=0,0===b[k.id].inDegree)p[m]=0;else{for(var y=s(m,c,"source"),E=0;E<y.length;++E){var L=y[E],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[m]=r*n,i+=p[m]}}for(i=(1-i)/l,o=0,g=0;g<l;++g){var k;n=p[m=(k=u[g]).id]+i,o+=Math.abs(n-v[m]),v[m]=n}a-=1}return v},getNeighbors:s,GADDI:function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=m(e,r),u=m(t,r),f=$(e.nodes,s,r),c=$(t.nodes,u,r),h=_(e.nodes,i),l=h.nodeMap,p=h.nodeLabelMap,b=_(t.nodes,i),y=b.nodeMap,E=b.nodeLabelMap;W(e.edges,a,l);var L=W(t.edges,a,y).edgeLabelMap;o||(o=Math.max.apply(Math,v(u[0],[2]))),n||(n=o);var N=G(e,s,i,n),k=G(t,u,i,n),j=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,c=e.neighborNum-1;s<i;){for(var h=f[1+Math.floor(Math.random()*c)],l=0;(a[n+"-"+h]||a[h+"-"+n])&&(h=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+h]={start:n,end:h,distance:o[n][h]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),k,s),M=B(j,N,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?R:o,a=e.edgeLabelProp,d=void 0===a?R:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new P(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,c=e.minNodeNum,h=e.verbose,l=e.top,p=new F({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:c,top:l,verbose:h,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:M,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(M).forEach((function(r){var n=M[r],o=z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),A=O.structure,S=O.structureCountMap,C=t.nodes[0],T=C[i],D=p[T],q={},H={},K={},J={},Q={};Object.keys(E).forEach((function(r,n){Q[r]=[];var o=-1/0,d=E[r],s={};d.forEach((function(e){var t=c[C.id+"-"+e.id];t&&Q[r].push(t),o<t&&(o=t),s[C.id+"-"+e.id]={start:0,end:y[e.id].idx,distance:t}})),Q[r]=Q[r].sort((function(e,t){return e-t})),H=B(s,k,t,H);var u=[];if(Object.keys(s).forEach((function(e){if(K[e])u.push(K[e]);else{var t=H[e];K[e]=z(t,A,i,a),u.push(K[e])}})),u=u.sort((function(e,t){return t-e})),J[C.id+"-"+r]=u,r!==T)for(var h=function(t){var n=D[t],o=N[l[n.id].idx],d=o.nodeLabelCountMap[r],s=E[r].length;if(!d||d.count<s)return D.splice(t,1),"continue";for(var c=!1,h=0;h<s;h++)if(d.dists[h]>Q[r][h]){c=!0;break}if(c)return D.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),M=B(p,N,e,M);var v=[];Object.keys(p).forEach((function(e){if(S[e])v.push(S[e]);else{var t=M[e];S[e]=z(t,A,i,a),v.push(S[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(h=0;h<s;h++)if(v[h]<u[h]){g=!0;break}return g?(D.splice(t,1),"continue"):void 0},p=D.length-1;p>=0;p--)h(p)}));var V=[];D.forEach((function(r){for(var n=l[r.id].idx,d=U(e.nodes,s[n],n,i,o).neighbors,u=d.length,c=!1,h=function(n){if(d.length+1<t.nodes.length)return c=!0,{value:void 0};var o=d[n],s=o[i];if(!E[s]||!E[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!Q[s]||!Q[s].length)return d.splice(n,1),"continue";var h=f[u];if(h>Q[s][Q[s].length-1])return d.splice(n,1),"continue";var p=S[u]?S[u]:function(e,t,r,n,o,i,a,d,s,u,f){var c,h=t.id+"-"+r.id;if(u&&u[h])return u[h];var l=f?f[h]:void 0;if(!l){var p=((c={})[h]={start:n[t.id].idx,end:n[r.id].idx,distance:o},c);l=(f=B(p,i,e,f))[h]}return z(l,a,d,s)}(e,r,o,l,h,N,A,i,a,S,M),v=C.id+"-"+s;if(p<J[v][J[v].length-1])return d.splice(n,1),"continue";var g=q[s];return void 0===g&&(g=1/0,E[s].forEach((function(e){var t=y[e.id].degree;g>t&&(g=t)})),q[s]=g),l[o.id].degree<g?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=h(p);if("object"==typeof v)return v.value}c||V.push({nodes:[r].concat(d)})}));var X=g(t,C.id,!1).length,Y={};r?(Object.keys(X).forEach((function(e){var t=y[e].node[i];Y[t]?Y[t].push(X[e]):Y[t]=[X[e]]})),Object.keys(Y).forEach((function(e){Y[e].sort((function(e,t){return e-t}))}))):Y=Q;for(var Z=function(n){var o=V[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],c={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),c[e[a]]?c[e[a]]++:c[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var h=Object.keys(L).length,p=!1,v=0;v<h;v++){var b=Object.keys(L)[v];if(!c[b]||c[b]<L[b].length){p=!0;break}}if(p)return V.splice(n,1),"continue";var m=f.length;if(m<t.edges.length)return V.splice(n,1),"break";var N=!1,k=function(e){var t=f[e],n=t[a],o=L[n];if(!o||!o.length)return c[n]--,o&&c[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],h=!1;return o.forEach((function(e){var t=y[e.source].node,n=y[e.target].node;t[i]===d&&n[i]===s&&(h=!0),r||t[i]!==s||n[i]!==d||(h=!0)})),h?void 0:(c[n]--,o&&c[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=m-1;v>=0&&"break"!==k(v);v--);if(N)return V.splice(n,1),"continue";o.edges=f;var j=g(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];return s[t]--,s[t]<E[t].length?void(N=!0):(o.nodes.splice(u[e].idx,1),void(u[e]=void 0))}var r=l[e].node[i];if(!Y[r]||!Y[r].length||j[e]>Y[r][Y[r].length-1]){if(t=u[e].node[i],s[t]--,s[t]<E[t].length)return void(N=!0);o.nodes.splice(u[e].idx,1),u[e]=void 0}}})),N)return V.splice(n,1),"continue";for(var M=!0,w=0;M&&!N;){if(M=!1,u[d.id].degree<y[C.id].degree){N=!0;break}if(s[d[i]]<E[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,A=I[i];if(O<q[A]){if(s[I[i]]--,s[I[i]]<E[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,M=!0}}if(N||!M&&0!==w)break;for(var S=(m=f.length)-1;S>=0;S--){var P=f[S];if(!u[P.source]||!u[P.target]){f.splice(S,1);var T=P[a];if(c[T]--,u[P.source]&&u[P.source].degree--,u[P.target]&&u[P.target].degree--,L[T]&&c[T]<L[T].length){N=!0;break}M=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(V.splice(n,1),"continue"):void 0},ee=V.length-1;ee>=0&&"break"!==Z(ee);ee--);var te=V.length,re=function(e){var t=V[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=V[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&V.splice(e,1)},o=te-1;o>e;o--)n(o);te=V.length};for(ee=0;ee<=te-1;ee++)re(ee);return V}}},getAdjMatrixAsync:function(e,t){return K("getAdjMatrix").apply(void 0,[e,t])},connectedComponentAsync:function(e,t){return K("connectedComponent").apply(void 0,[e,t])},getDegreeAsync:function(e){return K("getDegree")(e)},getInDegreeAsync:function(e,t){return K("getInDegree")(e,t)},getOutDegreeAsync:function(e,t){return K("getOutDegree")(e,t)},detectCycleAsync:function(e){return K("detectCycle")(e)},dijkstraAsync:function(e,t,r,n){return K("dijkstra").apply(void 0,[e,t,r,n])},findAllPathAsync:function(e,t,r,n){return K("findAllPath").apply(void 0,[e,t,r,n])},findShortestPathAsync:function(e,t,r,n,o){return K("findShortestPath").apply(void 0,[e,t,r,n,o])},floydWarshallAsync:function(e,t){return K("floydWarshall").apply(void 0,[e,t])},labelPropagationAsync:function(e,t,r,n){return K("labelPropagation")(e,t,r,n)},louvainAsync:function(e,t,r,n){return K("louvain")(e,t,r,n)},minimumSpanningTreeAsync:function(e,t,r){return K("minimumSpanningTree").apply(void 0,[e,t,r])},pageRankAsync:function(e,t,r){return K("pageRank").apply(void 0,[e,t,r])},getNeighborsAsync:function(e,t,r){return K("getNeighbors").apply(void 0,[e,t,r])},GADDIAsync:function(e,t,r,n,o,i,a){return void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),K("GADDI").apply(void 0,[e,t,r,n,o,i,a])}}}},n={};function o(e){if(n[e])return n[e].exports;var t=n[e]={exports:{}};return r[e](t,t.exports,o),t.exports}return o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,r)=>(o.f[r](e,t),t)),[])),o.u=e=>e+".min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="Algorithm:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var d,s;if(void 0!==i)for(var u=document.getElementsByTagName("script"),f=0;f<u.length;f++){var c=u[f];if(c.getAttribute("src")==r||c.getAttribute("data-webpack")==t+i){d=c;break}}d||(s=!0,(d=document.createElement("script")).charset="utf-8",d.timeout=120,o.nc&&d.setAttribute("nonce",o.nc),d.setAttribute("data-webpack",t+i),d.src=r),e[r]=[n];var h=(t,n)=>{d.onerror=d.onload=null,clearTimeout(l);var o=e[r];if(delete e[r],d.parentNode&&d.parentNode.removeChild(d),o&&o.forEach((e=>e(n))),t)return t(n)},l=setTimeout(h.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=h.bind(null,d.onerror),d.onload=h.bind(null,d.onload),s&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={826:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,o)=>{n=e[t]=[r,o]}));r.push(n[2]=i);var a=o.p+o.u(t),d=new Error;o.l(a,(r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;d.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",d.name="ChunkLoadError",d.type=i,d.request=a,n[1](d)}}),"chunk-"+t,t)}};var t=(t,r)=>{for(var n,i,[a,d,s]=r,u=0,f=[];u<a.length;u++)i=a[u],o.o(e,i)&&e[i]&&f.push(e[i][0]),e[i]=0;for(n in d)o.o(d,n)&&(o.m[n]=d[n]);for(s&&s(o),t&&t(r);f.length;)f.shift()()},r=this.webpackChunkAlgorithm=this.webpackChunkAlgorithm||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),o(537)})().default})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Algorithm=t():e.Algorithm=t()}(this,(function(){return(()=>{"use strict";var e,t,r={537:(e,t,r)=>{r.d(t,{default:()=>J});const n=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var o=function(e,t){return e===t},i=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const a=function(){function e(e){void 0===e&&(e=o),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new i(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new i(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),d=function(){function e(){this.linkedList=new a}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var s=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},u=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},f=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const h=c;function l(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;s(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&l(e,o,t,n)})),n.leave({current:t,previous:r})}function p(e,t,r){l(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}function v(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const g=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,s=[],f={},c={},h={};i.forEach((function(e,r){var n=e.id;s.push(n),c[n]=1/0,n===t&&(c[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(c,i,f),o=t.id;if(f[o]=!0,c[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):u(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;c[a]>c[t.id]+d?(c[a]=c[t.id]+d,h[a]=[t.id]):c[a]===c[t.id]+d&&h[a].push(t.id)}))},v=0;v<l;v++)p();h[t]=[t];var g={};for(var m in c)c[m]!==1/0&&b(t,m,h,g);var y={};for(var m in g)y[m]=g[m][0];return{length:c,path:y,allPaths:g}};function b(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=b(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(v(f,[t]))}}n[t]=o}const m=function(e,t){for(var r=n(e,t),o=[],i=r.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==r[a][d]&&r[a][d]?o[a][d]=r[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o};var y=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const E=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var L=function(e,t){return e-t};const N=function(){function e(e){void 0===e&&(e=L),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var k=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],s=new Set;s.add(d);var f=new N((function(e,r){return t?e.weight-r.weight:0}));for(u(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var c=f.delMin(),h=c.source,l=c.target;s.has(h)&&s.has(l)||(r.push(c),s.has(h)||(s.add(h),u(h,a).forEach((function(e){f.insert(e)}))),s.has(l)||(s.add(l),u(l,a).forEach((function(e){f.insert(e)}))))}return r},j=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new E(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,c=u.target;s.connected(f,c)||(r.push(u),s.union(f,c))}return r};var M={}.toString;const w=function(e,t){return M.call(e)==="[object "+t+"]"},x=function(e){return Array.isArray?Array.isArray(e):w(e,"Array")};Object.keys;var I=Array.prototype;I.splice,I.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const O=function e(t){if("object"!=typeof t||null===t)return t;var r;if(x(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var A="-1",S=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},C=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=A),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),P=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new C(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new S(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new S(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),T=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||A,edgeLabel:n||"-1",nodeLabel2:o||A}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),D=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new T(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new P(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==A&&r.addNode(t,i),d!==A&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),q=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),F=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,c=void 0!==f&&f,h=e.verbose,l=void 0!==h&&h;this.graphs=t,this.dfsCode=new D,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=c,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],c=i[f.to].label;t.to===f.to||r>c||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=c)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new D,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new T(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,c={},h=!1,l=0,p=r?-1:0,v=function(t){if(h)return"break";a.forEach((function(r){var o=new q(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(c[a.label]||(c[a.label]={projected:[],edgeLabel:a.label}),c[a.label].projected.push({graphId:n.id,edge:c,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,h=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(h){var b=e.findMinLabel(c);i.dfsEdgeList.push(new T(f,l,A,b.edgeLabel,A));var m=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[m]===i.dfsEdgeList[m]&&s(c[b.edgeLabel].projected)}var y={};h=!1;var E=0;a.forEach((function(t){var r=new q(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(h=!0,E=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(h)return"break";var r=d[t];a.forEach((function(t){var a=new q(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(h=!0,E=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!h)return!0;var k=e.findMinLabel(y);i.dfsEdgeList.push(new T(E,f+1,A,k.edgeLabel,k.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[k.edgeLabel+"-"+k.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(O(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new q(e),c=n.length-1;c>=0;c--){var h=t.findBackwardEdge(s,f.edges[n[c]],f.edges[n[0]],f);if(h){var l=t.dfsCode.dfsEdgeList[n[c]].fromNode+"-"+h.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[c]].fromNode,edgeLabel:h.label}),d[l].projected.push({graphId:e.graphId,edge:h,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(c=0;c<n.length;c++)p(c)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new T(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new T(n,o+1,A,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var c=o[u]||0;c++,o[u]=c}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,c=r+"-"+n+"-"+f+"-"+o,h=n+"-"+f+"-"+o;if(!i[h]){var l=i[h]||0;l++,i[h]=l}d[c]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new T(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),R="cluster";var G=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(U(i,e,t,r,n))})),o},U=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},B=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var c=new Set(f),h=u.filter((function(e){return c.has(e)}));if(h&&h.length){for(var l={},p=h.length,v=0;v<p;v++){var g=o[h[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},_=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},W=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+f]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},$=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};var H="SUCCESS";const K=function(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new Promise((function(n,o){r.e(1).then(r.bind(r,1)).then((function(r){var i=new r.default;i.postMessage({type:e,data:t}),i.onmessage=function(e){var t=e.data,r=t.data,a=t.type;H===a?n(r):o(),i.terminate()}}))}))}},J={getAdjMatrix:n,breadthFirstSearch:function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new d,i=e.edges,a=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),s(e,a,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()},connectedComponent:function(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},d={},u={},f=[],c=0,h=function(e){d[e.id]=c,u[e.id]=c,c+=1,i.push(e),a[e.id]=!0;for(var t=s(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(d[o]||0===d[o])a[o]&&(u[e.id]=Math.min(u[e.id],d[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&h(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===d[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];d[v.id]||0===d[v.id]||h(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},d=[],u=function(e){d.push(e),a[e.id]=!0;for(var t=s(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var c=r[f];if(!a[c.id]){u(c);for(var h=[];d.length>0;)h.push(d.pop());i.push(h)}}return i}(e)},getDegree:h,getInDegree:function(e,t){return c(e)[t]?c(e)[t].inDegree:0},getOutDegree:function(e,t){return c(e)[t]?c(e)[t].outDegree:0},detectCycle:function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)p(e,Object.keys(o)[0],d);return t},depthFirstSearch:p,dijkstra:g,findAllPath:function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,d=[t],u=((o={})[t]=!0,o),f=[],c=[],h=n?s(t,a,"target"):s(t,a);for(f.push(h);d.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(d.push(p),u[p]=!0,h=n?s(p,a,"target"):s(p,a),f.push(h.filter((function(e){return!u[e]})))),d[d.length-1]===r){var v=d.map((function(e){return e}));c.push(v),g=d.pop(),u[g]=!1,f.pop()}}else{var g=d.pop();u[g]=!1,f.pop()}}return c},findShortestPath:function(e,t,r,n,o){var i=g(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},floydWarshall:m,labelPropagation:function(e,t,r,o){void 0===t&&(t=!1),void 0===r&&(r="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u={},c={};a.forEach((function(e,t){var r=f();e.clusterId=r,u[r]={id:r,nodes:[e]},c[e.id]={node:e,idx:t}}));var h=n(e,t),l=[],p={};h.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=c[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=u[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),f=u[o[s]];f.nodes.push(t),t.clusterId=f.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(u).forEach((function(e){var t=u[e];t.nodes&&t.nodes.length||delete u[e]}));var b=[],m={};s.forEach((function(e){var t=e.source,n=e.target,o=e[r]||1,i=c[t].node.clusterId,a=c[n].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,b.push(s)}}));var y=[];return Object.keys(u).forEach((function(e){y.push(u[e])})),{clusters:y,clusterEdges:b}},louvain:function(e,t,r,o){void 0===t&&(t=!1),void 0===r&&(r="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u={},c={};a.forEach((function(e,t){var r=f();e.clusterId=r,u[r]={id:r,nodes:[e]},c[e.id]={node:e,idx:t}}));var h=n(e,t),l=[],p={},v=0;h.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,m=0;g=y(a,h,l,v),!(Math.abs(g-b)<o||m>100);)b=g,m++,Object.keys(u).forEach((function(e){var t=0;s.forEach((function(n){var o=n.source,i=n.target,a=c[o].node.clusterId,d=c[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=n[r]||1)})),u[e].sumTot=t})),a.forEach((function(e,t){var n,o=u[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=c[e.id].idx;d+=h[t][r]||0}));var f=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(r){var o=c[r].node.clusterId;if(o!==e.clusterId){var d=u[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=c[e.id].idx;l+=h[t][r]||0}));var p=l-d.sumTot*a-f;p>i&&(i=p,n=d)}}})),i>0){n.nodes.push(e);var b=e.clusterId;e.clusterId=n.id;var m=o.nodes.indexOf(e);o.nodes.splice(m,1);var y=0,E=0;s.forEach((function(e){var t=e.source,o=e.target,i=c[t].node.clusterId,a=c[o].node.clusterId;(i===n.id&&a!==n.id||a===n.id&&i!==n.id)&&(y+=e[r]||1),(i===b&&a!==b||a===b&&i!==b)&&(E+=e[r]||1)})),n.sumTot=y,o.sumTot=E}}));Object.keys(u).forEach((function(e){var t=u[e];t.nodes&&t.nodes.length||delete u[e]}));var E=[],L={};s.forEach((function(e){var t=e.source,n=e.target,o=e[r]||1,i=c[t].node.clusterId,a=c[n].node.clusterId,d=i+"---"+a;if(L[d])L[d].weight+=o,L[d].count++;else{var s={source:i,target:a,weight:o,count:1};L[d]=s,E.push(s)}}));var N=[];return Object.keys(u).forEach((function(e){N.push(u[e])})),{clusters:N,clusterEdges:E}},minimumSpanningTree:function(e,t,r){return r?{prim:k,kruskal:j}[r](e,t):j(e,t)},pageRank:function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,d=e.nodes,u=void 0===d?[]:d,f=e.edges,c=void 0===f?[]:f,l=u.length,p={},v={},g=0;g<l;++g)p[m=(k=u[g]).id]=1/l,v[m]=1/l;for(var b=h(e);a>0&&o>t;){for(i=0,g=0;g<l;++g){var m=(k=u[g]).id;if(n=0,0===b[k.id].inDegree)p[m]=0;else{for(var y=s(m,c,"source"),E=0;E<y.length;++E){var L=y[E],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[m]=r*n,i+=p[m]}}for(i=(1-i)/l,o=0,g=0;g<l;++g){var k;n=p[m=(k=u[g]).id]+i,o+=Math.abs(n-v[m]),v[m]=n}a-=1}return v},getNeighbors:s,GADDI:function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=m(e,r),u=m(t,r),f=$(e.nodes,s,r),c=$(t.nodes,u,r),h=_(e.nodes,i),l=h.nodeMap,p=h.nodeLabelMap,b=_(t.nodes,i),y=b.nodeMap,E=b.nodeLabelMap;W(e.edges,a,l);var L=W(t.edges,a,y).edgeLabelMap;o||(o=Math.max.apply(Math,v(u[0],[2]))),n||(n=o);var N=G(e,s,i,n),k=G(t,u,i,n),j=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,c=e.neighborNum-1;s<i;){for(var h=f[1+Math.floor(Math.random()*c)],l=0;(a[n+"-"+h]||a[h+"-"+n])&&(h=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+h]={start:n,end:h,distance:o[n][h]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),k,s),M=B(j,N,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?R:o,a=e.edgeLabelProp,d=void 0===a?R:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new P(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,c=e.minNodeNum,h=e.verbose,l=e.top,p=new F({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:c,top:l,verbose:h,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:M,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(M).forEach((function(r){var n=M[r],o=z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),A=O.structure,S=O.structureCountMap,C=t.nodes[0],T=C[i],D=p[T],q={},H={},K={},J={},Q={};Object.keys(E).forEach((function(r,n){Q[r]=[];var o=-1/0,d=E[r],s={};d.forEach((function(e){var t=c[C.id+"-"+e.id];t&&Q[r].push(t),o<t&&(o=t),s[C.id+"-"+e.id]={start:0,end:y[e.id].idx,distance:t}})),Q[r]=Q[r].sort((function(e,t){return e-t})),H=B(s,k,t,H);var u=[];if(Object.keys(s).forEach((function(e){if(K[e])u.push(K[e]);else{var t=H[e];K[e]=z(t,A,i,a),u.push(K[e])}})),u=u.sort((function(e,t){return t-e})),J[C.id+"-"+r]=u,r!==T)for(var h=function(t){var n=D[t],o=N[l[n.id].idx],d=o.nodeLabelCountMap[r],s=E[r].length;if(!d||d.count<s)return D.splice(t,1),"continue";for(var c=!1,h=0;h<s;h++)if(d.dists[h]>Q[r][h]){c=!0;break}if(c)return D.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),M=B(p,N,e,M);var v=[];Object.keys(p).forEach((function(e){if(S[e])v.push(S[e]);else{var t=M[e];S[e]=z(t,A,i,a),v.push(S[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(h=0;h<s;h++)if(v[h]<u[h]){g=!0;break}return g?(D.splice(t,1),"continue"):void 0},p=D.length-1;p>=0;p--)h(p)}));var V=[];D.forEach((function(r){for(var n=l[r.id].idx,d=U(e.nodes,s[n],n,i,o).neighbors,u=d.length,c=!1,h=function(n){if(d.length+1<t.nodes.length)return c=!0,{value:void 0};var o=d[n],s=o[i];if(!E[s]||!E[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!Q[s]||!Q[s].length)return d.splice(n,1),"continue";var h=f[u];if(h>Q[s][Q[s].length-1])return d.splice(n,1),"continue";var p=S[u]?S[u]:function(e,t,r,n,o,i,a,d,s,u,f){var c,h=t.id+"-"+r.id;if(u&&u[h])return u[h];var l=f?f[h]:void 0;if(!l){var p=((c={})[h]={start:n[t.id].idx,end:n[r.id].idx,distance:o},c);l=(f=B(p,i,e,f))[h]}return z(l,a,d,s)}(e,r,o,l,h,N,A,i,a,S,M),v=C.id+"-"+s;if(p<J[v][J[v].length-1])return d.splice(n,1),"continue";var g=q[s];return void 0===g&&(g=1/0,E[s].forEach((function(e){var t=y[e.id].degree;g>t&&(g=t)})),q[s]=g),l[o.id].degree<g?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=h(p);if("object"==typeof v)return v.value}c||V.push({nodes:[r].concat(d)})}));var X=g(t,C.id,!1).length,Y={};r?(Object.keys(X).forEach((function(e){var t=y[e].node[i];Y[t]?Y[t].push(X[e]):Y[t]=[X[e]]})),Object.keys(Y).forEach((function(e){Y[e].sort((function(e,t){return e-t}))}))):Y=Q;for(var Z=function(n){var o=V[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],c={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),c[e[a]]?c[e[a]]++:c[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var h=Object.keys(L).length,p=!1,v=0;v<h;v++){var b=Object.keys(L)[v];if(!c[b]||c[b]<L[b].length){p=!0;break}}if(p)return V.splice(n,1),"continue";var m=f.length;if(m<t.edges.length)return V.splice(n,1),"break";var N=!1,k=function(e){var t=f[e],n=t[a],o=L[n];if(!o||!o.length)return c[n]--,o&&c[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],h=!1;return o.forEach((function(e){var t=y[e.source].node,n=y[e.target].node;t[i]===d&&n[i]===s&&(h=!0),r||t[i]!==s||n[i]!==d||(h=!0)})),h?void 0:(c[n]--,o&&c[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=m-1;v>=0&&"break"!==k(v);v--);if(N)return V.splice(n,1),"continue";o.edges=f;var j=g(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<E[t].length)return void(N=!0);var r=o.nodes.indexOf(u[e].node);return o.nodes.splice(r,1),void(u[e]=void 0)}var n=l[e].node[i];if(!Y[n]||!Y[n].length||j[e]>Y[n][Y[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<E[t].length)return void(N=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),N)return V.splice(n,1),"continue";for(var M=!0,w=0;M&&!N;){if(M=!1,u[d.id].degree<y[C.id].degree){N=!0;break}if(s[d[i]]<E[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,A=I[i];if(O<q[A]){if(s[I[i]]--,s[I[i]]<E[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,M=!0}}if(N||!M&&0!==w)break;for(var S=(m=f.length)-1;S>=0;S--){var P=f[S];if(!u[P.source]||!u[P.target]){f.splice(S,1);var T=P[a];if(c[T]--,u[P.source]&&u[P.source].degree--,u[P.target]&&u[P.target].degree--,L[T]&&c[T]<L[T].length){N=!0;break}M=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(V.splice(n,1),"continue"):void 0},ee=V.length-1;ee>=0&&"break"!==Z(ee);ee--);var te=V.length,re=function(e){var t=V[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=V[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&V.splice(e,1)},o=te-1;o>e;o--)n(o);te=V.length};for(ee=0;ee<=te-1;ee++)re(ee);return V}}},getAdjMatrixAsync:function(e,t){return K("getAdjMatrix").apply(void 0,[e,t])},connectedComponentAsync:function(e,t){return K("connectedComponent").apply(void 0,[e,t])},getDegreeAsync:function(e){return K("getDegree")(e)},getInDegreeAsync:function(e,t){return K("getInDegree")(e,t)},getOutDegreeAsync:function(e,t){return K("getOutDegree")(e,t)},detectCycleAsync:function(e){return K("detectCycle")(e)},dijkstraAsync:function(e,t,r,n){return K("dijkstra").apply(void 0,[e,t,r,n])},findAllPathAsync:function(e,t,r,n){return K("findAllPath").apply(void 0,[e,t,r,n])},findShortestPathAsync:function(e,t,r,n,o){return K("findShortestPath").apply(void 0,[e,t,r,n,o])},floydWarshallAsync:function(e,t){return K("floydWarshall").apply(void 0,[e,t])},labelPropagationAsync:function(e,t,r,n){return K("labelPropagation")(e,t,r,n)},louvainAsync:function(e,t,r,n){return K("louvain")(e,t,r,n)},minimumSpanningTreeAsync:function(e,t,r){return K("minimumSpanningTree").apply(void 0,[e,t,r])},pageRankAsync:function(e,t,r){return K("pageRank").apply(void 0,[e,t,r])},getNeighborsAsync:function(e,t,r){return K("getNeighbors").apply(void 0,[e,t,r])},GADDIAsync:function(e,t,r,n,o,i,a){return void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),K("GADDI").apply(void 0,[e,t,r,n,o,i,a])}}}},n={};function o(e){if(n[e])return n[e].exports;var t=n[e]={exports:{}};return r[e](t,t.exports,o),t.exports}return o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,r)=>(o.f[r](e,t),t)),[])),o.u=e=>e+".min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="Algorithm:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var d,s;if(void 0!==i)for(var u=document.getElementsByTagName("script"),f=0;f<u.length;f++){var c=u[f];if(c.getAttribute("src")==r||c.getAttribute("data-webpack")==t+i){d=c;break}}d||(s=!0,(d=document.createElement("script")).charset="utf-8",d.timeout=120,o.nc&&d.setAttribute("nonce",o.nc),d.setAttribute("data-webpack",t+i),d.src=r),e[r]=[n];var h=(t,n)=>{d.onerror=d.onload=null,clearTimeout(l);var o=e[r];if(delete e[r],d.parentNode&&d.parentNode.removeChild(d),o&&o.forEach((e=>e(n))),t)return t(n)},l=setTimeout(h.bind(null,void 0,{type:"timeout",target:d}),12e4);d.onerror=h.bind(null,d.onerror),d.onload=h.bind(null,d.onload),s&&document.head.appendChild(d)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");r.length&&(e=r[r.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={826:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,o)=>{n=e[t]=[r,o]}));r.push(n[2]=i);var a=o.p+o.u(t),d=new Error;o.l(a,(r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;d.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",d.name="ChunkLoadError",d.type=i,d.request=a,n[1](d)}}),"chunk-"+t,t)}};var t=(t,r)=>{for(var n,i,[a,d,s]=r,u=0,f=[];u<a.length;u++)i=a[u],o.o(e,i)&&e[i]&&f.push(e[i][0]),e[i]=0;for(n in d)o.o(d,n)&&(o.m[n]=d[n]);for(s&&s(o),t&&t(r);f.length;)f.shift()()},r=this.webpackChunkAlgorithm=this.webpackChunkAlgorithm||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),o(537)})().default})); | ||
//# sourceMappingURL=index.min.js.map |
@@ -1,2 +0,2 @@ | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>re,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>m,findAllPath:()=>M,findShortestPath:()=>N,floydWarshall:()=>j,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>v,labelPropagation:()=>k,louvain:()=>x,minimumSpanningTree:()=>T,pageRank:()=>q});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new a,i=e.edges,s=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),d(e,s,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||c(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},v=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function g(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;d(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&g(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){g(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const m=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},v=0;v<l;v++)p();c[t]=[t];var g={};for(var b in h)h[b]!==1/0&&L(t,b,c,g);var E={};for(var b in g)E[b]=g[b][0];return{length:h,path:E,allPaths:g}};function L(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=L(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(y(f,[t]))}}n[t]=o}var N=function(e,t,r,n,o){var i=m(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},M=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));h.push(v),g=s.pop(),u[g]=!1,f.pop()}}else{var g=s.pop();u[g]=!1,f.pop()}}return h};const j=function(e,t){for(var n=r(e,t),o=[],i=n.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==n[a][d]&&n[a][d]?o[a][d]=n[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o},k=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var y=[];return Object.keys(f).forEach((function(e){y.push(f[e])})),{clusters:y,clusterEdges:b}};var w=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const x=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},v=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,E=0;g=w(a,c,l,v),!(Math.abs(g-b)<o||E>100);)b=g,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var y=0,m=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(y+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(m+=e[n]||1)})),r.sumTot=y,o.sumTot=m}}));Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var y=[],m={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,y.push(s)}}));var L=[];return Object.keys(f).forEach((function(e){L.push(f[e])})),{clusters:L,clusterEdges:y}},I=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var O=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=O),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new I(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const T=function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(e,t)},q=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},v={},g=0;g<c;++g)p[E=(M=u[g]).id]=1/c,v[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<c;++g){var E=(M=u[g]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var y=d(E,h,"source"),m=0;m<y.length;++m){var L=y[m],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,g=0;g<c;++g){var M;n=p[E=(M=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v};var F={}.toString;const A=function(e,t){return F.call(e)==="[object "+t+"]"},D=function(e){return Array.isArray?Array.isArray(e):A(e,"Array")};Object.keys;var R=Array.prototype;R.splice,R.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const U=function e(t){if("object"!=typeof t||null===t)return t;var r;if(D(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var G="-1",z=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},B=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),H=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new B(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new z(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new z(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),_=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new _(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new H(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new _(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,v=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new _(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var y={};c=!1;var m=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,m=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,m=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!c)return!0;var M=e.findMinLabel(y);i.dfsEdgeList.push(new _(m,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(U(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new _(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new _(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new _(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,v=0;v<p;v++){var g=o[c[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};const re=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=j(e,r),u=j(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,v=$(t.nodes,i),g=v.nodeMap,b=v.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,g).edgeLabelMap;o||(o=Math.max.apply(Math,y(u[0],[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),k=Y(M,L,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?Q:o,a=e.edgeLabelProp,d=void 0===a?Q:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new H(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:k,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(k).forEach((function(r){var n=k[r],o=Z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),S=O.structure,C=O.structureCountMap,P=t.nodes[0],T=P[i],q=p[T],F={},A={},D={},R={},U={};Object.keys(b).forEach((function(r,n){U[r]=[];var o=-1/0,d=b[r],s={};d.forEach((function(e){var t=h[P.id+"-"+e.id];t&&U[r].push(t),o<t&&(o=t),s[P.id+"-"+e.id]={start:0,end:g[e.id].idx,distance:t}})),U[r]=U[r].sort((function(e,t){return e-t})),A=Y(s,N,t,A);var u=[];if(Object.keys(s).forEach((function(e){if(D[e])u.push(D[e]);else{var t=A[e];D[e]=Z(t,S,i,a),u.push(D[e])}})),u=u.sort((function(e,t){return t-e})),R[P.id+"-"+r]=u,r!==T)for(var c=function(t){var n=q[t],o=L[l[n.id].idx],d=o.nodeLabelCountMap[r],s=b[r].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var h=!1,c=0;c<s;c++)if(d.dists[c]>U[r][c]){h=!0;break}if(h)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),k=Y(p,L,e,k);var v=[];Object.keys(p).forEach((function(e){if(C[e])v.push(C[e]);else{var t=k[e];C[e]=Z(t,S,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(c=0;c<s;c++)if(v[c]<u[c]){g=!0;break}return g?(q.splice(t,1),"continue"):void 0},p=q.length-1;p>=0;p--)c(p)}));var G=[];q.forEach((function(r){for(var n=l[r.id].idx,d=X(e.nodes,s[n],n,i,o).neighbors,u=d.length,h=!1,c=function(n){if(d.length+1<t.nodes.length)return h=!0,{value:void 0};var o=d[n],s=o[i];if(!b[s]||!b[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!U[s]||!U[s].length)return d.splice(n,1),"continue";var c=f[u];if(c>U[s][U[s].length-1])return d.splice(n,1),"continue";var p=C[u]?C[u]:function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)}(e,r,o,l,c,L,S,i,a,C,k),v=P.id+"-"+s;if(p<R[v][R[v].length-1])return d.splice(n,1),"continue";var E=F[s];return void 0===E&&(E=1/0,b[s].forEach((function(e){var t=g[e.id].degree;E>t&&(E=t)})),F[s]=E),l[o.id].degree<E?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=c(p);if("object"==typeof v)return v.value}h||G.push({nodes:[r].concat(d)})}));var z=m(t,P.id,!1).length,B={};r?(Object.keys(z).forEach((function(e){var t=g[e].node[i];B[t]?B[t].push(z[e]):B[t]=[z[e]]})),Object.keys(B).forEach((function(e){B[e].sort((function(e,t){return e-t}))}))):B=U;for(var _=function(n){var o=G[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var c=Object.keys(E).length,p=!1,v=0;v<c;v++){var y=Object.keys(E)[v];if(!h[y]||h[y]<E[y].length){p=!0;break}}if(p)return G.splice(n,1),"continue";var L=f.length;if(L<t.edges.length)return G.splice(n,1),"break";var N=!1,M=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],c=!1;return o.forEach((function(e){var t=g[e.source].node,n=g[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=L-1;v>=0&&"break"!==M(v);v--);if(N)return G.splice(n,1),"continue";o.edges=f;var j=m(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];return s[t]--,s[t]<b[t].length?void(N=!0):(o.nodes.splice(u[e].idx,1),void(u[e]=void 0))}var r=l[e].node[i];if(!B[r]||!B[r].length||j[e]>B[r][B[r].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(N=!0);o.nodes.splice(u[e].idx,1),u[e]=void 0}}})),N)return G.splice(n,1),"continue";for(var k=!0,w=0;k&&!N;){if(k=!1,u[d.id].degree<g[P.id].degree){N=!0;break}if(s[d[i]]<b[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,S=I[i];if(O<F[S]){if(s[I[i]]--,s[I[i]]<b[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,k=!0}}if(N||!k&&0!==w)break;for(var C=(L=f.length)-1;C>=0;C--){var T=f[C];if(!u[T.source]||!u[T.target]){f.splice(C,1);var q=T[a];if(h[q]--,u[T.source]&&u[T.source].degree--,u[T.target]&&u[T.target].degree--,E[q]&&h[q]<E[q].length){N=!0;break}k=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(G.splice(n,1),"continue"):void 0},K=G.length-1;K>=0&&"break"!==_(K);K--);var W=G.length,re=function(e){var t=G[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=G[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&G.splice(e,1)},o=W-1;o>e;o--)n(o);W=G.length};for(K=0;K<=W-1;K++)re(K);return G}}};var ne=self;ne.onmessage=function(e){var r=e.data,n=r.type,o=r.data;if("function"!=typeof t[n])ne.postMessage({type:"FAILURE"});else{var i=t[n].apply(t,o);ne.postMessage({type:"SUCCESS",data:i})}}})(); | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>re,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>m,findAllPath:()=>M,findShortestPath:()=>N,floydWarshall:()=>j,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>v,labelPropagation:()=>k,louvain:()=>x,minimumSpanningTree:()=>T,pageRank:()=>q});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r){var n=function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r),o=new a,i=e.edges,s=void 0===i?[]:i;o.enqueue(t);for(var u="",f=function(){var e=o.dequeue();n.enter({current:e,previous:u}),d(e,s,"target").forEach((function(t){n.allowTraversal({previous:u,current:e,next:t})&&o.enqueue(t)})),n.leave({current:e,previous:u}),u=e};!o.isEmpty();)f()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var v=i.pop();if(a[v.id]=!1,p.push(v),v===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||c(v)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},v=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function g(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;d(t,void 0===o?[]:o,"target").forEach((function(o){n.allowTraversal({previous:r,current:t,next:o})&&g(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){g(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function y(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,d=i.length;a<d;a++,o++)n[o]=i[a];return n}Object.create,Object.create;const m=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},v=0;v<l;v++)p();c[t]=[t];var g={};for(var b in h)h[b]!==1/0&&L(t,b,c,g);var E={};for(var b in g)E[b]=g[b][0];return{length:h,path:E,allPaths:g}};function L(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,a=r[t];i<a.length;i++){var d=L(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];o.push(y(f,[t]))}}n[t]=o}var N=function(e,t,r,n,o){var i=m(e,t,n,o),a=i.length,d=i.path,s=i.allPaths;return{length:a[r],path:d[r],allPath:s[r]}},M=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));h.push(v),g=s.pop(),u[g]=!1,f.pop()}}else{var g=s.pop();u[g]=!1,f.pop()}}return h};const j=function(e,t){for(var n=r(e,t),o=[],i=n.length,a=0;a<i;a+=1){o[a]=[];for(var d=0;d<i;d+=1)a===d?o[a][d]=0:0!==n[a][d]&&n[a][d]?o[a][d]=n[a][d]:o[a][d]=1/0}for(var s=0;s<i;s+=1)for(a=0;a<i;a+=1)for(d=0;d<i;d+=1)o[a][d]>o[a][s]+o[s][d]&&(o[a][d]=o[a][s]+o[s][d]);return o},k=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var v=0,g=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var y=[];return Object.keys(f).forEach((function(e){y.push(f[e])})),{clusters:y,clusterEdges:b}};var w=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const x=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},v=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,v+=e}})),l.push(r)})),v/=2;for(var g=1/0,b=1/0,E=0;g=w(a,c,l,v),!(Math.abs(g-b)<o||E>100);)b=g,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*v),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,g=p[e.id];if(Object.keys(g).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var y=0,m=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(y+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(m+=e[n]||1)})),r.sumTot=y,o.sumTot=m}}));Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var y=[],m={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(m[d])m[d].weight+=o,m[d].count++;else{var s={source:i,target:a,weight:o,count:1};m[d]=s,y.push(s)}}));var L=[];return Object.keys(f).forEach((function(e){L.push(f[e])})),{clusters:L,clusterEdges:y}},I=function(){function e(e){this.count=e.length,this.parent={};for(var t=0,r=e;t<r.length;t++){var n=r[t];this.parent[n]=n}}return e.prototype.find=function(e){for(;this.parent[e]!==e;)e=this.parent[e];return e},e.prototype.union=function(e,t){var r=this.find(e),n=this.find(t);r!==n&&(r<n?(this.parent[t]!==t&&this.union(this.parent[t],e),this.parent[t]=this.parent[e]):(this.parent[e]!==e&&this.union(this.parent[e],t),this.parent[e]=this.parent[t]))},e.prototype.connected=function(e,t){return this.find(e)===this.find(t)},e}();var O=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=O),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=a.map((function(e){return e}));t&&d.sort((function(e,t){return e.weight-t.weight}));for(var s=new I(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const T=function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(e,t)},q=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},v={},g=0;g<c;++g)p[E=(M=u[g]).id]=1/c,v[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<c;++g){var E=(M=u[g]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var y=d(E,h,"source"),m=0;m<y.length;++m){var L=y[m],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,g=0;g<c;++g){var M;n=p[E=(M=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v};var F={}.toString;const A=function(e,t){return F.call(e)==="[object "+t+"]"},D=function(e){return Array.isArray?Array.isArray(e):A(e,"Array")};Object.keys;var R=Array.prototype;R.splice,R.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const U=function e(t){if("object"!=typeof t||null===t)return t;var r;if(D(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var G="-1",z=function(e,t,r,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===r&&(r=-1),void 0===n&&(n="-1"),this.id=e,this.from=t,this.to=r,this.label=n},B=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),H=function(){function e(e,t,r){void 0===e&&(e=-1),void 0===t&&(t=!0),void 0===r&&(r=!1),this.id=e,this.edgeIdAutoIncrease=t,this.edges=[],this.nodes=[],this.nodeMap={},this.edgeMap={},this.nodeLabelMap={},this.edgeLabelMap={},this.counter=0,this.directed=r}return e.prototype.getNodeNum=function(){return this.nodes.length},e.prototype.addNode=function(e,t){if(!this.nodeMap[e]){var r=new B(e,t);this.nodes.push(r),this.nodeMap[e]=r,this.nodeLabelMap[t]||(this.nodeLabelMap[t]=[]),this.nodeLabelMap[t].push(e)}},e.prototype.addEdge=function(e,t,r,n){if((this.edgeIdAutoIncrease||void 0===e)&&(e=this.counter++),!(this.nodeMap[t]&&this.nodeMap[r]&&this.nodeMap[r].edgeMap[e])){var o=new z(e,t,r,n);if(this.edges.push(o),this.edgeMap[e]=o,this.nodeMap[t].addEdge(o),this.edgeLabelMap[n]||(this.edgeLabelMap[n]=[]),this.edgeLabelMap[n].push(o),!this.directed){var i=new z(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),_=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new _(e,t,r,n,o)),this.dfsEdgeList},e.prototype.toGraph=function(e,t){void 0===e&&(e=-1),void 0===t&&(t=!1);var r=new H(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),r.addEdge(void 0,t,n,a)})),r},e.prototype.buildRmpath=function(){this.rmpath=[];for(var e=void 0,t=this.dfsEdgeList.length-1;t>=0;t--){var r=this.dfsEdgeList[t],n=r.fromNode,o=r.toNode;n<o&&(void 0===e||o===e)&&(this.rmpath.push(t),e=n)}return this.rmpath},e.prototype.getNodeNum=function(){var e={};return this.dfsEdgeList.forEach((function(t){e[t.fromNode]||(e[t.fromNode]=!0),e[t.toNode]||(e[t.toNode]=!0)})),Object.keys(e).length},e}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);i.dfsEdgeList.push(new _(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,v=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},g=d.length-1;g>p&&"break"!==v(g);g--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new _(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var y={};c=!1;var m=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,m=f,i.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}));var L=d.length,N=function(t){if(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,m=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+o[e.to].label;y[r]||(y[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),y[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!c)return!0;var M=e.findMinLabel(y);i.dfsEdgeList.push(new _(m,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(y[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(U(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new _(o,n,"-1",i,"-1")),t.subGraphMining(d[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(a).forEach((function(e){var r=a[e],n=r.fromNodeId,i=r.edgeLabel,d=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new _(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new _(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,v=0;v<p;v++){var g=o[c[v]];n[i].nodes.push(g),l[g.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=t.nodes[0][r],u=t.nodes[1][r],f=t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&d.degree++;var s=r[e.target];s&&s.degree++})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o};const re=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=j(e,r),u=j(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,v=$(t.nodes,i),g=v.nodeMap,b=v.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,g).edgeLabelMap;o||(o=Math.max.apply(Math,y(u[0],[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),k=Y(M,L,e),w=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?Q:o,a=e.edgeLabelProp,d=void 0===a?Q:a,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,a){var d=e[i],s=new H(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:k,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),x=w.length,I=[];w.forEach((function(e,t){I[t]={},Object.keys(k).forEach((function(r){var n=k[r],o=Z(n,e,i,a);I[t][r]=o}))}));var O=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(I,x,w),S=O.structure,C=O.structureCountMap,P=t.nodes[0],T=P[i],q=p[T],F={},A={},D={},R={},U={};Object.keys(b).forEach((function(r,n){U[r]=[];var o=-1/0,d=b[r],s={};d.forEach((function(e){var t=h[P.id+"-"+e.id];t&&U[r].push(t),o<t&&(o=t),s[P.id+"-"+e.id]={start:0,end:g[e.id].idx,distance:t}})),U[r]=U[r].sort((function(e,t){return e-t})),A=Y(s,N,t,A);var u=[];if(Object.keys(s).forEach((function(e){if(D[e])u.push(D[e]);else{var t=A[e];D[e]=Z(t,S,i,a),u.push(D[e])}})),u=u.sort((function(e,t){return t-e})),R[P.id+"-"+r]=u,r!==T)for(var c=function(t){var n=q[t],o=L[l[n.id].idx],d=o.nodeLabelCountMap[r],s=b[r].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var h=!1,c=0;c<s;c++)if(d.dists[c]>U[r][c]){h=!0;break}if(h)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[n.id+"-"+e.id];p[n.id+"-"+e.id]={start:l[n.id].idx,end:l[e.id].idx,distance:t}})),k=Y(p,L,e,k);var v=[];Object.keys(p).forEach((function(e){if(C[e])v.push(C[e]);else{var t=k[e];C[e]=Z(t,S,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(c=0;c<s;c++)if(v[c]<u[c]){g=!0;break}return g?(q.splice(t,1),"continue"):void 0},p=q.length-1;p>=0;p--)c(p)}));var G=[];q.forEach((function(r){for(var n=l[r.id].idx,d=X(e.nodes,s[n],n,i,o).neighbors,u=d.length,h=!1,c=function(n){if(d.length+1<t.nodes.length)return h=!0,{value:void 0};var o=d[n],s=o[i];if(!b[s]||!b[s].length)return d.splice(n,1),"continue";var u=r.id+"-"+o.id;if(!U[s]||!U[s].length)return d.splice(n,1),"continue";var c=f[u];if(c>U[s][U[s].length-1])return d.splice(n,1),"continue";var p=C[u]?C[u]:function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)}(e,r,o,l,c,L,S,i,a,C,k),v=P.id+"-"+s;if(p<R[v][R[v].length-1])return d.splice(n,1),"continue";var E=F[s];return void 0===E&&(E=1/0,b[s].forEach((function(e){var t=g[e.id].degree;E>t&&(E=t)})),F[s]=E),l[o.id].degree<E?(d.splice(n,1),"continue"):void 0},p=u-1;p>=0;p--){var v=c(p);if("object"==typeof v)return v.value}h||G.push({nodes:[r].concat(d)})}));var z=m(t,P.id,!1).length,B={};r?(Object.keys(z).forEach((function(e){var t=g[e].node[i];B[t]?B[t].push(z[e]):B[t]=[z[e]]})),Object.keys(B).forEach((function(e){B[e].sort((function(e,t){return e-t}))}))):B=U;for(var _=function(n){var o=G[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++)}));for(var c=Object.keys(E).length,p=!1,v=0;v<c;v++){var y=Object.keys(E)[v];if(!h[y]||h[y]<E[y].length){p=!0;break}}if(p)return G.splice(n,1),"continue";var L=f.length;if(L<t.edges.length)return G.splice(n,1),"break";var N=!1,M=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],c=!1;return o.forEach((function(e){var t=g[e.source].node,n=g[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(N=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,"continue"))};for(v=L-1;v>=0&&"break"!==M(v);v--);if(N)return G.splice(n,1),"continue";o.edges=f;var j=m(o,o.nodes[0].id,!1).length;if(Object.keys(j).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!N){if(j[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[t].length)return void(N=!0);var r=o.nodes.indexOf(u[e].node);return o.nodes.splice(r,1),void(u[e]=void 0)}var n=l[e].node[i];if(!B[n]||!B[n].length||j[e]>B[n][B[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(N=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),N)return G.splice(n,1),"continue";for(var k=!0,w=0;k&&!N;){if(k=!1,u[d.id].degree<g[P.id].degree){N=!0;break}if(s[d[i]]<b[d[i]].length){N=!0;break}for(var x=o.nodes.length-1;x>=0;x--){var I=o.nodes[x],O=u[I.id].degree,S=I[i];if(O<F[S]){if(s[I[i]]--,s[I[i]]<b[I[i]].length){N=!0;break}o.nodes.splice(x,1),u[I.id]=void 0,k=!0}}if(N||!k&&0!==w)break;for(var C=(L=f.length)-1;C>=0;C--){var T=f[C];if(!u[T.source]||!u[T.target]){f.splice(C,1);var q=T[a];if(h[q]--,u[T.source]&&u[T.source].degree--,u[T.target]&&u[T.target].degree--,E[q]&&h[q]<E[q].length){N=!0;break}k=!0}}w++}return N||N||o.nodes.length<t.nodes.length||f.length<t.edges.length?(G.splice(n,1),"continue"):void 0},K=G.length-1;K>=0&&"break"!==_(K);K--);var W=G.length,re=function(e){var t=G[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=G[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&G.splice(e,1)},o=W-1;o>e;o--)n(o);W=G.length};for(K=0;K<=W-1;K++)re(K);return G}}};var ne=self;ne.onmessage=function(e){var r=e.data,n=r.type,o=r.data;if("function"!=typeof t[n])ne.postMessage({type:"FAILURE"});else{var i=t[n].apply(t,o);ne.postMessage({type:"SUCCESS",data:i})}}})(); | ||
//# sourceMappingURL=index.worker.js.map |
@@ -880,3 +880,4 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
candidateGraph.nodes.splice(candidateNodeMap[targetId].idx, 1); | ||
var idx = candidateGraph.nodes.indexOf(candidateNodeMap[targetId].node); | ||
candidateGraph.nodes.splice(idx, 1); | ||
candidateNodeMap[targetId] = undefined; | ||
@@ -898,3 +899,4 @@ return; | ||
candidateGraph.nodes.splice(candidateNodeMap[targetId].idx, 1); | ||
var idx = candidateGraph.nodes.indexOf(candidateNodeMap[targetId].node); | ||
candidateGraph.nodes.splice(idx, 1); | ||
candidateNodeMap[targetId] = undefined; | ||
@@ -901,0 +903,0 @@ } |
@@ -893,3 +893,4 @@ "use strict"; | ||
candidateGraph.nodes.splice(candidateNodeMap[targetId].idx, 1); | ||
var idx = candidateGraph.nodes.indexOf(candidateNodeMap[targetId].node); | ||
candidateGraph.nodes.splice(idx, 1); | ||
candidateNodeMap[targetId] = undefined; | ||
@@ -911,3 +912,4 @@ return; | ||
candidateGraph.nodes.splice(candidateNodeMap[targetId].idx, 1); | ||
var idx = candidateGraph.nodes.indexOf(candidateNodeMap[targetId].node); | ||
candidateGraph.nodes.splice(idx, 1); | ||
candidateNodeMap[targetId] = undefined; | ||
@@ -914,0 +916,0 @@ } |
{ | ||
"name": "@antv/algorithm", | ||
"version": "0.1.0-beta.2", | ||
"version": "0.1.0-beta.3", | ||
"description": "graph algorithm", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
980738
9834