Socket
Socket
Sign inDemoInstall

@antv/algorithm

Package Overview
Dependencies
Maintainers
56
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/algorithm - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

es/k-core.d.ts

2

dist/index.min.js

@@ -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={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)},t={};e.d(t,{default:()=>ae});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):"".concat(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){void 0===e&&(e=0);var t="".concat(Math.random()).split(".")[1].substr(0,5),r="".concat(Math.random()).split(".")[1].substr(0,5);return"".concat(e,"-").concat(t).concat(r)};var c=function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},c=[],f=0,h=function(e){s[e.id]=f,u[e.id]=f,f+=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&&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]===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&&c.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||h(v)}return c};function f(e,t){return t?c(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)},c=0;c<r.length;c++){var f=r[c];if(!a[f.id]){u(f);for(var h=[];s.length>0;)h.push(s.pop());i.push(h)}}return i}(e)}var h=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=h;function p(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})&&p(e,o,t,n)})),n.leave({current:t,previous:r})}function v(e,t,r){p(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))}var g=function(e,t,r){var n,o;void 0===r&&(r=!0);for(var i=[],a=0,s=f(e,!1);a<s.length;a++){var u=s[a];if(u.length)for(var c=u[0],h=c.id,l=[c],p=((n={})[h]=c,n),v=((o={})[h]=new Set,o);l.length>0;)for(var g=l.pop(),b=g.id,E=d(b,e.edges),m=function(n){var o,a=E[n],d=e.nodes.find((function(e){return e.id===a}));if(a===b)i.push(((o={})[a]=g,o));else if(a in v){if(!v[b].has(d)){for(var s=!0,u=[d,g],c=p[b];v[a].size&&!v[a].has(c)&&(u.push(c),c!==p[c.id]);)c=p[c.id];if(u.push(c),t&&r?(s=!1,u.findIndex((function(e){return t.indexOf(e.id)>-1}))>-1&&(s=!0)):t&&!r&&u.findIndex((function(e){return t.indexOf(e.id)>-1}))>-1&&(s=!1),s){for(var f={},h=1;h<u.length;h+=1)f[u[h-1].id]=u[h];u.length&&(f[u[u.length-1].id]=u[0]),i.push(f)}v[a].add(g)}}else p[a]=g,l.push(d),v[a]=new Set([g])},y=0;y<E.length;y+=1)m(y)}return i},b=function(e,t,r){void 0===r&&(r=!0);for(var n=[],o=new Set,i=[],a=[],s={},u={},f=function(e,d,u){var c=!1;if(t&&!1===r&&t.indexOf(e.id)>-1)return c;n.push(e),o.add(e);for(var h=u[e.id],l=0;l<h.length;l+=1)if((g=s[h[l]])===d){for(var p={},v=1;v<n.length;v+=1)p[n[v-1].id]=n[v];n.length&&(p[n[n.length-1].id]=n[0]),a.push(p),c=!0}else o.has(g)||f(g,d,u)&&(c=!0);if(c)!function(e){for(var t=[e];t.length>0;){var r=t.pop();o.has(r)&&(o.delete(r),i[r.id].forEach((function(e){t.push(e)})),i[r.id].clear())}}(e);else for(l=0;l<h.length;l+=1){var g=s[h[l]];i[g.id].has(e)||i[g.id].add(e)}return n.pop(),c},h=e.nodes,l=void 0===h?[]:h,p=0;p<l.length;p+=1){var v=l[p],g=v.id;u[g]=p,s[p]=v}if(t&&r){var b=function(e){var r=t[e];u[l[e].id]=u[r],u[r]=0,s[0]=l.find((function(e){return e.id===r})),s[u[l[e].id]]=l[e]};for(p=0;p<t.length;p++)b(p)}for(var E=function(n){for(var o,i,s=1/0,c=0;c<n.length;c+=1)for(var f=n[c],h=0;h<f.length;h++){var l=u[f[h].id];l<s&&(s=l,i=c)}var p=n[i],v=[];for(c=0;c<p.length;c+=1){var g=p[c];v[g.id]=[];for(var b=0,E=d(g.id,e.edges,"target").filter((function(e){return p.map((function(e){return e.id})).indexOf(e)>-1}));b<E.length;b++){var m=E[b];m!==g.id||!1===r&&t.indexOf(g.id)>-1?v[g.id].push(u[m]):a.push(((o={})[g.id]=g,o))}}return{component:p,adjList:v,minIdx:s}},m=0;m<l.length;){var y=l.filter((function(e){return u[e.id]>=m})),L=c({nodes:y,edges:e.edges}).filter((function(e){return e.length>1}));if(0===L.length)break;var N=E(L),w=N.minIdx,k=N.adjList,x=N.component;if(!(x.length>1))break;x.forEach((function(e){i[e.id]=new Set}));var I=s[w];if(t&&r&&-1===t.indexOf(I.id))return a;f(I,I,k),m=w+1}return a};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;)v(e,Object.keys(o)[0],d);return t};function m(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return L(e,"Function")},w=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var k=Array.prototype;k.splice,k.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI;Object.values;Object.prototype;const x=function e(t){if("object"!=typeof t||null===t)return t;var r;if(w(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};var I;Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(e,t){if(!N(e))throw new TypeError("Expected a function");new Map}((function(e,t){void 0===t&&(t={});var r,n=t.fontSize,o=t.fontFamily,i=t.fontWeight,a=t.fontStyle,d=t.fontVariant;return I||(I=document.createElement("canvas").getContext("2d")),I.font=[a,d,i,n+"px",o].join(" "),I.measureText((r=e,L(r,"String")?e:"")).width})),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}}();const j=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],c={},f={},h={};i.forEach((function(e,r){var n=e.id;u.push(n),f[n]=1/0,n===t&&(f[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}(f,i,c),o=t.id;if(c[o]=!0,f[o]===1/0)return"continue";var a=[];a=r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d),a.forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;f[a]>f[t.id]+d?(f[a]=f[t.id]+d,h[a]=[t.id]):f[a]===f[t.id]+d&&h[a].push(t.id)}))},v=0;v<l;v++)p();h[t]=[t];var g={};for(var b in f)f[b]!==1/0&&M(t,b,h,g);var E={};for(var b in g)E[b]=g[b][0];return{length:f,path:E,allPath:g}};function M(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=M(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var c=u[s];w(c)?o.push(m(m([],c,!0),[t],!1)):o.push([c,t])}}return n[t]=o,n[t]}const O=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};const D=function(){function e(e){this.arr=e}return e.prototype.add=function(t){var r,n=t.arr;if(!(null===(r=this.arr)||void 0===r?void 0:r.length))return new e(n);if(!(null==n?void 0:n.length))return new e(this.arr);if(this.arr.length===n.length){var o=[];for(var i in this.arr)o[i]=this.arr[i]+n[i];return new e(o)}},e.prototype.subtract=function(t){var r,n=t.arr;if(!(null===(r=this.arr)||void 0===r?void 0:r.length))return new e(n);if(!(null==n?void 0:n.length))return new e(this.arr);if(this.arr.length===n.length){var o=[];for(var i in this.arr)o[i]=this.arr[i]-n[i];return new e(o)}},e.prototype.avg=function(t){var r=[];for(var n in this.arr)r[n]=this.arr[n]/t;return new e(r)},e.prototype.negate=function(){var t=[];for(var r in this.arr)t[r]=-this.arr[r];return new e(t)},e.prototype.squareEuclideanDistance=function(e){var t,r=e.arr;if(!(null===(t=this.arr)||void 0===t?void 0:t.length)||!(null==r?void 0:r.length))return 0;if(this.arr.length===r.length){var n=0;for(var o in this.arr)n+=Math.pow(this.arr[o]-e.arr[o],2);return n}},e.prototype.normalize=function(){var t=[],r=x(this.arr);r.sort((function(e,t){return e-t}));var n=r[r.length-1],o=r[0];for(var i in this.arr)t[i]=(this.arr[i]-o)/(n-o);return new e(t)},e}();var S=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/,P=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/,C=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)},A=function(e,t){return t.map((function(t){if(e.hasOwnProperty(t)){if(!isNaN(Number(e[t])))return Number(e[t]);if(e[t].match(S)||e[t].match(P))return Number(Date.parse(new Date(e[t])))/1e3}return 0}))},T=function(e,t){void 0===e&&(e=[]);for(var r=e.length,n=new D([]),o=0;o<r;o++)n=n.add(new D(t[o]));var i=n.avg(r);i.normalize();var a=0;for(o=0;o<r;o++)a+=(s=new D(t[o])).squareEuclideanDistance(i);var d=[];for(e.forEach((function(){d.push([])})),o=0;o<r;o++){var s=new D(t[o]);e[o].clusterInertial=0;for(var u=0;u<r;u++)if(o!==u){var c=new D(t[u]);d[o][u]=s.squareEuclideanDistance(c),e[o].clusterInertial+=d[o][u]}else d[o][u]=0}var f=0,h=2*r*a;for(o=0;o<r;o++){var l=e[o].clusterId;for(u=0;u<r;u++){var p=e[u].clusterId;o!==u&&l===p&&(f+=e[o].clusterInertial*e[u].clusterInertial/Math.pow(h,2)-d[o][u]/h)}}return Number(f.toFixed(4))};const q=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 F=function(e,t){return e-t};const R=function(){function e(e){void 0===e&&(e=F),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 G=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 c=new R((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){c.insert(e)}));!c.isEmpty();){var f=c.delMin(),h=f.source,l=f.target;u.has(h)&&u.has(l)||(r.push(f),u.has(h)||(u.add(h),s(h,a).forEach((function(e){c.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){c.insert(e)}))))}return r},U=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 q(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),c=u.source,f=u.target;s.connected(c,f)||(r.push(u),s.union(c,f))}return r};var z="-1",B=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},H=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=z),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}(),W=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 H(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 B(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 B(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||z,edgeLabel:n||"-1",nodeLabel2:o||z}}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 W(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!==z&&r.addNode(t,i),d!==z&&r.addNode(n,d),i!==z&&d!==i&&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}(),V=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,c=e.directed,f=void 0!==c&&c,h=e.verbose,l=void 0!==h&&h;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=f,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],c=e.nodeMap[u.to];r<=c.label&&!n.hasNode(c)&&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 c=d[u],f=i[c.to].label;t.to===c.to||r>f||n.hasNode(i[c.to])||(t.label<c.label||t.label===c.label&&a<=f)&&o.push(c)}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="".concat(t.label,"-").concat(e.label,"-").concat(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);if(d){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,c=i.dfsEdgeList[d[0]].toNode,f={},h=!1,l=0,p=r?-1:0,v=function(t){if(h)return"break";a.forEach((function(r){var o=new V(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(f[a.label]||(f[a.label]={projected:[],edgeLabel:a.label}),f[a.label].projected.push({graphId:n.id,edge:f,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(f);i.dfsEdgeList.push(new $(c,l,z,b.edgeLabel,z));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(f[b.edgeLabel].projected)}var m={};h=!1;var y=0;a.forEach((function(t){var r=new V(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(h=!0,y=c,i.forEach((function(e){var r="".concat(e.label,"-").concat(o[e.to].label);m[r]||(m[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),m[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 V(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(h=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r="".concat(e.label,"-").concat(o[e.to].label);m[r]||(m[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),m[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!h)return!0;var w=e.findMinLabel(m);i.dfsEdgeList.push(new $(y,c+1,z,w.edgeLabel,w.nodeLabel2));var k=i.dfsEdgeList.length-1;return t.dfsEdgeList[k]===i.dfsEdgeList[k]&&s(m["".concat(w.edgeLabel,"-").concat(w.nodeLabel2)].projected)},u="".concat(d.nodeLabel1,"-").concat(d.edgeLabel,"-").concat(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(x(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,c=new V(e),f=n.length-1;f>=0;f--){var h=t.findBackwardEdge(s,c.edges[n[f]],c.edges[n[0]],c);if(h){var l="".concat(t.dfsCode.dfsEdgeList[n[f]].fromNode,"-").concat(h.label);d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[f]].fromNode,edgeLabel:h.label}),d[l].projected.push({graphId:e.graphId,edge:h,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,c.edges[n[0]],i,c).forEach((function(t){var r="".concat(o,"-").concat(t.label,"-").concat(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,c.edges[n[r]],i,c).forEach((function(o){var i="".concat(t.dfsCode.dfsEdgeList[n[r]].fromNode,"-").concat(o.label,"-").concat(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(f=0;f<n.length;f++)p(f)}})),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,z,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,c="".concat(r,"-").concat(u);if(!a[c]){var f=o[u]||0;f++,o[u]=f}a[c]={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 c=e.label,f="".concat(r,"-").concat(n,"-").concat(c,"-").concat(o),h="".concat(n,"-").concat(c,"-").concat(o);if(!i[h]){var l=i[h]||0;l++,i[h]=l}d[f]={graphId:r,nodeLabel1:n,edgeLabel:c,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="".concat(t.label,"-").concat(e.label,"-").concat(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 X=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(Y(i,e,t,r,n))})),o},Y=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}},Z=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,c=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&c){var f=new Set(c),h=u.filter((function(e){return f.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},_=function(e,t,r,n){var o,i,a={};e.nodes.forEach((function(e){a[e.id]=e}));var d=0;return!(null===(o=null==t?void 0:t.edges)||void 0===o?void 0:o.length)||(null===(i=null==t?void 0:t.nodes)||void 0===i?void 0:i.length)<2?0:(e.edges.forEach((function(e){var o=a[e.source][r],i=a[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],c=null==t?void 0:t.edges[0][n];e[n]===c&&(o===s&&i===u||o===u&&i===s)&&d++})),d)},ee=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0,inDegree:0,outDegree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},te=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n["".concat(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++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},re=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,c=t[s];o["".concat(d,"-").concat(u)]=c,r||(o["".concat(u,"-").concat(d)]=c)}})),o},ne=function(e,t,r,n,o,i,a,d,s,u,c){var f,h="".concat(t.id,"-").concat(r.id);if(u&&u[h])return u[h];var l=c?c[h]:void 0;if(!l){var p=((f={})[h]={start:n[t.id].idx,end:n[r.id].idx,distance:o},f);l=(c=Z(p,i,e,c))[h]}return _(l,a,d,s)},oe=function(e,t,r,n){var o,i,a,d=null===(o=e[t])||void 0===o?void 0:o.degree,s=null===(i=e[t])||void 0===i?void 0:i.inDegree,u=null===(a=e[t])||void 0===a?void 0:a.outDegree;return void 0===e[t]&&(d=1/0,s=1/0,u=1/0,n[t].forEach((function(e){var t=r[e.id].degree;d>t&&(d=t);var n=r[e.id].inDegree;s>n&&(s=n);var o=r[e.id].outDegree;u>o&&(u=o)})),e[t]={degree:d,inDegree:s,outDegree:u}),{minPatternNodeLabelDegree:d,minPatternNodeLabelInDegree:s,minPatternNodeLabelOutDegree:u}};var ie=function(){function e(e){void 0===e&&(e=10),this.linkedList=new i,this.maxStep=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},e.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},e.prototype.push=function(e){this.linkedList.prepend(e),this.length>this.maxStep&&this.linkedList.deleteTail()},e.prototype.pop=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toArray=function(){return this.linkedList.toArray().map((function(e){return e.value}))},e.prototype.clear=function(){for(;!this.isEmpty();)this.pop()},e}();const ae={getAdjMatrix:r,breadthFirstSearch:function(e,t,r,n){void 0===n&&(n=!0);var o=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),i=new a,s=e.edges,u=void 0===s?[]:s;i.enqueue(t);for(var c="",f=function(){var e=i.dequeue();o.enter({current:e,previous:c}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:c,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:c}),c=e};!i.isEmpty();)f()},connectedComponent:f,getDegree:l,getInDegree:function(e,t){return h(e)[t]?h(e)[t].inDegree:0},getOutDegree:function(e,t){return h(e)[t]?h(e)[t].outDegree:0},detectCycle:E,detectDirectedCycle:E,detectAllCycles:function(e,t,r,n){return void 0===n&&(n=!0),t?b(e,r,n):g(e,r,n)},detectAllDirectedCycle:b,detectAllUndirectedCycle:g,depthFirstSearch:v,dijkstra:j,findAllPath: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),c=[],f=[],h=n?d(t,a,"target"):d(t,a);for(c.push(h);s.length>0&&c.length>0;){var l=c[c.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,h=n?d(p,a,"target"):d(p,a),c.push(h.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));f.push(v),g=s.pop(),u[g]=!1,c.pop()}}else{var g=s.pop();u[g]=!1,c.pop()}}return f},findShortestPath:function(e,t,r,n,o){var i=j(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},floydWarshall:O,labelPropagation: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,c={},f={};a.forEach((function(e,t){var r=u();e.clusterId=r,c[r]={id:r,nodes:[e]},f[e.id]={node:e,idx:t}}));var h=r(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=f[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=c[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=c[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(c).forEach((function(e){var t=c[e];t.nodes&&t.nodes.length||delete c[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=f[t].node.clusterId,a=f[r].node.clusterId,d="".concat(i,"---").concat(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 m=[];return Object.keys(c).forEach((function(e){m.push(c[e])})),{clusters:m,clusterEdges:b}},louvain:function(e,t,n,o,i,a){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4),void 0===i&&(i=!1),void 0===a&&(a=1);var d=e.nodes,s=void 0===d?[]:d,u=e.edges,c=void 0===u?[]:u,f=[];if(i){s.forEach((function(e,t){e.properties=e.properties||{},e.originIndex=t}));var h=[];s.every((function(e){return e.hasOwnProperty("nodeType")}))&&(h=Array.from(new Set(s.map((function(e){return e.nodeType})))),s.forEach((function(e){e.properties.nodeType=h.findIndex((function(t){return t===e.nodeType}))})));var l=function(e){void 0===e&&(e=[]);var t={};e.forEach((function(e){Object.keys(e.properties).forEach((function(r){!"".concat(e.properties[r]).match(S)&&!"".concat(e.properties[r]).match(P)&&isNaN(Number(e.properties[r]))||"id"===r?t.hasOwnProperty(r)&&delete t[r]:t.hasOwnProperty(r)?t[r]+=1:t[r]=1}))}));var r=Object.keys(t).sort((function(e,r){return t[r]-t[e]}));return r.length<100?r:r.slice(0,100)}(s);f=function(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=A(t[n].properties,e);return r}(l,s)}var p=1,v={},g={};s.forEach((function(e,t){var r=String(p++);e.clusterId=r,v[r]={id:r,nodes:[e]},g[e.id]={node:e,idx:t}}));var b=r(e,t),E=[],m={},y=0;b.forEach((function(e,t){var r=0,n=s[t].id;m[n]={},e.forEach((function(e,t){if(e){r+=e;var o=s[t].id;m[n][o]=e,y+=e}})),E.push(r)})),y/=2;for(var L=1/0,N=1/0,w=0,k=[],I={};;){L=i&&s.every((function(e){return e.hasOwnProperty("properties")}))?C(s,b,E,y)+T(s,f)*a:C(s,b,E,y),0===w&&(N=L,k=s,I=v);var j=L>0&&L>N&&L-N<o;if(L>N&&(k=s.map((function(e){return{node:e,clusterId:e.clusterId}})),I=x(v),N=L),j||w>100)break;w++,Object.keys(v).forEach((function(e){var t=0;c.forEach((function(r){var o=r.source,i=r.target,a=g[o].node.clusterId,d=g[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),v[e].sumTot=t})),s.forEach((function(e,t){var r,o=v[e.clusterId],d=0,s=E[t]/(2*y),u=0,h=o.nodes;h.forEach((function(e){var r=g[e.id].idx;u+=b[t][r]||0}));var l=u-o.sumTot*s,p=h.filter((function(t){return t.id!==e.id})),L=[];p.forEach((function(e,t){L[t]=f[e.originIndex]}));var N=T(p,f)*a,w=m[e.id];if(Object.keys(w).forEach((function(n){var o=g[n].node.clusterId;if(o!==e.clusterId){var u=v[o],c=u.nodes;if(c&&c.length){var h=0;c.forEach((function(e){var r=g[e.id].idx;h+=b[t][r]||0}));var p=h-u.sumTot*s,E=c.concat([e]),m=[];E.forEach((function(e,t){m[t]=f[e.originIndex]}));var y=T(E,f)*a,L=p-l;i&&(L=p+y-(l+N)),L>d&&(d=L,r=u)}}})),d>0){r.nodes.push(e);var k=e.clusterId;e.clusterId=r.id;var x=o.nodes.indexOf(e);o.nodes.splice(x,1);var I=0,j=0;c.forEach((function(e){var t=e.source,o=e.target,i=g[t].node.clusterId,a=g[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(I+=e[n]||1),(i===k&&a!==k||a===k&&i!==k)&&(j+=e[n]||1)})),r.sumTot=I,o.sumTot=j}}))}var M={},O=0;Object.keys(I).forEach((function(e){var t=I[e];if(t.nodes&&t.nodes.length){var r=String(O+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),I[r]=t,M[e]=r,delete I[e],O++)}else delete I[e]})),k.forEach((function(e){var t=e.node,r=e.clusterId;t.clusterId=r,t.clusterId&&M[t.clusterId]&&(t.clusterId=M[t.clusterId])}));var D=[],q={};c.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=g[t].node.clusterId,a=g[r].node.clusterId,d="".concat(i,"---").concat(a);if(q[d])q[d].weight+=o,q[d].count++;else{var s={source:i,target:a,weight:o,count:1};q[d]=s,D.push(s)}}));var F=[];return Object.keys(I).forEach((function(e){F.push(I[e])})),{clusters:F,clusterEdges:D}},minimumSpanningTree:function(e,t,r){return r?{prim:G,kruskal:U}[r](e,t):U(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,s=e.nodes,u=void 0===s?[]:s,c=e.edges,f=void 0===c?[]:c,h=u.length,p={},v={},g=0;g<h;++g)p[E=(w=u[g]).id]=1/h,v[E]=1/h;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<h;++g){var E=(w=u[g]).id;if(n=0,0===b[w.id].inDegree)p[E]=0;else{for(var m=d(E,f,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/h,o=0,g=0;g<h;++g){var w;n=p[E=(w=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v},getNeighbors:d,Stack:ie,GADDI:function(e,t,r,n,o,i,a){var d;if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var s=e.nodes.length;if(s){var u=O(e,r),c=O(t,r),f=re(e.nodes,u,r),h=re(t.nodes,c,r),l=ee(e.nodes,i),p=l.nodeMap,v=l.nodeLabelMap,g=ee(t.nodes,i),b=g.nodeMap,E=g.nodeLabelMap;te(e.edges,a,p);var y=te(t.edges,a,b).edgeLabelMap,L=[];null==c||c.forEach((function(e){L=L.concat(e)})),o||(o=Math.max.apply(Math,m(m([],L,!1),[2],!1))),n||(n=o);var N=X(e,u,i,n),w=X(t,c,i,n),k=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,c=e.nodeIdxs,f=e.neighborNum-1;s<i;){for(var h=c[1+Math.floor(Math.random()*f)],l=0;(a["".concat(n,"-").concat(h)]||a["".concat(h,"-").concat(n)])&&(h=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a["".concat(n,"-").concat(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,s,Math.min(100,s*(s-1)/2),w,u),x=Z(k,N,e),I=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 W(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,c=e.maxNodeNum,f=e.minNodeNum,h=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:c,minNodeNum:f,top:l,verbose:h,directed:n});p.run();var v=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:"".concat(e.id)})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:"".concat(e.from),target:"".concat(e.to)})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d);return v}({graphs:x,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),M=I.length,D=[];I.forEach((function(e,t){D[t]={},Object.keys(x).forEach((function(r){var n=x[r],o=_(n,e,i,a);D[t][r]=o}))}));var S=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 c=u-d;n<c&&(n=c,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(D,M,I),P=S.structure,C=S.structureCountMap,A=t.nodes[0],T=[],q=null===(d=t.nodes[0])||void 0===d?void 0:d[i],F=-1/0;t.nodes.forEach((function(e){var t=e[i],r=v[t];(null==r?void 0:r.length)>F&&(F=r.length,T=r,q=t,A=e)}));var R={},G={},U={},z={},B={},H={};Object.keys(E).forEach((function(n,o){B[n]=[],r&&(H[n]=[]);var d=-1/0,s=E[n],u={};s.forEach((function(e){var t=h["".concat(A.id,"-").concat(e.id)];if(t&&B[n].push(t),d<t&&(d=t),u["".concat(A.id,"-").concat(e.id)]={start:0,end:b[e.id].idx,distance:t},r){var o=h["".concat(e.id,"-").concat(A.id)];o&&H[n].push(o)}})),B[n]=B[n].sort((function(e,t){return e-t})),r&&(H[n]=H[n].sort((function(e,t){return e-t}))),G=Z(u,w,t,G);var c=[];if(Object.keys(u).forEach((function(e){if(U[e])c.push(U[e]);else{var t=G[e];U[e]=_(t,P,i,a),c.push(U[e])}})),c=c.sort((function(e,t){return t-e})),z["".concat(A.id,"-").concat(n)]=c,n!==q)for(var l=function(t){var r=T[t],o=N[p[r.id].idx],d=o.nodeLabelCountMap[n],s=E[n].length;if(!d||d.count<s)return T.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>B[n][h]){u=!0;break}if(u)return T.splice(t,1),"continue";var l={};o.neighbors.forEach((function(e){var t=f["".concat(r.id,"-").concat(e.id)];l["".concat(r.id,"-").concat(e.id)]={start:p[r.id].idx,end:p[e.id].idx,distance:t}})),x=Z(l,N,e,x);var v=[];Object.keys(l).forEach((function(e){if(C[e])v.push(C[e]);else{var t=x[e];C[e]=_(t,P,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(h=0;h<s;h++)if(v[h]<c[h]){g=!0;break}return g?(T.splice(t,1),"continue"):void 0},v=((null==T?void 0:T.length)||0)-1;v>=0;v--)l(v)}));var $=[];null==T||T.forEach((function(n){for(var d=p[n.id].idx,s=Y(e.nodes,u[d],d,i,o).neighbors,c=!1,h=s.length-1;h>=0;h--){if(s.length+1<t.nodes.length)return void(c=!0);var l=s[h],v=l[i];if(E[v]&&E[v].length)if(B[v]&&B[v].length){var g="".concat(n.id,"-").concat(l.id),m=f[g],y=B[v].length-1;if(m>B[v][y])s.splice(h,1);else{if(r){var L="".concat(l.id,"-").concat(n.id),w=f[L];if(y=H[v].length-1,w>H[v][y]){s.splice(h,1);continue}}var k=C[g]?C[g]:ne(e,n,l,p,m,N,P,i,a,C,x),I="".concat(A.id,"-").concat(v);if(k<z[I][z[I].length-1])s.splice(h,1);else{var j=oe(R,v,b,E),M=j.minPatternNodeLabelDegree;j.minPatternNodeLabelInDegree,j.minPatternNodeLabelOutDegree,p[l.id].degree<M&&s.splice(h,1)}}}else s.splice(h,1);else s.splice(h,1)}c||$.push({nodes:[n].concat(s)})}));var K=j(t,A.id,!1).length,V={};r?(Object.keys(K).forEach((function(e){var t=b[e].node[i];V[t]?V[t].push(K[e]):V[t]=[K[e]]})),Object.keys(V).forEach((function(e){V[e].sort((function(e,t){return e-t}))}))):V=B;for(var ie=function(n){var o=$[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0,inDegree:0,outDegree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var c=[],f={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(c.push(e),f[e[a]]?f[e[a]]++:f[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var h=Object.keys(y).length,l=!1,v=0;v<h;v++){var g=Object.keys(y)[v];if(!f[g]||f[g]<y[g].length){l=!0;break}}if(l)return $.splice(n,1),"continue";var m=c.length;if(m<t.edges.length)return $.splice(n,1),"break";var L=!1,N=function(e){var t=c[e],n=t[a],o=y[n];if(!o||!o.length)return f[n]--,o&&f[n]<o.length?(L=!0,"break"):(c.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],h=!1;return o.forEach((function(e){var t=b[e.source].node,n=b[e.target].node;t[i]===d&&n[i]===s&&(h=!0),r||t[i]!==s||n[i]!==d||(h=!0)})),h?void 0:(f[n]--,o&&f[n]<o.length?(L=!0,"break"):(c.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(v=m-1;v>=0&&"break"!==N(v);v--);if(L)return $.splice(n,1),"continue";o.edges=c;var w=j(o,o.nodes[0].id,!1).length;if(Object.keys(w).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(w[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<E[t].length)return void(L=!0);var r=o.nodes.indexOf(u[e].node);return o.nodes.splice(r,1),void(u[e]=void 0)}var n=p[e].node[i];if(!V[n]||!V[n].length||w[e]>V[n][V[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<E[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return $.splice(n,1),"continue";for(var k=!0,x=0;k&&!L;){if(k=!1,r?u[d.id].degree<b[A.id].degree||u[d.id].inDegree<b[A.id].inDegree||u[d.id].outDegree<b[A.id].outDegree:u[d.id].degree<b[A.id].degree){L=!0;break}if(s[d[i]]<E[d[i]].length){L=!0;break}for(var I=o.nodes.length-1;I>=0;I--){var M=o.nodes[I],O=u[M.id].degree,D=u[M.id].inDegree,S=u[M.id].outDegree,P=M[i],C=oe(R,P,b,E),T=C.minPatternNodeLabelDegree,q=C.minPatternNodeLabelInDegree,F=C.minPatternNodeLabelOutDegree;if(r?O<T||D<q||S<F:O<T){if(s[M[i]]--,s[M[i]]<E[M[i]].length){L=!0;break}o.nodes.splice(I,1),u[M.id]=void 0,k=!0}}if(L||!k&&0!==x)break;for(var G=(m=c.length)-1;G>=0;G--){var U=c[G];if(!u[U.source]||!u[U.target]){c.splice(G,1);var z=U[a];if(f[z]--,u[U.source]&&(u[U.source].degree--,u[U.source].outDegree--),u[U.target]&&(u[U.target].degree--,u[U.target].inDegree--),y[z]&&f[z]<y[z].length){L=!0;break}k=!0}}x++}return L||L||o.nodes.length<t.nodes.length||c.length<t.edges.length?($.splice(n,1),"continue"):void 0},ae=$.length-1;ae>=0&&"break"!==ie(ae);ae--);var de=$.length,se=function(e){var t=$[e],r={};t.edges.forEach((function(e){var t="".concat(e.source,"-").concat(e.target,"-").concat(e.label);r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=$[e],n={};t.edges.forEach((function(e){var t="".concat(e.source,"-").concat(e.target,"-").concat(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&&$.splice(e,1)},o=de-1;o>e;o--)n(o);de=$.length};for(ae=0;ae<=de-1;ae++)se(ae);return $}}}};return t.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={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)},t={};e.d(t,{default:()=>ae});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):"".concat(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){void 0===e&&(e=0);var t="".concat(Math.random()).split(".")[1].substr(0,5),r="".concat(Math.random()).split(".")[1].substr(0,5);return"".concat(e,"-").concat(t).concat(r)};var c=function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},c=[],f=0,h=function(e){s[e.id]=f,u[e.id]=f,f+=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&&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]===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&&c.push(p)}},l=0,p=r;l<p.length;l++){var v=p[l];s[v.id]||0===s[v.id]||h(v)}return c};function f(e,t){return t?c(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)},c=0;c<r.length;c++){var f=r[c];if(!a[f.id]){u(f);for(var h=[];s.length>0;)h.push(s.pop());i.push(h)}}return i}(e)}var h=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=h;function p(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})&&p(e,o,t,n)})),n.leave({current:t,previous:r})}function v(e,t,r){p(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))}var g=function(e,t,r){var n,o;void 0===r&&(r=!0);for(var i=[],a=0,s=f(e,!1);a<s.length;a++){var u=s[a];if(u.length)for(var c=u[0],h=c.id,l=[c],p=((n={})[h]=c,n),v=((o={})[h]=new Set,o);l.length>0;)for(var g=l.pop(),b=g.id,E=d(b,e.edges),m=function(n){var o,a=E[n],d=e.nodes.find((function(e){return e.id===a}));if(a===b)i.push(((o={})[a]=g,o));else if(a in v){if(!v[b].has(d)){for(var s=!0,u=[d,g],c=p[b];v[a].size&&!v[a].has(c)&&(u.push(c),c!==p[c.id]);)c=p[c.id];if(u.push(c),t&&r?(s=!1,u.findIndex((function(e){return t.indexOf(e.id)>-1}))>-1&&(s=!0)):t&&!r&&u.findIndex((function(e){return t.indexOf(e.id)>-1}))>-1&&(s=!1),s){for(var f={},h=1;h<u.length;h+=1)f[u[h-1].id]=u[h];u.length&&(f[u[u.length-1].id]=u[0]),i.push(f)}v[a].add(g)}}else p[a]=g,l.push(d),v[a]=new Set([g])},y=0;y<E.length;y+=1)m(y)}return i},b=function(e,t,r){void 0===r&&(r=!0);for(var n=[],o=new Set,i=[],a=[],s={},u={},f=function(e,d,u){var c=!1;if(t&&!1===r&&t.indexOf(e.id)>-1)return c;n.push(e),o.add(e);for(var h=u[e.id],l=0;l<h.length;l+=1)if((g=s[h[l]])===d){for(var p={},v=1;v<n.length;v+=1)p[n[v-1].id]=n[v];n.length&&(p[n[n.length-1].id]=n[0]),a.push(p),c=!0}else o.has(g)||f(g,d,u)&&(c=!0);if(c)!function(e){for(var t=[e];t.length>0;){var r=t.pop();o.has(r)&&(o.delete(r),i[r.id].forEach((function(e){t.push(e)})),i[r.id].clear())}}(e);else for(l=0;l<h.length;l+=1){var g=s[h[l]];i[g.id].has(e)||i[g.id].add(e)}return n.pop(),c},h=e.nodes,l=void 0===h?[]:h,p=0;p<l.length;p+=1){var v=l[p],g=v.id;u[g]=p,s[p]=v}if(t&&r){var b=function(e){var r=t[e];u[l[e].id]=u[r],u[r]=0,s[0]=l.find((function(e){return e.id===r})),s[u[l[e].id]]=l[e]};for(p=0;p<t.length;p++)b(p)}for(var E=function(n){for(var o,i,s=1/0,c=0;c<n.length;c+=1)for(var f=n[c],h=0;h<f.length;h++){var l=u[f[h].id];l<s&&(s=l,i=c)}var p=n[i],v=[];for(c=0;c<p.length;c+=1){var g=p[c];v[g.id]=[];for(var b=0,E=d(g.id,e.edges,"target").filter((function(e){return p.map((function(e){return e.id})).indexOf(e)>-1}));b<E.length;b++){var m=E[b];m!==g.id||!1===r&&t.indexOf(g.id)>-1?v[g.id].push(u[m]):a.push(((o={})[g.id]=g,o))}}return{component:p,adjList:v,minIdx:s}},m=0;m<l.length;){var y=l.filter((function(e){return u[e.id]>=m})),L=c({nodes:y,edges:e.edges}).filter((function(e){return e.length>1}));if(0===L.length)break;var N=E(L),w=N.minIdx,k=N.adjList,x=N.component;if(!(x.length>1))break;x.forEach((function(e){i[e.id]=new Set}));var I=s[w];if(t&&r&&-1===t.indexOf(I.id))return a;f(I,I,k),m=w+1}return a};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;)v(e,Object.keys(o)[0],d);return t};function m(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return L(e,"Function")},w=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var k=Array.prototype;k.splice,k.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI;Object.values;Object.prototype;const x=function e(t){if("object"!=typeof t||null===t)return t;var r;if(w(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};var I;Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(e,t){if(!N(e))throw new TypeError("Expected a function");new Map}((function(e,t){void 0===t&&(t={});var r,n=t.fontSize,o=t.fontFamily,i=t.fontWeight,a=t.fontStyle,d=t.fontVariant;return I||(I=document.createElement("canvas").getContext("2d")),I.font=[a,d,i,n+"px",o].join(" "),I.measureText((r=e,L(r,"String")?e:"")).width})),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}}();const j=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],c={},f={},h={};i.forEach((function(e,r){var n=e.id;u.push(n),f[n]=1/0,n===t&&(f[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}(f,i,c),o=t.id;if(c[o]=!0,f[o]===1/0)return"continue";var a=[];a=r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d),a.forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;f[a]>f[t.id]+d?(f[a]=f[t.id]+d,h[a]=[t.id]):f[a]===f[t.id]+d&&h[a].push(t.id)}))},v=0;v<l;v++)p();h[t]=[t];var g={};for(var b in f)f[b]!==1/0&&M(t,b,h,g);var E={};for(var b in g)E[b]=g[b][0];return{length:f,path:E,allPath:g}};function M(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=M(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var c=u[s];w(c)?o.push(m(m([],c,!0),[t],!1)):o.push([c,t])}}return n[t]=o,n[t]}const O=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};const D=function(){function e(e){this.arr=e}return e.prototype.add=function(t){var r,n=t.arr;if(!(null===(r=this.arr)||void 0===r?void 0:r.length))return new e(n);if(!(null==n?void 0:n.length))return new e(this.arr);if(this.arr.length===n.length){var o=[];for(var i in this.arr)o[i]=this.arr[i]+n[i];return new e(o)}},e.prototype.subtract=function(t){var r,n=t.arr;if(!(null===(r=this.arr)||void 0===r?void 0:r.length))return new e(n);if(!(null==n?void 0:n.length))return new e(this.arr);if(this.arr.length===n.length){var o=[];for(var i in this.arr)o[i]=this.arr[i]-n[i];return new e(o)}},e.prototype.avg=function(t){var r=[];for(var n in this.arr)r[n]=this.arr[n]/t;return new e(r)},e.prototype.negate=function(){var t=[];for(var r in this.arr)t[r]=-this.arr[r];return new e(t)},e.prototype.squareEuclideanDistance=function(e){var t,r=e.arr;if(!(null===(t=this.arr)||void 0===t?void 0:t.length)||!(null==r?void 0:r.length))return 0;if(this.arr.length===r.length){var n=0;for(var o in this.arr)n+=Math.pow(this.arr[o]-e.arr[o],2);return n}},e.prototype.normalize=function(){var t=[],r=x(this.arr);r.sort((function(e,t){return e-t}));var n=r[r.length-1],o=r[0];for(var i in this.arr)t[i]=(this.arr[i]-o)/(n-o);return new e(t)},e}();var S=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/,P=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/,C=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)},A=function(e,t){return t.map((function(t){if(e.hasOwnProperty(t)){if(!isNaN(Number(e[t])))return Number(e[t]);if(e[t].match(S)||e[t].match(P))return Number(Date.parse(new Date(e[t])))/1e3}return 0}))},T=function(e,t){void 0===e&&(e=[]);for(var r=e.length,n=new D([]),o=0;o<r;o++)n=n.add(new D(t[o]));var i=n.avg(r);i.normalize();var a=0;for(o=0;o<r;o++)a+=(s=new D(t[o])).squareEuclideanDistance(i);var d=[];for(e.forEach((function(){d.push([])})),o=0;o<r;o++){var s=new D(t[o]);e[o].clusterInertial=0;for(var u=0;u<r;u++)if(o!==u){var c=new D(t[u]);d[o][u]=s.squareEuclideanDistance(c),e[o].clusterInertial+=d[o][u]}else d[o][u]=0}var f=0,h=2*r*a;for(o=0;o<r;o++){var l=e[o].clusterId;for(u=0;u<r;u++){var p=e[u].clusterId;o!==u&&l===p&&(f+=e[o].clusterInertial*e[u].clusterInertial/Math.pow(h,2)-d[o][u]/h)}}return Number(f.toFixed(4))};const q=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 F=function(e,t){return e-t};const R=function(){function e(e){void 0===e&&(e=F),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 G=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 c=new R((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){c.insert(e)}));!c.isEmpty();){var f=c.delMin(),h=f.source,l=f.target;u.has(h)&&u.has(l)||(r.push(f),u.has(h)||(u.add(h),s(h,a).forEach((function(e){c.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){c.insert(e)}))))}return r},U=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 q(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),c=u.source,f=u.target;s.connected(c,f)||(r.push(u),s.union(c,f))}return r};var z="-1",B=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},H=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=z),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}(),W=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 H(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 B(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 B(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||z,edgeLabel:n||"-1",nodeLabel2:o||z}}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 W(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!==z&&r.addNode(t,i),d!==z&&r.addNode(n,d),i!==z&&d!==i&&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}(),V=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,c=e.directed,f=void 0!==c&&c,h=e.verbose,l=void 0!==h&&h;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=f,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],c=e.nodeMap[u.to];r<=c.label&&!n.hasNode(c)&&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 c=d[u],f=i[c.to].label;t.to===c.to||r>f||n.hasNode(i[c.to])||(t.label<c.label||t.label===c.label&&a<=f)&&o.push(c)}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="".concat(t.label,"-").concat(e.label,"-").concat(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);if(d){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,c=i.dfsEdgeList[d[0]].toNode,f={},h=!1,l=0,p=r?-1:0,v=function(t){if(h)return"break";a.forEach((function(r){var o=new V(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(f[a.label]||(f[a.label]={projected:[],edgeLabel:a.label}),f[a.label].projected.push({graphId:n.id,edge:f,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(f);i.dfsEdgeList.push(new $(c,l,z,b.edgeLabel,z));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(f[b.edgeLabel].projected)}var m={};h=!1;var y=0;a.forEach((function(t){var r=new V(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(h=!0,y=c,i.forEach((function(e){var r="".concat(e.label,"-").concat(o[e.to].label);m[r]||(m[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),m[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 V(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(h=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r="".concat(e.label,"-").concat(o[e.to].label);m[r]||(m[r]={projected:[],edgeLabel:e.label,nodeLabel2:o[e.to].label}),m[r].projected.push({graphId:n.id,edge:e,preNode:t})})))}))};for(g=0;g<L&&"break"!==N(g);g++);if(!h)return!0;var w=e.findMinLabel(m);i.dfsEdgeList.push(new $(y,c+1,z,w.edgeLabel,w.nodeLabel2));var k=i.dfsEdgeList.length-1;return t.dfsEdgeList[k]===i.dfsEdgeList[k]&&s(m["".concat(w.edgeLabel,"-").concat(w.nodeLabel2)].projected)},u="".concat(d.nodeLabel1,"-").concat(d.edgeLabel,"-").concat(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(x(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,c=new V(e),f=n.length-1;f>=0;f--){var h=t.findBackwardEdge(s,c.edges[n[f]],c.edges[n[0]],c);if(h){var l="".concat(t.dfsCode.dfsEdgeList[n[f]].fromNode,"-").concat(h.label);d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[f]].fromNode,edgeLabel:h.label}),d[l].projected.push({graphId:e.graphId,edge:h,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,c.edges[n[0]],i,c).forEach((function(t){var r="".concat(o,"-").concat(t.label,"-").concat(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,c.edges[n[r]],i,c).forEach((function(o){var i="".concat(t.dfsCode.dfsEdgeList[n[r]].fromNode,"-").concat(o.label,"-").concat(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(f=0;f<n.length;f++)p(f)}})),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,z,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,c="".concat(r,"-").concat(u);if(!a[c]){var f=o[u]||0;f++,o[u]=f}a[c]={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 c=e.label,f="".concat(r,"-").concat(n,"-").concat(c,"-").concat(o),h="".concat(n,"-").concat(c,"-").concat(o);if(!i[h]){var l=i[h]||0;l++,i[h]=l}d[f]={graphId:r,nodeLabel1:n,edgeLabel:c,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="".concat(t.label,"-").concat(e.label,"-").concat(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 X=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(Y(i,e,t,r,n))})),o},Y=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}},Z=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,c=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&c){var f=new Set(c),h=u.filter((function(e){return f.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},_=function(e,t,r,n){var o,i,a={};e.nodes.forEach((function(e){a[e.id]=e}));var d=0;return!(null===(o=null==t?void 0:t.edges)||void 0===o?void 0:o.length)||(null===(i=null==t?void 0:t.nodes)||void 0===i?void 0:i.length)<2?0:(e.edges.forEach((function(e){var o=a[e.source][r],i=a[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],c=null==t?void 0:t.edges[0][n];e[n]===c&&(o===s&&i===u||o===u&&i===s)&&d++})),d)},ee=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0,inDegree:0,outDegree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},te=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n["".concat(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++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},re=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,c=t[s];o["".concat(d,"-").concat(u)]=c,r||(o["".concat(u,"-").concat(d)]=c)}})),o},ne=function(e,t,r,n,o,i,a,d,s,u,c){var f,h="".concat(t.id,"-").concat(r.id);if(u&&u[h])return u[h];var l=c?c[h]:void 0;if(!l){var p=((f={})[h]={start:n[t.id].idx,end:n[r.id].idx,distance:o},f);l=(c=Z(p,i,e,c))[h]}return _(l,a,d,s)},oe=function(e,t,r,n){var o,i,a,d=null===(o=e[t])||void 0===o?void 0:o.degree,s=null===(i=e[t])||void 0===i?void 0:i.inDegree,u=null===(a=e[t])||void 0===a?void 0:a.outDegree;return void 0===e[t]&&(d=1/0,s=1/0,u=1/0,n[t].forEach((function(e){var t=r[e.id].degree;d>t&&(d=t);var n=r[e.id].inDegree;s>n&&(s=n);var o=r[e.id].outDegree;u>o&&(u=o)})),e[t]={degree:d,inDegree:s,outDegree:u}),{minPatternNodeLabelDegree:d,minPatternNodeLabelInDegree:s,minPatternNodeLabelOutDegree:u}};var ie=function(){function e(e){void 0===e&&(e=10),this.linkedList=new i,this.maxStep=e}return Object.defineProperty(e.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},e.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},e.prototype.push=function(e){this.linkedList.prepend(e),this.length>this.maxStep&&this.linkedList.deleteTail()},e.prototype.pop=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toArray=function(){return this.linkedList.toArray().map((function(e){return e.value}))},e.prototype.clear=function(){for(;!this.isEmpty();)this.pop()},e}();const ae={getAdjMatrix:r,breadthFirstSearch:function(e,t,r,n){void 0===n&&(n=!0);var o=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),i=new a,s=e.edges,u=void 0===s?[]:s;i.enqueue(t);for(var c="",f=function(){var e=i.dequeue();o.enter({current:e,previous:c}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:c,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:c}),c=e};!i.isEmpty();)f()},connectedComponent:f,getDegree:l,getInDegree:function(e,t){return h(e)[t]?h(e)[t].inDegree:0},getOutDegree:function(e,t){return h(e)[t]?h(e)[t].outDegree:0},detectCycle:E,detectDirectedCycle:E,detectAllCycles:function(e,t,r,n){return void 0===n&&(n=!0),t?b(e,r,n):g(e,r,n)},detectAllDirectedCycle:b,detectAllUndirectedCycle:g,depthFirstSearch:v,dijkstra:j,findAllPath: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),c=[],f=[],h=n?d(t,a,"target"):d(t,a);for(c.push(h);s.length>0&&c.length>0;){var l=c[c.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,h=n?d(p,a,"target"):d(p,a),c.push(h.filter((function(e){return!u[e]})))),s[s.length-1]===r){var v=s.map((function(e){return e}));f.push(v),g=s.pop(),u[g]=!1,c.pop()}}else{var g=s.pop();u[g]=!1,c.pop()}}return f},findShortestPath:function(e,t,r,n,o){var i=j(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},floydWarshall:O,labelPropagation: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,c={},f={};a.forEach((function(e,t){var r=u();e.clusterId=r,c[r]={id:r,nodes:[e]},f[e.id]={node:e,idx:t}}));var h=r(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=f[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=c[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=c[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";v++};v<o&&"break"!==g(););Object.keys(c).forEach((function(e){var t=c[e];t.nodes&&t.nodes.length||delete c[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=f[t].node.clusterId,a=f[r].node.clusterId,d="".concat(i,"---").concat(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 m=[];return Object.keys(c).forEach((function(e){m.push(c[e])})),{clusters:m,clusterEdges:b}},louvain:function(e,t,n,o,i,a){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4),void 0===i&&(i=!1),void 0===a&&(a=1);var d=e.nodes,s=void 0===d?[]:d,u=e.edges,c=void 0===u?[]:u,f=[];if(i){s.forEach((function(e,t){e.properties=e.properties||{},e.originIndex=t}));var h=[];s.every((function(e){return e.hasOwnProperty("nodeType")}))&&(h=Array.from(new Set(s.map((function(e){return e.nodeType})))),s.forEach((function(e){e.properties.nodeType=h.findIndex((function(t){return t===e.nodeType}))})));var l=function(e){void 0===e&&(e=[]);var t={};e.forEach((function(e){Object.keys(e.properties).forEach((function(r){!"".concat(e.properties[r]).match(S)&&!"".concat(e.properties[r]).match(P)&&isNaN(Number(e.properties[r]))||"id"===r?t.hasOwnProperty(r)&&delete t[r]:t.hasOwnProperty(r)?t[r]+=1:t[r]=1}))}));var r=Object.keys(t).sort((function(e,r){return t[r]-t[e]}));return r.length<100?r:r.slice(0,100)}(s);f=function(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=A(t[n].properties,e);return r}(l,s)}var p=1,v={},g={};s.forEach((function(e,t){var r=String(p++);e.clusterId=r,v[r]={id:r,nodes:[e]},g[e.id]={node:e,idx:t}}));var b=r(e,t),E=[],m={},y=0;b.forEach((function(e,t){var r=0,n=s[t].id;m[n]={},e.forEach((function(e,t){if(e){r+=e;var o=s[t].id;m[n][o]=e,y+=e}})),E.push(r)})),y/=2;for(var L=1/0,N=1/0,w=0,k=[],I={};;){L=i&&s.every((function(e){return e.hasOwnProperty("properties")}))?C(s,b,E,y)+T(s,f)*a:C(s,b,E,y),0===w&&(N=L,k=s,I=v);var j=L>0&&L>N&&L-N<o;if(L>N&&(k=s.map((function(e){return{node:e,clusterId:e.clusterId}})),I=x(v),N=L),j||w>100)break;w++,Object.keys(v).forEach((function(e){var t=0;c.forEach((function(r){var o=r.source,i=r.target,a=g[o].node.clusterId,d=g[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),v[e].sumTot=t})),s.forEach((function(e,t){var r,o=v[e.clusterId],d=0,s=E[t]/(2*y),u=0,h=o.nodes;h.forEach((function(e){var r=g[e.id].idx;u+=b[t][r]||0}));var l=u-o.sumTot*s,p=h.filter((function(t){return t.id!==e.id})),L=[];p.forEach((function(e,t){L[t]=f[e.originIndex]}));var N=T(p,f)*a,w=m[e.id];if(Object.keys(w).forEach((function(n){var o=g[n].node.clusterId;if(o!==e.clusterId){var u=v[o],c=u.nodes;if(c&&c.length){var h=0;c.forEach((function(e){var r=g[e.id].idx;h+=b[t][r]||0}));var p=h-u.sumTot*s,E=c.concat([e]),m=[];E.forEach((function(e,t){m[t]=f[e.originIndex]}));var y=T(E,f)*a,L=p-l;i&&(L=p+y-(l+N)),L>d&&(d=L,r=u)}}})),d>0){r.nodes.push(e);var k=e.clusterId;e.clusterId=r.id;var x=o.nodes.indexOf(e);o.nodes.splice(x,1);var I=0,j=0;c.forEach((function(e){var t=e.source,o=e.target,i=g[t].node.clusterId,a=g[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(I+=e[n]||1),(i===k&&a!==k||a===k&&i!==k)&&(j+=e[n]||1)})),r.sumTot=I,o.sumTot=j}}))}var M={},O=0;Object.keys(I).forEach((function(e){var t=I[e];if(t.nodes&&t.nodes.length){var r=String(O+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),I[r]=t,M[e]=r,delete I[e],O++)}else delete I[e]})),k.forEach((function(e){var t=e.node,r=e.clusterId;t.clusterId=r,t.clusterId&&M[t.clusterId]&&(t.clusterId=M[t.clusterId])}));var D=[],q={};c.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=g[t].node.clusterId,a=g[r].node.clusterId,d="".concat(i,"---").concat(a);if(q[d])q[d].weight+=o,q[d].count++;else{var s={source:i,target:a,weight:o,count:1};q[d]=s,D.push(s)}}));var F=[];return Object.keys(I).forEach((function(e){F.push(I[e])})),{clusters:F,clusterEdges:D}},kCore:function(e,t){var r;void 0===t&&(t=1);for(var n=x(e),o=n.nodes,i=void 0===o?[]:o,a=n.edges,d=void 0===a?[]:a,s=function(){var e=l({nodes:i,edges:d}),n=Object.keys(e);n.sort((function(t,r){var n,o;return(null===(n=e[t])||void 0===n?void 0:n.degree)-(null===(o=e[r])||void 0===o?void 0:o.degree)}));var o=n[0];if(!i.length||(null===(r=e[o])||void 0===r?void 0:r.degree)>=t)return"break";var a=i.findIndex((function(e){return e.id===o}));i.splice(a,1),d=d.filter((function(e){return!(e.source===o||e.target===o)}))};"break"!==s(););return{nodes:i,edges:d}},minimumSpanningTree:function(e,t,r){return r?{prim:G,kruskal:U}[r](e,t):U(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,s=e.nodes,u=void 0===s?[]:s,c=e.edges,f=void 0===c?[]:c,h=u.length,p={},v={},g=0;g<h;++g)p[E=(w=u[g]).id]=1/h,v[E]=1/h;for(var b=l(e);a>0&&o>t;){for(i=0,g=0;g<h;++g){var E=(w=u[g]).id;if(n=0,0===b[w.id].inDegree)p[E]=0;else{for(var m=d(E,f,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=v[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/h,o=0,g=0;g<h;++g){var w;n=p[E=(w=u[g]).id]+i,o+=Math.abs(n-v[E]),v[E]=n}a-=1}return v},getNeighbors:d,Stack:ie,GADDI:function(e,t,r,n,o,i,a){var d;if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var s=e.nodes.length;if(s){var u=O(e,r),c=O(t,r),f=re(e.nodes,u,r),h=re(t.nodes,c,r),l=ee(e.nodes,i),p=l.nodeMap,v=l.nodeLabelMap,g=ee(t.nodes,i),b=g.nodeMap,E=g.nodeLabelMap;te(e.edges,a,p);var y=te(t.edges,a,b).edgeLabelMap,L=[];null==c||c.forEach((function(e){L=L.concat(e)})),o||(o=Math.max.apply(Math,m(m([],L,!1),[2],!1))),n||(n=o);var N=X(e,u,i,n),w=X(t,c,i,n),k=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,c=e.nodeIdxs,f=e.neighborNum-1;s<i;){for(var h=c[1+Math.floor(Math.random()*f)],l=0;(a["".concat(n,"-").concat(h)]||a["".concat(h,"-").concat(n)])&&(h=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a["".concat(n,"-").concat(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,s,Math.min(100,s*(s-1)/2),w,u),x=Z(k,N,e),I=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 W(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,c=e.maxNodeNum,f=e.minNodeNum,h=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:c,minNodeNum:f,top:l,verbose:h,directed:n});p.run();var v=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:"".concat(e.id)})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:"".concat(e.from),target:"".concat(e.to)})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d);return v}({graphs:x,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),M=I.length,D=[];I.forEach((function(e,t){D[t]={},Object.keys(x).forEach((function(r){var n=x[r],o=_(n,e,i,a);D[t][r]=o}))}));var S=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 c=u-d;n<c&&(n=c,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(D,M,I),P=S.structure,C=S.structureCountMap,A=t.nodes[0],T=[],q=null===(d=t.nodes[0])||void 0===d?void 0:d[i],F=-1/0;t.nodes.forEach((function(e){var t=e[i],r=v[t];(null==r?void 0:r.length)>F&&(F=r.length,T=r,q=t,A=e)}));var R={},G={},U={},z={},B={},H={};Object.keys(E).forEach((function(n,o){B[n]=[],r&&(H[n]=[]);var d=-1/0,s=E[n],u={};s.forEach((function(e){var t=h["".concat(A.id,"-").concat(e.id)];if(t&&B[n].push(t),d<t&&(d=t),u["".concat(A.id,"-").concat(e.id)]={start:0,end:b[e.id].idx,distance:t},r){var o=h["".concat(e.id,"-").concat(A.id)];o&&H[n].push(o)}})),B[n]=B[n].sort((function(e,t){return e-t})),r&&(H[n]=H[n].sort((function(e,t){return e-t}))),G=Z(u,w,t,G);var c=[];if(Object.keys(u).forEach((function(e){if(U[e])c.push(U[e]);else{var t=G[e];U[e]=_(t,P,i,a),c.push(U[e])}})),c=c.sort((function(e,t){return t-e})),z["".concat(A.id,"-").concat(n)]=c,n!==q)for(var l=function(t){var r=T[t],o=N[p[r.id].idx],d=o.nodeLabelCountMap[n],s=E[n].length;if(!d||d.count<s)return T.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>B[n][h]){u=!0;break}if(u)return T.splice(t,1),"continue";var l={};o.neighbors.forEach((function(e){var t=f["".concat(r.id,"-").concat(e.id)];l["".concat(r.id,"-").concat(e.id)]={start:p[r.id].idx,end:p[e.id].idx,distance:t}})),x=Z(l,N,e,x);var v=[];Object.keys(l).forEach((function(e){if(C[e])v.push(C[e]);else{var t=x[e];C[e]=_(t,P,i,a),v.push(C[e])}})),v=v.sort((function(e,t){return t-e}));var g=!1;for(h=0;h<s;h++)if(v[h]<c[h]){g=!0;break}return g?(T.splice(t,1),"continue"):void 0},v=((null==T?void 0:T.length)||0)-1;v>=0;v--)l(v)}));var $=[];null==T||T.forEach((function(n){for(var d=p[n.id].idx,s=Y(e.nodes,u[d],d,i,o).neighbors,c=!1,h=s.length-1;h>=0;h--){if(s.length+1<t.nodes.length)return void(c=!0);var l=s[h],v=l[i];if(E[v]&&E[v].length)if(B[v]&&B[v].length){var g="".concat(n.id,"-").concat(l.id),m=f[g],y=B[v].length-1;if(m>B[v][y])s.splice(h,1);else{if(r){var L="".concat(l.id,"-").concat(n.id),w=f[L];if(y=H[v].length-1,w>H[v][y]){s.splice(h,1);continue}}var k=C[g]?C[g]:ne(e,n,l,p,m,N,P,i,a,C,x),I="".concat(A.id,"-").concat(v);if(k<z[I][z[I].length-1])s.splice(h,1);else{var j=oe(R,v,b,E),M=j.minPatternNodeLabelDegree;j.minPatternNodeLabelInDegree,j.minPatternNodeLabelOutDegree,p[l.id].degree<M&&s.splice(h,1)}}}else s.splice(h,1);else s.splice(h,1)}c||$.push({nodes:[n].concat(s)})}));var K=j(t,A.id,!1).length,V={};r?(Object.keys(K).forEach((function(e){var t=b[e].node[i];V[t]?V[t].push(K[e]):V[t]=[K[e]]})),Object.keys(V).forEach((function(e){V[e].sort((function(e,t){return e-t}))}))):V=B;for(var ie=function(n){var o=$[n],d=o.nodes[0],s={},u={};o.nodes.forEach((function(e,t){u[e.id]={idx:t,node:e,degree:0,inDegree:0,outDegree:0};var r=e[i];s[r]?s[r]++:s[r]=1}));var c=[],f={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(c.push(e),f[e[a]]?f[e[a]]++:f[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var h=Object.keys(y).length,l=!1,v=0;v<h;v++){var g=Object.keys(y)[v];if(!f[g]||f[g]<y[g].length){l=!0;break}}if(l)return $.splice(n,1),"continue";var m=c.length;if(m<t.edges.length)return $.splice(n,1),"break";var L=!1,N=function(e){var t=c[e],n=t[a],o=y[n];if(!o||!o.length)return f[n]--,o&&f[n]<o.length?(L=!0,"break"):(c.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue");var d=u[t.source].node[i],s=u[t.target].node[i],h=!1;return o.forEach((function(e){var t=b[e.source].node,n=b[e.target].node;t[i]===d&&n[i]===s&&(h=!0),r||t[i]!==s||n[i]!==d||(h=!0)})),h?void 0:(f[n]--,o&&f[n]<o.length?(L=!0,"break"):(c.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(v=m-1;v>=0&&"break"!==N(v);v--);if(L)return $.splice(n,1),"continue";o.edges=c;var w=j(o,o.nodes[0].id,!1).length;if(Object.keys(w).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(w[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<E[t].length)return void(L=!0);var r=o.nodes.indexOf(u[e].node);return o.nodes.splice(r,1),void(u[e]=void 0)}var n=p[e].node[i];if(!V[n]||!V[n].length||w[e]>V[n][V[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<E[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return $.splice(n,1),"continue";for(var k=!0,x=0;k&&!L;){if(k=!1,r?u[d.id].degree<b[A.id].degree||u[d.id].inDegree<b[A.id].inDegree||u[d.id].outDegree<b[A.id].outDegree:u[d.id].degree<b[A.id].degree){L=!0;break}if(s[d[i]]<E[d[i]].length){L=!0;break}for(var I=o.nodes.length-1;I>=0;I--){var M=o.nodes[I],O=u[M.id].degree,D=u[M.id].inDegree,S=u[M.id].outDegree,P=M[i],C=oe(R,P,b,E),T=C.minPatternNodeLabelDegree,q=C.minPatternNodeLabelInDegree,F=C.minPatternNodeLabelOutDegree;if(r?O<T||D<q||S<F:O<T){if(s[M[i]]--,s[M[i]]<E[M[i]].length){L=!0;break}o.nodes.splice(I,1),u[M.id]=void 0,k=!0}}if(L||!k&&0!==x)break;for(var G=(m=c.length)-1;G>=0;G--){var U=c[G];if(!u[U.source]||!u[U.target]){c.splice(G,1);var z=U[a];if(f[z]--,u[U.source]&&(u[U.source].degree--,u[U.source].outDegree--),u[U.target]&&(u[U.target].degree--,u[U.target].inDegree--),y[z]&&f[z]<y[z].length){L=!0;break}k=!0}}x++}return L||L||o.nodes.length<t.nodes.length||c.length<t.edges.length?($.splice(n,1),"continue"):void 0},ae=$.length-1;ae>=0&&"break"!==ie(ae);ae--);var de=$.length,se=function(e){var t=$[e],r={};t.edges.forEach((function(e){var t="".concat(e.source,"-").concat(e.target,"-").concat(e.label);r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=$[e],n={};t.edges.forEach((function(e){var t="".concat(e.source,"-").concat(e.target,"-").concat(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&&$.splice(e,1)},o=de-1;o>e;o--)n(o);de=$.length};for(ae=0;ae<=de-1;ae++)se(ae);return $}}}};return t.default})()}));
//# sourceMappingURL=index.min.js.map

@@ -13,2 +13,3 @@ import getAdjMatrix from './adjacent-matrix';

import louvain from './louvain';
import kCore from './k-core';
import minimumSpanningTree from './mts';

@@ -23,3 +24,3 @@ import pageRank from './pageRank';

};
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI, IAlgorithm };
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, kCore, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI, IAlgorithm };
declare const _default: {

@@ -56,2 +57,3 @@ getAdjMatrix: (graphData: import("./types").GraphData, directed?: boolean) => import("./types").Matrix[];

louvain: (graphData: import("./types").GraphData, directed?: boolean, weightPropertyName?: string, threshold?: number, inertialModularity?: boolean, inertialWeight?: number) => import("./types").ClusterData;
kCore: (graphData: import("./types").GraphData, k?: number) => import("./types").GraphData;
minimumSpanningTree: (graphData: import("./types").GraphData, weight?: string, algo?: string) => import("./types").EdgeConfig[];

@@ -58,0 +60,0 @@ pageRank: (graphData: import("./types").GraphData, epsilon?: number, linkProb?: number) => {

@@ -13,2 +13,3 @@ import getAdjMatrix from './adjacent-matrix';

import louvain from './louvain';
import kCore from './k-core';
import minimumSpanningTree from './mts';

@@ -20,3 +21,3 @@ import pageRank from './pageRank';

var detectDirectedCycle = detectCycle;
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI };
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, kCore, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI };
export default {

@@ -41,2 +42,3 @@ getAdjMatrix: getAdjMatrix,

louvain: louvain,
kCore: kCore,
minimumSpanningTree: minimumSpanningTree,

@@ -43,0 +45,0 @@ pageRank: pageRank,

@@ -13,2 +13,3 @@ import getAdjMatrix from './adjacent-matrix';

import louvain from './louvain';
import kCore from './k-core';
import minimumSpanningTree from './mts';

@@ -23,3 +24,3 @@ import pageRank from './pageRank';

};
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI, IAlgorithm };
export { getAdjMatrix, breadthFirstSearch, connectedComponent, getDegree, getInDegree, getOutDegree, detectCycle, detectDirectedCycle, detectAllCycles, detectAllDirectedCycle, detectAllUndirectedCycle, depthFirstSearch, dijkstra, findAllPath, findShortestPath, floydWarshall, labelPropagation, louvain, kCore, minimumSpanningTree, pageRank, getNeighbors, Stack, GADDI, IAlgorithm };
declare const _default: {

@@ -56,2 +57,3 @@ getAdjMatrix: (graphData: import("./types").GraphData, directed?: boolean) => import("./types").Matrix[];

louvain: (graphData: import("./types").GraphData, directed?: boolean, weightPropertyName?: string, threshold?: number, inertialModularity?: boolean, inertialWeight?: number) => import("./types").ClusterData;
kCore: (graphData: import("./types").GraphData, k?: number) => import("./types").GraphData;
minimumSpanningTree: (graphData: import("./types").GraphData, weight?: string, algo?: string) => import("./types").EdgeConfig[];

@@ -58,0 +60,0 @@ pageRank: (graphData: import("./types").GraphData, epsilon?: number, linkProb?: number) => {

@@ -118,2 +118,8 @@ "use strict";

});
Object.defineProperty(exports, "kCore", {
enumerable: true,
get: function get() {
return _kCore.default;
}
});
Object.defineProperty(exports, "labelPropagation", {

@@ -166,2 +172,4 @@ enumerable: true,

var _kCore = _interopRequireDefault(require("./k-core"));
var _mts = _interopRequireDefault(require("./mts"));

@@ -204,2 +212,3 @@

louvain: _louvain.default,
kCore: _kCore.default,
minimumSpanningTree: _mts.default,

@@ -206,0 +215,0 @@ pageRank: _pageRank.default,

{
"name": "@antv/algorithm",
"version": "0.1.14",
"version": "0.1.15",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc