@antv/algorithm
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -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={458:e=>{e.exports=function(e,t,r,n){var o=self||window;try{try{var i;try{i=new o.Blob([e])}catch(t){(i=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(e),i=i.getBlob()}var a=o.URL||o.webkitURL,d=a.createObjectURL(i),s=new o[t](d,r);return a.revokeObjectURL(d),s}catch(n){return new o[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new o[t](n,r)}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.p="./dist";var n={};return(()=>{r.d(n,{default:()=>s});var e="SUCCESS",t=r(458),o=r.n(t);function i(){return o()('(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>oe,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>k,findAllPath:()=>x,findShortestPath:()=>w,floydWarshall:()=>O,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>g,labelPropagation:()=>D,louvain:()=>P,minimumSpanningTree:()=>R,pageRank:()=>U});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r,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 f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(a[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var g=p[l];s[g.id]||0===s[g.id]||c(g)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},g=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function v(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})&&v(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){v(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var M=Array.prototype;M.splice,M.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const j=function e(t){if("object"!=typeof t||null===t)return t;var r;if(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const k=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},g=0;g<l;g++)p();c[t]=[t];var v={};for(var b in h)h[b]!==1/0&&I(t,b,c,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function I(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=I(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}var w=function(e,t,r,n,o){var i=k(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},x=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h};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},D=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var g=0,v=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}};var S=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const P=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u=1,f={},h={};a.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},g=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,g+=e}})),l.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=S(a,c,l,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*g),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),a.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(N[d])N[d].weight+=o,N[d].count++;else{var s={source:i,target:a,weight:o,count:1};N[d]=s,L.push(s)}}));var M=[];return Object.keys(f).forEach((function(e){M.push(f[e])})),{clusters:M,clusterEdges:L}},C=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 T=function(e,t){return e-t};const q=function(){function e(e){void 0===e&&(e=T),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 F=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new q((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},A=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 C(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const R=function(e,t,r){return r?{prim:F,kruskal:A}[r](e,t):A(e,t)},U=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},g={},v=0;v<c;++v)p[E=(M=u[v]).id]=1/c,g[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,v=0;v<c;++v){var E=(M=u[v]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var m=d(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,v=0;v<c;++v){var M;n=p[E=(M=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}a-=1}return g};var G="-1",_=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},z=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),B=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 z(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 _(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 _(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),H=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new H(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 B(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),i!==G&&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}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);if(d){i.dfsEdgeList.push(new H(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,g=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},v=d.length-1;v>p&&"break"!==g(v);v--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new H(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};c=!1;var y=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!c)return!0;var M=e.findMinLabel(m);i.dfsEdgeList.push(new H(y,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(m[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)}},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(j(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new H(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 H(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new H(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,g=0;g<p;g++){var v=o[c[g]];n[i].nodes.push(v),l[v.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],f=null==t?void 0:t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0,inDegree:0,outDegree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&(d.degree++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o},re=function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)},ne=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}};const oe=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=O(e,r),u=O(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,g=$(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),j=Y(M,L,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 B(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:j,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=I.length,x=[];I.forEach((function(e,t){x[t]={},Object.keys(j).forEach((function(r){var n=j[r],o=Z(n,e,i,a);x[t][r]=o}))}));var D=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(x,w,I),S=D.structure,P=D.structureCountMap,C=t.nodes[0],T=C[i],q=p[T],F={},A={},R={},U={},G={},_={};Object.keys(b).forEach((function(n,o){G[n]=[],r&&(_[n]=[]);var d=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[C.id+"-"+e.id];if(t&&G[n].push(t),d<t&&(d=t),u[C.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+C.id];o&&_[n].push(o)}})),G[n]=G[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),A=Y(u,N,t,A);var c=[];if(Object.keys(u).forEach((function(e){if(R[e])c.push(R[e]);else{var t=A[e];R[e]=Z(t,S,i,a),c.push(R[e])}})),c=c.sort((function(e,t){return t-e})),U[C.id+"-"+n]=c,n!==T)for(var p=function(t){var r=q[t],o=L[l[r.id].idx],d=o.nodeLabelCountMap[n],s=b[n].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>G[n][h]){u=!0;break}if(u)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:l[r.id].idx,end:l[e.id].idx,distance:t}})),j=Y(p,L,e,j);var g=[];Object.keys(p).forEach((function(e){if(P[e])g.push(P[e]);else{var t=j[e];P[e]=Z(t,S,i,a),g.push(P[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<c[h]){v=!0;break}return v?(q.splice(t,1),"continue"):void 0},g=q.length-1;g>=0;g--)p(g)}));var z=[];null==q||q.forEach((function(n){for(var d=l[n.id].idx,u=X(e.nodes,s[d],d,i,o).neighbors,h=!1,c=u.length-1;c>=0;c--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[c],g=p[i];if(b[g]&&b[g].length)if(G[g]&&G[g].length){var E=n.id+"-"+p.id,m=f[E],y=G[g].length-1;if(m>G[g][y])u.splice(c,1);else{if(r){var N=p.id+"-"+n.id,M=f[N];if(y=_[g].length-1,M>_[g][y]){u.splice(c,1);continue}}var k=P[E]?P[E]:re(e,n,p,l,m,L,S,i,a,P,j),I=C.id+"-"+g;if(k<U[I][U[I].length-1])u.splice(c,1);else{var w=ne(F,g,v,b),x=w.minPatternNodeLabelDegree;w.minPatternNodeLabelInDegree,w.minPatternNodeLabelOutDegree,l[p.id].degree<x&&u.splice(c,1)}}}else u.splice(c,1);else u.splice(c,1)}h||z.push({nodes:[n].concat(u)})}));var H=k(t,C.id,!1).length,K={};r?(Object.keys(H).forEach((function(e){var t=v[e].node[i];K[t]?K[t].push(H[e]):K[t]=[H[e]]})),Object.keys(K).forEach((function(e){K[e].sort((function(e,t){return e-t}))}))):K=G;for(var W=function(n){var o=z[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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var c=Object.keys(E).length,p=!1,g=0;g<c;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return z.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return z.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.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],c=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return z.splice(n,1),"continue";o.edges=f;var M=k(o,o.nodes[0].id,!1).length;if(Object.keys(M).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(M[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=l[e].node[i];if(!K[n]||!K[n].length||M[e]>K[n][K[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return z.splice(n,1),"continue";for(var j=!0,I=0;j&&!L;){if(j=!1,r?u[d.id].degree<v[C.id].degree||u[d.id].inDegree<v[C.id].inDegree||u[d.id].outDegree<v[C.id].outDegree:u[d.id].degree<v[C.id].degree){L=!0;break}if(s[d[i]]<b[d[i]].length){L=!0;break}for(var w=o.nodes.length-1;w>=0;w--){var x=o.nodes[w],O=u[x.id].degree,D=u[x.id].inDegree,S=u[x.id].outDegree,P=x[i],T=ne(F,P,v,b),q=T.minPatternNodeLabelDegree,A=T.minPatternNodeLabelInDegree,R=T.minPatternNodeLabelOutDegree;if(r?O<q||D<A||S<R:O<q){if(s[x[i]]--,s[x[i]]<b[x[i]].length){L=!0;break}o.nodes.splice(w,1),u[x.id]=void 0,j=!0}}if(L||!j&&0!==I)break;for(var U=(y=f.length)-1;U>=0;U--){var G=f[U];if(!u[G.source]||!u[G.target]){f.splice(U,1);var _=G[a];if(h[_]--,u[G.source]&&(u[G.source].degree--,u[G.source].outDegree--),u[G.target]&&(u[G.target].degree--,u[G.target].inDegree--),E[_]&&h[_]<E[_].length){L=!0;break}j=!0}}I++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(z.splice(n,1),"continue"):void 0},oe=z.length-1;oe>=0&&"break"!==W(oe);oe--);var ie=z.length,ae=function(e){var t=z[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=z[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&z.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=z.length};for(oe=0;oe<=ie-1;oe++)ae(oe);return z}}};var ie="undefined"!=typeof self?self:{};ie.onmessage=function(e){var r=e.data,n=r._algorithmType,o=r.data;if(n)if("function"!=typeof t[n])ie.postMessage({_algorithmType:"FAILURE"});else{var i=t[n].apply(t,o);ie.postMessage({_algorithmType:"SUCCESS",data:i})}}})();\n//# sourceMappingURL=index.worker.js.map',"Worker",void 0,r.p+"index.worker.js")}const a=function(t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return new Promise((function(n,o){var a=new i;a.postMessage({_algorithmType:t,data:r}),a.onmessage=function(t){var r=t.data,i=r.data,d=r._algorithmType;e===d?n(i):o(),a.terminate()}}))}};var d=function(e){return a("detectCycle")(e)};const s={getAdjMatrixAsync:function(e,t){return a("getAdjMatrix").apply(void 0,[e,t])},connectedComponentAsync:function(e,t){return a("connectedComponent").apply(void 0,[e,t])},getDegreeAsync:function(e){return a("getDegree")(e)},getInDegreeAsync:function(e,t){return a("getInDegree")(e,t)},getOutDegreeAsync:function(e,t){return a("getOutDegree")(e,t)},detectCycleAsync:d,detectDirectedCycleAsync:d,detectAllCyclesAsync:function(e){return a("detectAllCycles")(e)},detectAllDirectedCycleAsync:function(e){return a("detectAllDirectedCycle")(e)},detectAllUndirectedCycleAsync:function(e){return a("detectAllUndirectedCycle")(e)},dijkstraAsync:function(e,t,r,n){return a("dijkstra").apply(void 0,[e,t,r,n])},findAllPathAsync:function(e,t,r,n){return a("findAllPath").apply(void 0,[e,t,r,n])},findShortestPathAsync:function(e,t,r,n,o){return a("findShortestPath").apply(void 0,[e,t,r,n,o])},floydWarshallAsync:function(e,t){return a("floydWarshall").apply(void 0,[e,t])},labelPropagationAsync:function(e,t,r,n){return void 0===n&&(n=1e3),a("labelPropagation")(e,t,r,n)},louvainAsync:function(e,t,r,n){return a("louvain")(e,t,r,n)},minimumSpanningTreeAsync:function(e,t,r){return a("minimumSpanningTree").apply(void 0,[e,t,r])},pageRankAsync:function(e,t,r){return a("pageRank").apply(void 0,[e,t,r])},getNeighborsAsync:function(e,t,r){return a("getNeighbors").apply(void 0,[e,t,r])},GADDIAsync:function(e,t,r,n,o,i,d){return void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===d&&(d="cluster"),a("GADDI").apply(void 0,[e,t,r,n,o,i,d])}}})(),n.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={458:e=>{e.exports=function(e,t,r,n){var o=self||window;try{try{var i;try{i=new o.Blob([e])}catch(t){(i=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(e),i=i.getBlob()}var a=o.URL||o.webkitURL,d=a.createObjectURL(i),s=new o[t](d,r);return a.revokeObjectURL(d),s}catch(n){return new o[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(e){if(!n)throw Error("Inline worker is not supported");return new o[t](n,r)}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.p="./dist";var n={};return(()=>{r.d(n,{default:()=>s});var e="SUCCESS",t=r(458),o=r.n(t);function i(){return o()('(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>oe,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>k,findAllPath:()=>x,findShortestPath:()=>w,floydWarshall:()=>O,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>g,labelPropagation:()=>D,louvain:()=>P,minimumSpanningTree:()=>R,pageRank:()=>U});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r,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 f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(a[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var g=p[l];s[g.id]||0===s[g.id]||c(g)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},g=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function v(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})&&v(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){v(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var M=Array.prototype;M.splice,M.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const j=function e(t){if("object"!=typeof t||null===t)return t;var r;if(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const k=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},g=0;g<l;g++)p();c[t]=[t];var v={};for(var b in h)h[b]!==1/0&&I(t,b,c,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function I(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=I(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}var w=function(e,t,r,n,o){var i=k(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},x=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h};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},D=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var g=0,v=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}};var S=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const P=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u=1,f={},h={};a.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},g=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,g+=e}})),l.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=S(a,c,l,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*g),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),a.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(N[d])N[d].weight+=o,N[d].count++;else{var s={source:i,target:a,weight:o,count:1};N[d]=s,L.push(s)}}));var M=[];return Object.keys(f).forEach((function(e){M.push(f[e])})),{clusters:M,clusterEdges:L}},C=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 T=function(e,t){return e-t};const q=function(){function e(e){void 0===e&&(e=T),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 F=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new q((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},A=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 C(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const R=function(e,t,r){return r?{prim:F,kruskal:A}[r](e,t):A(e,t)},U=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},g={},v=0;v<c;++v)p[E=(M=u[v]).id]=1/c,g[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,v=0;v<c;++v){var E=(M=u[v]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var m=d(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,v=0;v<c;++v){var M;n=p[E=(M=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}a-=1}return g};var G="-1",_=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},z=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),B=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 z(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 _(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 _(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),H=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new H(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 B(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),i!==G&&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}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);if(d){i.dfsEdgeList.push(new H(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,g=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},v=d.length-1;v>p&&"break"!==g(v);v--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new H(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};c=!1;var y=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!c)return!0;var M=e.findMinLabel(m);i.dfsEdgeList.push(new H(y,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(m[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)}},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(j(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new H(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 H(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new H(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,g=0;g<p;g++){var v=o[c[g]];n[i].nodes.push(v),l[v.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o,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],f=null==t?void 0:t.edges[0][n];e[n]===f&&(o===s&&i===u||o===u&&i===s)&&d++})),d)},$=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}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&(d.degree++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o},re=function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)},ne=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}};const oe=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=O(e,r),u=O(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,g=$(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),j=Y(M,L,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 B(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:j,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=I.length,x=[];I.forEach((function(e,t){x[t]={},Object.keys(j).forEach((function(r){var n=j[r],o=Z(n,e,i,a);x[t][r]=o}))}));var D=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(x,w,I),S=D.structure,P=D.structureCountMap,C=t.nodes[0],T=C[i],q=p[T],F={},A={},R={},U={},G={},_={};Object.keys(b).forEach((function(n,o){G[n]=[],r&&(_[n]=[]);var d=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[C.id+"-"+e.id];if(t&&G[n].push(t),d<t&&(d=t),u[C.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+C.id];o&&_[n].push(o)}})),G[n]=G[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),A=Y(u,N,t,A);var c=[];if(Object.keys(u).forEach((function(e){if(R[e])c.push(R[e]);else{var t=A[e];R[e]=Z(t,S,i,a),c.push(R[e])}})),c=c.sort((function(e,t){return t-e})),U[C.id+"-"+n]=c,n!==T)for(var p=function(t){var r=q[t],o=L[l[r.id].idx],d=o.nodeLabelCountMap[n],s=b[n].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>G[n][h]){u=!0;break}if(u)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:l[r.id].idx,end:l[e.id].idx,distance:t}})),j=Y(p,L,e,j);var g=[];Object.keys(p).forEach((function(e){if(P[e])g.push(P[e]);else{var t=j[e];P[e]=Z(t,S,i,a),g.push(P[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<c[h]){v=!0;break}return v?(q.splice(t,1),"continue"):void 0},g=q.length-1;g>=0;g--)p(g)}));var z=[];null==q||q.forEach((function(n){for(var d=l[n.id].idx,u=X(e.nodes,s[d],d,i,o).neighbors,h=!1,c=u.length-1;c>=0;c--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[c],g=p[i];if(b[g]&&b[g].length)if(G[g]&&G[g].length){var E=n.id+"-"+p.id,m=f[E],y=G[g].length-1;if(m>G[g][y])u.splice(c,1);else{if(r){var N=p.id+"-"+n.id,M=f[N];if(y=_[g].length-1,M>_[g][y]){u.splice(c,1);continue}}var k=P[E]?P[E]:re(e,n,p,l,m,L,S,i,a,P,j),I=C.id+"-"+g;if(k<U[I][U[I].length-1])u.splice(c,1);else{var w=ne(F,g,v,b),x=w.minPatternNodeLabelDegree;w.minPatternNodeLabelInDegree,w.minPatternNodeLabelOutDegree,l[p.id].degree<x&&u.splice(c,1)}}}else u.splice(c,1);else u.splice(c,1)}h||z.push({nodes:[n].concat(u)})}));var H=k(t,C.id,!1).length,K={};r?(Object.keys(H).forEach((function(e){var t=v[e].node[i];K[t]?K[t].push(H[e]):K[t]=[H[e]]})),Object.keys(K).forEach((function(e){K[e].sort((function(e,t){return e-t}))}))):K=G;for(var W=function(n){var o=z[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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var c=Object.keys(E).length,p=!1,g=0;g<c;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return z.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return z.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.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],c=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return z.splice(n,1),"continue";o.edges=f;var M=k(o,o.nodes[0].id,!1).length;if(Object.keys(M).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(M[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=l[e].node[i];if(!K[n]||!K[n].length||M[e]>K[n][K[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return z.splice(n,1),"continue";for(var j=!0,I=0;j&&!L;){if(j=!1,r?u[d.id].degree<v[C.id].degree||u[d.id].inDegree<v[C.id].inDegree||u[d.id].outDegree<v[C.id].outDegree:u[d.id].degree<v[C.id].degree){L=!0;break}if(s[d[i]]<b[d[i]].length){L=!0;break}for(var w=o.nodes.length-1;w>=0;w--){var x=o.nodes[w],O=u[x.id].degree,D=u[x.id].inDegree,S=u[x.id].outDegree,P=x[i],T=ne(F,P,v,b),q=T.minPatternNodeLabelDegree,A=T.minPatternNodeLabelInDegree,R=T.minPatternNodeLabelOutDegree;if(r?O<q||D<A||S<R:O<q){if(s[x[i]]--,s[x[i]]<b[x[i]].length){L=!0;break}o.nodes.splice(w,1),u[x.id]=void 0,j=!0}}if(L||!j&&0!==I)break;for(var U=(y=f.length)-1;U>=0;U--){var G=f[U];if(!u[G.source]||!u[G.target]){f.splice(U,1);var _=G[a];if(h[_]--,u[G.source]&&(u[G.source].degree--,u[G.source].outDegree--),u[G.target]&&(u[G.target].degree--,u[G.target].inDegree--),E[_]&&h[_]<E[_].length){L=!0;break}j=!0}}I++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(z.splice(n,1),"continue"):void 0},oe=z.length-1;oe>=0&&"break"!==W(oe);oe--);var ie=z.length,ae=function(e){var t=z[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=z[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&z.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=z.length};for(oe=0;oe<=ie-1;oe++)ae(oe);return z}}};var ie="undefined"!=typeof self?self:{};ie.onmessage=function(e){var r=e.data,n=r._algorithmType,o=r.data;if(n)if("function"!=typeof t[n])ie.postMessage({_algorithmType:"FAILURE"});else{var i=t[n].apply(t,o);ie.postMessage({_algorithmType:"SUCCESS",data:i})}}})();\n//# sourceMappingURL=index.worker.js.map',"Worker",void 0,r.p+"index.worker.js")}const a=function(t){return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return new Promise((function(n,o){var a=new i;a.postMessage({_algorithmType:t,data:r}),a.onmessage=function(t){var r=t.data,i=r.data,d=r._algorithmType;e===d?n(i):o(),a.terminate()}}))}};var d=function(e){return a("detectCycle")(e)};const s={getAdjMatrixAsync:function(e,t){return a("getAdjMatrix").apply(void 0,[e,t])},connectedComponentAsync:function(e,t){return a("connectedComponent").apply(void 0,[e,t])},getDegreeAsync:function(e){return a("getDegree")(e)},getInDegreeAsync:function(e,t){return a("getInDegree")(e,t)},getOutDegreeAsync:function(e,t){return a("getOutDegree")(e,t)},detectCycleAsync:d,detectDirectedCycleAsync:d,detectAllCyclesAsync:function(e){return a("detectAllCycles")(e)},detectAllDirectedCycleAsync:function(e){return a("detectAllDirectedCycle")(e)},detectAllUndirectedCycleAsync:function(e){return a("detectAllUndirectedCycle")(e)},dijkstraAsync:function(e,t,r,n){return a("dijkstra").apply(void 0,[e,t,r,n])},findAllPathAsync:function(e,t,r,n){return a("findAllPath").apply(void 0,[e,t,r,n])},findShortestPathAsync:function(e,t,r,n,o){return a("findShortestPath").apply(void 0,[e,t,r,n,o])},floydWarshallAsync:function(e,t){return a("floydWarshall").apply(void 0,[e,t])},labelPropagationAsync:function(e,t,r,n){return void 0===n&&(n=1e3),a("labelPropagation")(e,t,r,n)},louvainAsync:function(e,t,r,n){return a("louvain")(e,t,r,n)},minimumSpanningTreeAsync:function(e,t,r){return a("minimumSpanningTree").apply(void 0,[e,t,r])},pageRankAsync:function(e,t,r){return a("pageRank").apply(void 0,[e,t,r])},getNeighborsAsync:function(e,t,r){return a("getNeighbors").apply(void 0,[e,t,r])},GADDIAsync:function(e,t,r,n,o,i,d){return void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===d&&(d="cluster"),a("GADDI").apply(void 0,[e,t,r,n,o,i,d])}}})(),n.default})()})); | ||
//# sourceMappingURL=async.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Algorithm=t():e.Algorithm=t()}(this,(function(){return(()=>{"use strict";var e={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:()=>_});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,d=i[r],a=i[n];!d&&0!==d||!a&&0!==a||(o[d][a]=1,t||(o[a][d]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),d=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 a=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};var f=function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],d={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),d[e.id]=!0;for(var t=a(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])d[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(d[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var g=p[l];s[g.id]||0===s[g.id]||c(g)}return f};function h(e,t){return t?f(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],d={},s=[],u=function(e){s.push(e),d[e.id]=!0;for(var t=a(e.id,o),n=function(e){var n=t[e];if(!d[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!d[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;function p(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;a(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 g(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 v=function(e,t,r){var n,o;void 0===r&&(r=!0);for(var i=[],d=0,s=h(e,!1);d<s.length;d++){var u=s[d];if(u.length)for(var f=u[0],c=f.id,l=[f],p=((n={})[c]=f,n),g=((o={})[c]=new Set,o);l.length>0;)for(var v=l.pop(),b=v.id,E=a(b,e.edges),m=function(n){var o,d=E[n],a=e.nodes.find((function(e){return e.id===d}));if(d===b)i.push(((o={})[d]=v,o));else if(d in g){if(!g[b].has(a)){for(var s=!0,u=[a,v],f=p[b];g[d].size&&!g[d].has(f)&&(u.push(f),f!==p[f.id]);)f=p[f.id];if(u.push(f),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 h={},c=1;c<u.length;c+=1)h[u[c-1].id]=u[c];u.length&&(h[u[u.length-1].id]=u[0]),i.push(h)}g[d].add(v)}}else p[d]=v,l.push(a),g[d]=new Set([v])},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=[],d=[],s={},u={},h=function(e,a,u){var f=!1;if(t&&!1===r&&t.indexOf(e.id)>-1)return f;n.push(e),o.add(e);for(var c=u[e.id],l=0;l<c.length;l+=1)if((v=s[c[l]])===a){for(var p={},g=1;g<n.length;g+=1)p[n[g-1].id]=n[g];n.length&&(p[n[n.length-1].id]=n[0]),d.push(p),f=!0}else o.has(v)||h(v,a,u)&&(f=!0);if(f)!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<c.length;l+=1){var v=s[c[l]];i[v.id].has(e)||i[v.id].add(e)}return n.pop(),f},c=e.nodes,l=void 0===c?[]:c,p=0;p<l.length;p+=1){var g=l[p],v=g.id;u[v]=p,s[p]=g}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,f=0;f<n.length;f+=1)for(var h=n[f],c=0;c<h.length;c++){var l=u[h[c].id];l<s&&(s=l,i=f)}var p=n[i],g=[];for(f=0;f<p.length;f+=1){var v=p[f];g[v.id]=[];for(var b=0,E=a(v.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!==v.id||!1===r&&t.indexOf(v.id)>-1?g[v.id].push(u[m]):d.push(((o={})[v.id]=v,o))}}return{component:p,adjList:g,minIdx:s}},m=0;m<l.length;){var y=l.filter((function(e){return u[e.id]>=m})),L=f({nodes:y,edges:e.edges}).filter((function(e){return e.length>1}));if(0===L.length)break;var N=E(L),k=N.minIdx,x=N.adjList,j=N.component;if(!(j.length>1))break;j.forEach((function(e){i[e.id]=new Set}));var M=s[k];if(t&&r&&-1===t.indexOf(M.id))return d;h(M,M,x),m=k+1}return d};const E=function(e){var t=null,r=e.nodes,n={},o={},i={},d={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var a={enter:function(e){var r=e.current,d=e.previous;if(i[r]){t={};for(var a=r,s=d;s!==r;)t[a]=s,a=s,s=n[s];t[a]=s}else i[r]=r,delete o[r],n[r]=d},leave:function(e){var t=e.current;d[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!d[r]}};Object.keys(o).length;)g(e,Object.keys(o)[0],a);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=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(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const j=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,d=e.edges,a=void 0===d?[]:d,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var d=t[i].id;!r[d]&&e[d]<=o&&(o=e[d],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,a):s(o,a)).forEach((function(e){var r=e.target,i=e.source,d=r===o?i:r,a=n&&e[n]?e[n]:1;h[d]>h[t.id]+a?(h[d]=h[t.id]+a,c[d]=[t.id]):h[d]===h[t.id]+a&&c[d].push(t.id)}))},g=0;g<l;g++)p();c[t]=[t];var v={};for(var b in h)h[b]!==1/0&&M(t,b,c,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function M(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,d=r[t];i<d.length;i++){var a=M(e,d[i],r,n);if(!a)return;for(var s=0,u=a;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}const I=function(e,t){for(var n=r(e,t),o=[],i=n.length,d=0;d<i;d+=1){o[d]=[];for(var a=0;a<i;a+=1)d===a?o[d][a]=0:0!==n[d][a]&&n[d][a]?o[d][a]=n[d][a]:o[d][a]=1/0}for(var s=0;s<i;s+=1)for(d=0;d<i;d+=1)for(a=0;a<i;a+=1)o[d][a]>o[d][s]+o[s][a]&&(o[d][a]=o[d][s]+o[s][a]);return o};var w=function(e,t,r,n){for(var o=t.length,i=2*n,d=0,a=0;a<o;a++)for(var s=e[a].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(d+=(t[a][u]||0)-(r[a]||0)*(r[u]||0)/i);return d*(1/i)};const O=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 D=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=D),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,d=void 0===i?[]:i;if(0===o.length)return r;var a=o[0],u=new Set;u.add(a);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(a.id,d).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,d).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,d).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,d=void 0===i?[]:i;if(0===o.length)return r;var a=d.map((function(e){return e}));t&&a.sort((function(e,t){return e.weight-t.weight}));for(var s=new O(o.map((function(e){return e.id})));a.length>0;){var u=a.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};var A="-1",T=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},q=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=A),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),F=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 q(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 T(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 T(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),R=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||A,edgeLabel:n||"-1",nodeLabel2:o||A}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),G=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 R(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 F(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,d=o.edgeLabel,a=o.nodeLabel2;i!==A&&r.addNode(t,i),a!==A&&r.addNode(n,a),i!==A&&a!==i&&r.addEdge(void 0,t,n,d)})),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}(),U=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}(),z=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,d=e.maxNodeNum,a=void 0===d?4:d,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new G,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=a,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,d=i.length,a=0;a<d;a++){var s=i[a];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,d=e.nodeMap[i].edges,a=d.length,s=0;s<a;s++){var u=d[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,d=i[t.to].label,a=i[t.from].edges,s=a.length,u=0;u<s;u++){var f=a[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&d<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,d=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&d<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:d}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:d}})),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 G,d={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;d[i]||(d[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var a={graphId:n.id,edge:e,preNode:null};d[i].projected.push(a)}))}));var a=this.findMinLabel(d);if(a){i.dfsEdgeList.push(new R(0,1,a.nodeLabel1,a.edgeLabel,a.nodeLabel2));var s=function(d){for(var a=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[a[0]].toNode,h={},c=!1,l=0,p=r?-1:0,g=function(t){if(c)return"break";d.forEach((function(r){var o=new U(r),d=e.findBackwardEdge(n,o.edges[a[t]],o.edges[a[0]],o);d&&(h[d.label]||(h[d.label]={projected:[],edgeLabel:d.label}),h[d.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[a[t]].fromNode,c=!0)}))},v=a.length-1;v>p&&"break"!==g(v);v--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new R(f,l,A,b.edgeLabel,A));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};c=!1;var y=0;d.forEach((function(t){var r=new U(t),i=e.findForwardPureEdges(n,r.edges[a[0]],u,r);i.length>0&&(c=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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=a.length,N=function(t){if(c)return"break";var r=a[t];d.forEach((function(t){var d=new U(t),a=e.findForwardRmpathEdges(n,d.edges[r],u,d);a.length>0&&(c=!0,y=i.dfsEdgeList[r].fromNode,a.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!c)return!0;var k=e.findMinLabel(m);i.dfsEdgeList.push(new R(y,f+1,A,k.edgeLabel,k.nodeLabel2));var x=i.dfsEdgeList.length-1;return t.dfsEdgeList[x]===i.dfsEdgeList[x]&&s(m[k.edgeLabel+"-"+k.nodeLabel2].projected)},u=a.nodeLabel1+"-"+a.edgeLabel+"-"+a.nodeLabel2;return s(d[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,d={},a={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new U(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;a[l]||(a[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),a[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;d[r]||(d[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),d[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;d[i]||(d[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),d[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(a).forEach((function(e){var r=a[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new R(o,n,"-1",i,"-1")),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(d).forEach((function(e){var r=d[e],n=r.fromNodeId,i=r.edgeLabel,a=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new R(n,o+1,A,i,a)),t.subGraphMining(d[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={},d={},a={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!d[f]){var h=o[u]||0;h++,o[u]=h}d[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var d=o;o=n,n=d}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}a[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],d=t.label+"-"+e.label+"-"+o.label;r[d]||(r[d]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var a={graphId:n,edge:e,preNode:null};r[d].projected.push(a)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,d=n.edgeLabel,a=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new R(0,1,i,d,a)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),B="cluster";var H=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(K(i,e,t,r,n))})),o},K=function(e,t,r,n,o){var i=[r],d=[],a={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),d.push(e[s]);var u=e[s][n];a[u]?(a[u].count++,a[u].dists.push(t)):a[u]={count:1,dists:[t]}}})),Object.keys(a).forEach((function(e){a[e].dists=a[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:d,neighborNum:i.length-1,nodeLabelCountMap:a}},W=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var d,a;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(d=t[s.start])||void 0===d?void 0:d.nodeIdxs,f=null===(a=t[s.end])||void 0===a?void 0:a.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,g=0;g<p;g++){var v=o[c[g]];n[i].nodes.push(v),l[v.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},J=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var d=o[e.source][r],a=o[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],f=null==t?void 0:t.edges[0][n];e[n]===f&&(d===s&&a===u||d===u&&a===s)&&i++})),i},Q=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}},V=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var d=e[t];o[d]||(o[d]=[]),o[d].push(e);var a=r[e.source];a&&(a.degree++,a.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},X=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var d=r?0:i+1,a=e[i].id,s=d;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[a+"-"+u]=f,r||(o[u+"-"+a]=f)}})),o},Y=function(e,t,r,n,o,i,d,a,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=W(p,i,e,f))[c]}return J(l,d,a,s)},Z=function(e,t,r,n){var o,i,d,a=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===(d=e[t])||void 0===d?void 0:d.outDegree;return void 0===e[t]&&(a=1/0,s=1/0,u=1/0,n[t].forEach((function(e){var t=r[e.id].degree;a>t&&(a=t);var n=r[e.id].inDegree;s>n&&(s=n);var o=r[e.id].outDegree;u>o&&(u=o)})),e[t]={degree:a,inDegree:s,outDegree:u}),{minPatternNodeLabelDegree:a,minPatternNodeLabelInDegree:s,minPatternNodeLabelOutDegree:u}};var $=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 _={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 d,s=e.edges,u=void 0===s?[]:s;i.enqueue(t);for(var f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),a(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()},connectedComponent:h,getDegree:l,getInDegree:function(e,t){return c(e)[t]?c(e)[t].inDegree:0},getOutDegree:function(e,t){return c(e)[t]?c(e)[t].outDegree:0},detectCycle:E,detectDirectedCycle:E,detectAllCycles:function(e,t,r,n){return void 0===n&&(n=!0),t?b(e,r,n):v(e,r,n)},detectAllDirectedCycle:b,detectAllUndirectedCycle:v,depthFirstSearch:g,dijkstra:j,findAllPath:function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,d=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?a(t,d,"target"):a(t,d);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?a(p,d,"target"):a(p,d),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h},findShortestPath:function(e,t,r,n,o){var i=j(e,t,n,o),d=i.length,a=i.path,s=i.allPath;return{length:d[r],path:a[r],allPath:s[r]}},floydWarshall:I,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,d=void 0===i?[]:i,a=e.edges,s=void 0===a?[]:a,f={},h={};d.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=d[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=d[t].id;p[n][o]=e}})),l.push(r)}));for(var g=0,v=function(){var e=!1;if(d.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var d=f[t.clusterId],a=d.nodes.indexOf(t);d.nodes.splice(a,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,d=h[r].node.clusterId,a=i+"---"+d;if(E[a])E[a].weight+=o,E[a].count++;else{var s={source:i,target:d,weight:o,count:1};E[a]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}},louvain:function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,d=void 0===i?[]:i,a=e.edges,s=void 0===a?[]:a,u=1,f={},h={};d.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},g=0;c.forEach((function(e,t){var r=0,n=d[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=d[t].id;p[n][o]=e,g+=e}})),l.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=w(d,c,l,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,d=h[o].node.clusterId,a=h[i].node.clusterId;(d===e&&a!==e||a===e&&d!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),d.forEach((function(e,t){var r,o=f[e.clusterId],i=0,d=l[t]/(2*g),a=0;o.nodes.forEach((function(e){var r=h[e.id].idx;a+=c[t][r]||0}));var u=a-o.sumTot*d,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var a=f[o],s=a.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-a.sumTot*d-u;p>i&&(i=p,r=a)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,d=h[o].node.clusterId;(i===r.id&&d!==r.id||d===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&d!==b||d===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),d.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,d=h[r].node.clusterId,a=i+"---"+d;if(N[a])N[a].weight+=o,N[a].count++;else{var s={source:i,target:d,weight:o,count:1};N[a]=s,L.push(s)}}));var k=[];return Object.keys(f).forEach((function(e){k.push(f[e])})),{clusters:k,clusterEdges:L}},minimumSpanningTree:function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(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,d=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},g={},v=0;v<c;++v)p[E=(k=u[v]).id]=1/c,g[E]=1/c;for(var b=l(e);d>0&&o>t;){for(i=0,v=0;v<c;++v){var E=(k=u[v]).id;if(n=0,0===b[k.id].inDegree)p[E]=0;else{for(var m=a(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,v=0;v<c;++v){var k;n=p[E=(k=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}d-=1}return g},getNeighbors:a,Stack:$,GADDI:function(e,t,r,n,o,i,d){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===d&&(d="cluster"),e&&e.nodes){var a=e.nodes.length;if(a){var s=I(e,r),u=I(t,r),f=X(e.nodes,s,r),h=X(t.nodes,u,r),c=Q(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,g=Q(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;V(e.edges,d,l);var E=V(t.edges,d,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=H(e,s,i,n),N=H(t,u,i,n),k=function(e,t,r,n,o){var i=Math.ceil(r/t),d={},a=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(d[n+"-"+c]||d[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(d[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++a>=r))return d;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),d}(0,a,Math.min(100,a*(a-1)/2),N,s),x=W(k,L,e),M=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?B:o,d=e.edgeLabelProp,a=void 0===d?B:d,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,d){var a=e[i],s=new F(d,!0,t),u={};a.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),a.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,a),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new z({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,a)}({graphs:x,nodeLabelProp:i,edgeLabelProp:d,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=M.length,O=[];M.forEach((function(e,t){O[t]={},Object.keys(x).forEach((function(r){var n=x[r],o=J(n,e,i,d);O[t][r]=o}))}));var D=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]})),d=[];i.forEach((function(e,t){d[t%10]||(d[t%10]={graphs:[],totalCount:0,aveCount:0}),d[t%10].graphs.push(e),d[t%10].totalCount+=r[e]}));var a=0,s=[];d.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]))}))})),a+=n/=o*(o-1)/2})),a/=d.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-a;n<f&&(n=f,o=t)},d=0;d<t;d++)i(d);return{structure:r[o],structureCountMap:e[o]}}(O,w,M),S=D.structure,C=D.structureCountMap,P=t.nodes[0],A=P[i],T=p[A],q={},R={},G={},U={},$={},_={};Object.keys(b).forEach((function(n,o){$[n]=[],r&&(_[n]=[]);var a=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[P.id+"-"+e.id];if(t&&$[n].push(t),a<t&&(a=t),u[P.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+P.id];o&&_[n].push(o)}})),$[n]=$[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),R=W(u,N,t,R);var c=[];if(Object.keys(u).forEach((function(e){if(G[e])c.push(G[e]);else{var t=R[e];G[e]=J(t,S,i,d),c.push(G[e])}})),c=c.sort((function(e,t){return t-e})),U[P.id+"-"+n]=c,n!==A)for(var p=function(t){var r=T[t],o=L[l[r.id].idx],a=o.nodeLabelCountMap[n],s=b[n].length;if(!a||a.count<s)return T.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(a.dists[h]>$[n][h]){u=!0;break}if(u)return T.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:l[r.id].idx,end:l[e.id].idx,distance:t}})),x=W(p,L,e,x);var g=[];Object.keys(p).forEach((function(e){if(C[e])g.push(C[e]);else{var t=x[e];C[e]=J(t,S,i,d),g.push(C[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<c[h]){v=!0;break}return v?(T.splice(t,1),"continue"):void 0},g=T.length-1;g>=0;g--)p(g)}));var ee=[];null==T||T.forEach((function(n){for(var a=l[n.id].idx,u=K(e.nodes,s[a],a,i,o).neighbors,h=!1,c=u.length-1;c>=0;c--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[c],g=p[i];if(b[g]&&b[g].length)if($[g]&&$[g].length){var E=n.id+"-"+p.id,m=f[E],y=$[g].length-1;if(m>$[g][y])u.splice(c,1);else{if(r){var N=p.id+"-"+n.id,k=f[N];if(y=_[g].length-1,k>_[g][y]){u.splice(c,1);continue}}var j=C[E]?C[E]:Y(e,n,p,l,m,L,S,i,d,C,x),M=P.id+"-"+g;if(j<U[M][U[M].length-1])u.splice(c,1);else{var I=Z(q,g,v,b),w=I.minPatternNodeLabelDegree;I.minPatternNodeLabelInDegree,I.minPatternNodeLabelOutDegree,l[p.id].degree<w&&u.splice(c,1)}}}else u.splice(c,1);else u.splice(c,1)}h||ee.push({nodes:[n].concat(u)})}));var te=j(t,P.id,!1).length,re={};r?(Object.keys(te).forEach((function(e){var t=v[e].node[i];re[t]?re[t].push(te[e]):re[t]=[te[e]]})),Object.keys(re).forEach((function(e){re[e].sort((function(e,t){return e-t}))}))):re=$;for(var ne=function(n){var o=ee[n],a=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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[d]]?h[e[d]]++:h[e[d]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var c=Object.keys(E).length,p=!1,g=0;g<c;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return ee.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return ee.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[d],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue");var a=u[t.source].node[i],s=u[t.target].node[i],c=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===a&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==a||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return ee.splice(n,1),"continue";o.edges=f;var k=j(o,o.nodes[0].id,!1).length;if(Object.keys(k).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(k[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=l[e].node[i];if(!re[n]||!re[n].length||k[e]>re[n][re[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return ee.splice(n,1),"continue";for(var x=!0,M=0;x&&!L;){if(x=!1,r?u[a.id].degree<v[P.id].degree||u[a.id].inDegree<v[P.id].inDegree||u[a.id].outDegree<v[P.id].outDegree:u[a.id].degree<v[P.id].degree){L=!0;break}if(s[a[i]]<b[a[i]].length){L=!0;break}for(var I=o.nodes.length-1;I>=0;I--){var w=o.nodes[I],O=u[w.id].degree,D=u[w.id].inDegree,S=u[w.id].outDegree,C=w[i],A=Z(q,C,v,b),T=A.minPatternNodeLabelDegree,F=A.minPatternNodeLabelInDegree,R=A.minPatternNodeLabelOutDegree;if(r?O<T||D<F||S<R:O<T){if(s[w[i]]--,s[w[i]]<b[w[i]].length){L=!0;break}o.nodes.splice(I,1),u[w.id]=void 0,x=!0}}if(L||!x&&0!==M)break;for(var G=(y=f.length)-1;G>=0;G--){var U=f[G];if(!u[U.source]||!u[U.target]){f.splice(G,1);var z=U[d];if(h[z]--,u[U.source]&&(u[U.source].degree--,u[U.source].outDegree--),u[U.target]&&(u[U.target].degree--,u[U.target].inDegree--),E[z]&&h[z]<E[z].length){L=!0;break}x=!0}}M++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(ee.splice(n,1),"continue"):void 0},oe=ee.length-1;oe>=0&&"break"!==ne(oe);oe--);var ie=ee.length,de=function(e){var t=ee[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=ee[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&ee.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=ee.length};for(oe=0;oe<=ie-1;oe++)de(oe);return ee}}}};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:()=>_});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,d=i[r],a=i[n];!d&&0!==d||!a&&0!==a||(o[d][a]=1,t||(o[a][d]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),d=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 a=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};var f=function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],d={},s={},u={},f=[],h=0,l=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),d[e.id]=!0;for(var t=a(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])d[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&&l(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},c=0;c<t.length;c++)n(c);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(d[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},c=0,p=r;c<p.length;c++){var g=p[c];s[g.id]||0===s[g.id]||l(g)}return f};function h(e,t){return t?f(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],d={},s=[],u=function(e){s.push(e),d[e.id]=!0;for(var t=a(e.id,o),n=function(e){var n=t[e];if(!d[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!d[h.id]){u(h);for(var l=[];s.length>0;)l.push(s.pop());i.push(l)}}return i}(e)}var l=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 c=l;function p(e,t,r,n){n.enter({current:t,previous:r});var o=e.edges;a(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 g(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 v=function(e,t,r){var n,o;void 0===r&&(r=!0);for(var i=[],d=0,s=h(e,!1);d<s.length;d++){var u=s[d];if(u.length)for(var f=u[0],l=f.id,c=[f],p=((n={})[l]=f,n),g=((o={})[l]=new Set,o);c.length>0;)for(var v=c.pop(),b=v.id,E=a(b,e.edges),m=function(n){var o,d=E[n],a=e.nodes.find((function(e){return e.id===d}));if(d===b)i.push(((o={})[d]=v,o));else if(d in g){if(!g[b].has(a)){for(var s=!0,u=[a,v],f=p[b];g[d].size&&!g[d].has(f)&&(u.push(f),f!==p[f.id]);)f=p[f.id];if(u.push(f),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 h={},l=1;l<u.length;l+=1)h[u[l-1].id]=u[l];u.length&&(h[u[u.length-1].id]=u[0]),i.push(h)}g[d].add(v)}}else p[d]=v,c.push(a),g[d]=new Set([v])},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=[],d=[],s={},u={},h=function(e,a,u){var f=!1;if(t&&!1===r&&t.indexOf(e.id)>-1)return f;n.push(e),o.add(e);for(var l=u[e.id],c=0;c<l.length;c+=1)if((v=s[l[c]])===a){for(var p={},g=1;g<n.length;g+=1)p[n[g-1].id]=n[g];n.length&&(p[n[n.length-1].id]=n[0]),d.push(p),f=!0}else o.has(v)||h(v,a,u)&&(f=!0);if(f)!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(c=0;c<l.length;c+=1){var v=s[l[c]];i[v.id].has(e)||i[v.id].add(e)}return n.pop(),f},l=e.nodes,c=void 0===l?[]:l,p=0;p<c.length;p+=1){var g=c[p],v=g.id;u[v]=p,s[p]=g}if(t&&r){var b=function(e){var r=t[e];u[c[e].id]=u[r],u[r]=0,s[0]=c.find((function(e){return e.id===r})),s[u[c[e].id]]=c[e]};for(p=0;p<t.length;p++)b(p)}for(var E=function(n){for(var o,i,s=1/0,f=0;f<n.length;f+=1)for(var h=n[f],l=0;l<h.length;l++){var c=u[h[l].id];c<s&&(s=c,i=f)}var p=n[i],g=[];for(f=0;f<p.length;f+=1){var v=p[f];g[v.id]=[];for(var b=0,E=a(v.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!==v.id||!1===r&&t.indexOf(v.id)>-1?g[v.id].push(u[m]):d.push(((o={})[v.id]=v,o))}}return{component:p,adjList:g,minIdx:s}},m=0;m<c.length;){var y=c.filter((function(e){return u[e.id]>=m})),L=f({nodes:y,edges:e.edges}).filter((function(e){return e.length>1}));if(0===L.length)break;var N=E(L),k=N.minIdx,x=N.adjList,j=N.component;if(!(j.length>1))break;j.forEach((function(e){i[e.id]=new Set}));var M=s[k];if(t&&r&&-1===t.indexOf(M.id))return d;h(M,M,x),m=k+1}return d};const E=function(e){var t=null,r=e.nodes,n={},o={},i={},d={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var a={enter:function(e){var r=e.current,d=e.previous;if(i[r]){t={};for(var a=r,s=d;s!==r;)t[a]=s,a=s,s=n[s];t[a]=s}else i[r]=r,delete o[r],n[r]=d},leave:function(e){var t=e.current;d[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!d[r]}};Object.keys(o).length;)g(e,Object.keys(o)[0],a);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=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(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const j=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,d=e.edges,a=void 0===d?[]:d,u=[],f={},h={},l={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var c=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var d=t[i].id;!r[d]&&e[d]<=o&&(o=e[d],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,a):s(o,a)).forEach((function(e){var r=e.target,i=e.source,d=r===o?i:r,a=n&&e[n]?e[n]:1;h[d]>h[t.id]+a?(h[d]=h[t.id]+a,l[d]=[t.id]):h[d]===h[t.id]+a&&l[d].push(t.id)}))},g=0;g<c;g++)p();l[t]=[t];var v={};for(var b in h)h[b]!==1/0&&M(t,b,l,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function M(e,t,r,n){if(e===t)return[e];if(n[t])return n[t];for(var o=[],i=0,d=r[t];i<d.length;i++){var a=M(e,d[i],r,n);if(!a)return;for(var s=0,u=a;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}const I=function(e,t){for(var n=r(e,t),o=[],i=n.length,d=0;d<i;d+=1){o[d]=[];for(var a=0;a<i;a+=1)d===a?o[d][a]=0:0!==n[d][a]&&n[d][a]?o[d][a]=n[d][a]:o[d][a]=1/0}for(var s=0;s<i;s+=1)for(d=0;d<i;d+=1)for(a=0;a<i;a+=1)o[d][a]>o[d][s]+o[s][a]&&(o[d][a]=o[d][s]+o[s][a]);return o};var w=function(e,t,r,n){for(var o=t.length,i=2*n,d=0,a=0;a<o;a++)for(var s=e[a].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(d+=(t[a][u]||0)-(r[a]||0)*(r[u]||0)/i);return d*(1/i)};const O=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 D=function(e,t){return e-t};const S=function(){function e(e){void 0===e&&(e=D),this.compareFn=e,this.list=[]}return e.prototype.getLeft=function(e){return 2*e+1},e.prototype.getRight=function(e){return 2*e+2},e.prototype.getParent=function(e){return 0===e?null:Math.floor((e-1)/2)},e.prototype.isEmpty=function(){return this.list.length<=0},e.prototype.top=function(){return this.isEmpty()?void 0:this.list[0]},e.prototype.delMin=function(){var e=this.top(),t=this.list.pop();return this.list.length>0&&(this.list[0]=t,this.moveDown(0)),e},e.prototype.insert=function(e){if(null!==e){this.list.push(e);var t=this.list.length-1;return this.moveUp(t),!0}return!1},e.prototype.moveUp=function(e){for(var t=this.getParent(e);e&&e>0&&this.compareFn(this.list[t],this.list[e])>0;){var r=this.list[t];this.list[t]=this.list[e],this.list[e]=r,e=t,t=this.getParent(e)}},e.prototype.moveDown=function(e){var t,r=e,n=this.getLeft(e),o=this.getRight(e),i=this.list.length;null!==n&&n<i&&this.compareFn(this.list[r],this.list[n])>0?r=n:null!==o&&o<i&&this.compareFn(this.list[r],this.list[o])>0&&(r=o),e!==r&&(t=[this.list[r],this.list[e]],this.list[e]=t[0],this.list[r]=t[1],this.moveDown(r))},e}();var C=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,d=void 0===i?[]:i;if(0===o.length)return r;var a=o[0],u=new Set;u.add(a);var f=new S((function(e,r){return t?e.weight-r.weight:0}));for(s(a.id,d).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),l=h.source,c=h.target;u.has(l)&&u.has(c)||(r.push(h),u.has(l)||(u.add(l),s(l,d).forEach((function(e){f.insert(e)}))),u.has(c)||(u.add(c),s(c,d).forEach((function(e){f.insert(e)}))))}return r},P=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,d=void 0===i?[]:i;if(0===o.length)return r;var a=d.map((function(e){return e}));t&&a.sort((function(e,t){return e.weight-t.weight}));for(var s=new O(o.map((function(e){return e.id})));a.length>0;){var u=a.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};var A="-1",T=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},q=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=A),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),F=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 q(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 T(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 T(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),R=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||A,edgeLabel:n||"-1",nodeLabel2:o||A}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),G=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 R(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 F(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,d=o.edgeLabel,a=o.nodeLabel2;i!==A&&r.addNode(t,i),a!==A&&r.addNode(n,a),i!==A&&a!==i&&r.addEdge(void 0,t,n,d)})),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}(),U=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}(),z=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,d=e.maxNodeNum,a=void 0===d?4:d,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,l=e.verbose,c=void 0!==l&&l;this.graphs=t,this.dfsCode=new G,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=a,this.minNodeNum=i,this.verbose=c,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,d=i.length,a=0;a<d;a++){var s=i[a];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,d=e.nodeMap[i].edges,a=d.length,s=0;s<a;s++){var u=d[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,d=i[t.to].label,a=i[t.from].edges,s=a.length,u=0;u<s;u++){var f=a[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&d<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,d=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&d<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:d}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:d}})),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 G,d={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;d[i]||(d[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var a={graphId:n.id,edge:e,preNode:null};d[i].projected.push(a)}))}));var a=this.findMinLabel(d);if(a){i.dfsEdgeList.push(new R(0,1,a.nodeLabel1,a.edgeLabel,a.nodeLabel2));var s=function(d){for(var a=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[a[0]].toNode,h={},l=!1,c=0,p=r?-1:0,g=function(t){if(l)return"break";d.forEach((function(r){var o=new U(r),d=e.findBackwardEdge(n,o.edges[a[t]],o.edges[a[0]],o);d&&(h[d.label]||(h[d.label]={projected:[],edgeLabel:d.label}),h[d.label].projected.push({graphId:n.id,edge:h,preNode:r}),c=i.dfsEdgeList[a[t]].fromNode,l=!0)}))},v=a.length-1;v>p&&"break"!==g(v);v--);if(l){var b=e.findMinLabel(h);i.dfsEdgeList.push(new R(f,c,A,b.edgeLabel,A));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};l=!1;var y=0;d.forEach((function(t){var r=new U(t),i=e.findForwardPureEdges(n,r.edges[a[0]],u,r);i.length>0&&(l=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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=a.length,N=function(t){if(l)return"break";var r=a[t];d.forEach((function(t){var d=new U(t),a=e.findForwardRmpathEdges(n,d.edges[r],u,d);a.length>0&&(l=!0,y=i.dfsEdgeList[r].fromNode,a.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!l)return!0;var k=e.findMinLabel(m);i.dfsEdgeList.push(new R(y,f+1,A,k.edgeLabel,k.nodeLabel2));var x=i.dfsEdgeList.length-1;return t.dfsEdgeList[x]===i.dfsEdgeList[x]&&s(m[k.edgeLabel+"-"+k.nodeLabel2].projected)},u=a.nodeLabel1+"-"+a.edgeLabel+"-"+a.nodeLabel2;return s(d[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,d={},a={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new U(e),h=n.length-1;h>=0;h--){var l=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(l){var c=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+l.label;a[c]||(a[c]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:l.label}),a[c].projected.push({graphId:e.graphId,edge:l,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;d[r]||(d[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),d[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;d[i]||(d[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),d[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(a).forEach((function(e){var r=a[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new R(o,n,"-1",i,"-1")),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()})),Object.keys(d).forEach((function(e){var r=d[e],n=r.fromNodeId,i=r.edgeLabel,a=r.nodeLabel2;t.dfsCode.dfsEdgeList.push(new R(n,o+1,A,i,a)),t.subGraphMining(d[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={},d={},a={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!d[f]){var h=o[u]||0;h++,o[u]=h}d[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var d=o;o=n,n=d}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,l=n+"-"+f+"-"+o;if(!i[l]){var c=i[l]||0;c++,i[l]=c}a[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],d=t.label+"-"+e.label+"-"+o.label;r[d]||(r[d]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var a={graphId:n,edge:e,preNode:null};r[d].projected.push(a)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,d=n.edgeLabel,a=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new R(0,1,i,d,a)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),B="cluster";var H=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(K(i,e,t,r,n))})),o},K=function(e,t,r,n,o){var i=[r],d=[],a={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),d.push(e[s]);var u=e[s][n];a[u]?(a[u].count++,a[u].dists.push(t)):a[u]={count:1,dists:[t]}}})),Object.keys(a).forEach((function(e){a[e].dists=a[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:d,neighborNum:i.length-1,nodeLabelCountMap:a}},W=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var d,a;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(d=t[s.start])||void 0===d?void 0:d.nodeIdxs,f=null===(a=t[s.end])||void 0===a?void 0:a.nodeIdxs;if(u&&f){var h=new Set(f),l=u.filter((function(e){return h.has(e)}));if(l&&l.length){for(var c={},p=l.length,g=0;g<p;g++){var v=o[l[g]];n[i].nodes.push(v),c[v.id]=!0}r.edges.forEach((function(e){c[e.source]&&c[e.target]&&n[i].edges.push(e)}))}}}})),n},J=function(e,t,r,n){var o,i,d={};e.nodes.forEach((function(e){d[e.id]=e}));var a=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=d[e.source][r],i=d[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],f=null==t?void 0:t.edges[0][n];e[n]===f&&(o===s&&i===u||o===u&&i===s)&&a++})),a)},Q=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}},V=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var d=e[t];o[d]||(o[d]=[]),o[d].push(e);var a=r[e.source];a&&(a.degree++,a.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},X=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var d=r?0:i+1,a=e[i].id,s=d;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[a+"-"+u]=f,r||(o[u+"-"+a]=f)}})),o},Y=function(e,t,r,n,o,i,d,a,s,u,f){var h,l=t.id+"-"+r.id;if(u&&u[l])return u[l];var c=f?f[l]:void 0;if(!c){var p=((h={})[l]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);c=(f=W(p,i,e,f))[l]}return J(c,d,a,s)},Z=function(e,t,r,n){var o,i,d,a=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===(d=e[t])||void 0===d?void 0:d.outDegree;return void 0===e[t]&&(a=1/0,s=1/0,u=1/0,n[t].forEach((function(e){var t=r[e.id].degree;a>t&&(a=t);var n=r[e.id].inDegree;s>n&&(s=n);var o=r[e.id].outDegree;u>o&&(u=o)})),e[t]={degree:a,inDegree:s,outDegree:u}),{minPatternNodeLabelDegree:a,minPatternNodeLabelInDegree:s,minPatternNodeLabelOutDegree:u}};var $=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 _={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 d,s=e.edges,u=void 0===s?[]:s;i.enqueue(t);for(var f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),a(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()},connectedComponent:h,getDegree:c,getInDegree:function(e,t){return l(e)[t]?l(e)[t].inDegree:0},getOutDegree:function(e,t){return l(e)[t]?l(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):v(e,r,n)},detectAllDirectedCycle:b,detectAllUndirectedCycle:v,depthFirstSearch:g,dijkstra:j,findAllPath:function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,d=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],l=n?a(t,d,"target"):a(t,d);for(f.push(l);s.length>0&&f.length>0;){var c=f[f.length-1];if(c.length){var p=c.shift();if(p&&(s.push(p),u[p]=!0,l=n?a(p,d,"target"):a(p,d),f.push(l.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h},findShortestPath:function(e,t,r,n,o){var i=j(e,t,n,o),d=i.length,a=i.path,s=i.allPath;return{length:d[r],path:a[r],allPath:s[r]}},floydWarshall:I,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,d=void 0===i?[]:i,a=e.edges,s=void 0===a?[]:a,f={},h={};d.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var l=r(e,t),c=[],p={};l.forEach((function(e,t){var r=0,n=d[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=d[t].id;p[n][o]=e}})),c.push(r)}));for(var g=0,v=function(){var e=!1;if(d.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var d=f[t.clusterId],a=d.nodes.indexOf(t);d.nodes.splice(a,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,d=h[r].node.clusterId,a=i+"---"+d;if(E[a])E[a].weight+=o,E[a].count++;else{var s={source:i,target:d,weight:o,count:1};E[a]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}},louvain:function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,d=void 0===i?[]:i,a=e.edges,s=void 0===a?[]:a,u=1,f={},h={};d.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var l=r(e,t),c=[],p={},g=0;l.forEach((function(e,t){var r=0,n=d[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=d[t].id;p[n][o]=e,g+=e}})),c.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=w(d,l,c,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,d=h[o].node.clusterId,a=h[i].node.clusterId;(d===e&&a!==e||a===e&&d!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),d.forEach((function(e,t){var r,o=f[e.clusterId],i=0,d=c[t]/(2*g),a=0;o.nodes.forEach((function(e){var r=h[e.id].idx;a+=l[t][r]||0}));var u=a-o.sumTot*d,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var a=f[o],s=a.nodes;if(s&&s.length){var c=0;s.forEach((function(e){var r=h[e.id].idx;c+=l[t][r]||0}));var p=c-a.sumTot*d-u;p>i&&(i=p,r=a)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,d=h[o].node.clusterId;(i===r.id&&d!==r.id||d===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&d!==b||d===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),d.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,d=h[r].node.clusterId,a=i+"---"+d;if(N[a])N[a].weight+=o,N[a].count++;else{var s={source:i,target:d,weight:o,count:1};N[a]=s,L.push(s)}}));var k=[];return Object.keys(f).forEach((function(e){k.push(f[e])})),{clusters:k,clusterEdges:L}},minimumSpanningTree:function(e,t,r){return r?{prim:C,kruskal:P}[r](e,t):P(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,d=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,l=u.length,p={},g={},v=0;v<l;++v)p[E=(k=u[v]).id]=1/l,g[E]=1/l;for(var b=c(e);d>0&&o>t;){for(i=0,v=0;v<l;++v){var E=(k=u[v]).id;if(n=0,0===b[k.id].inDegree)p[E]=0;else{for(var m=a(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/l,o=0,v=0;v<l;++v){var k;n=p[E=(k=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}d-=1}return g},getNeighbors:a,Stack:$,GADDI:function(e,t,r,n,o,i,d){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===d&&(d="cluster"),e&&e.nodes){var a=e.nodes.length;if(a){var s=I(e,r),u=I(t,r),f=X(e.nodes,s,r),h=X(t.nodes,u,r),l=Q(e.nodes,i),c=l.nodeMap,p=l.nodeLabelMap,g=Q(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;V(e.edges,d,c);var E=V(t.edges,d,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=H(e,s,i,n),N=H(t,u,i,n),k=function(e,t,r,n,o){var i=Math.ceil(r/t),d={},a=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var l=f[1+Math.floor(Math.random()*h)],c=0;(d[n+"-"+l]||d[l+"-"+n])&&(l=Math.floor(Math.random()*t),!(++c>2*t)););if(c<2*t&&(d[n+"-"+l]={start:n,end:l,distance:o[n][l]},s++,++a>=r))return d;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),d}(0,a,Math.min(100,a*(a-1)/2),N,s),x=W(k,L,e),M=function(e){var t=e.graphs,r=e.directed,n=void 0!==r&&r,o=e.nodeLabelProp,i=void 0===o?B:o,d=e.edgeLabelProp,a=void 0===d?B:d,s=function(e,t,r,n){var o={};return Object.keys(e).forEach((function(i,d){var a=e[i],s=new F(d,!0,t),u={};a.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),a.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,a),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,l=e.verbose,c=e.top,p=new z({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:c,verbose:l,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,a)}({graphs:x,nodeLabelProp:i,edgeLabelProp:d,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=M.length,O=[];M.forEach((function(e,t){O[t]={},Object.keys(x).forEach((function(r){var n=x[r],o=J(n,e,i,d);O[t][r]=o}))}));var D=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]})),d=[];i.forEach((function(e,t){d[t%10]||(d[t%10]={graphs:[],totalCount:0,aveCount:0}),d[t%10].graphs.push(e),d[t%10].totalCount+=r[e]}));var a=0,s=[];d.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]))}))})),a+=n/=o*(o-1)/2})),a/=d.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-a;n<f&&(n=f,o=t)},d=0;d<t;d++)i(d);return{structure:r[o],structureCountMap:e[o]}}(O,w,M),S=D.structure,C=D.structureCountMap,P=t.nodes[0],A=P[i],T=p[A],q={},R={},G={},U={},$={},_={};Object.keys(b).forEach((function(n,o){$[n]=[],r&&(_[n]=[]);var a=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[P.id+"-"+e.id];if(t&&$[n].push(t),a<t&&(a=t),u[P.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+P.id];o&&_[n].push(o)}})),$[n]=$[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),R=W(u,N,t,R);var l=[];if(Object.keys(u).forEach((function(e){if(G[e])l.push(G[e]);else{var t=R[e];G[e]=J(t,S,i,d),l.push(G[e])}})),l=l.sort((function(e,t){return t-e})),U[P.id+"-"+n]=l,n!==A)for(var p=function(t){var r=T[t],o=L[c[r.id].idx],a=o.nodeLabelCountMap[n],s=b[n].length;if(!a||a.count<s)return T.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(a.dists[h]>$[n][h]){u=!0;break}if(u)return T.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:c[r.id].idx,end:c[e.id].idx,distance:t}})),x=W(p,L,e,x);var g=[];Object.keys(p).forEach((function(e){if(C[e])g.push(C[e]);else{var t=x[e];C[e]=J(t,S,i,d),g.push(C[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<l[h]){v=!0;break}return v?(T.splice(t,1),"continue"):void 0},g=T.length-1;g>=0;g--)p(g)}));var ee=[];null==T||T.forEach((function(n){for(var a=c[n.id].idx,u=K(e.nodes,s[a],a,i,o).neighbors,h=!1,l=u.length-1;l>=0;l--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[l],g=p[i];if(b[g]&&b[g].length)if($[g]&&$[g].length){var E=n.id+"-"+p.id,m=f[E],y=$[g].length-1;if(m>$[g][y])u.splice(l,1);else{if(r){var N=p.id+"-"+n.id,k=f[N];if(y=_[g].length-1,k>_[g][y]){u.splice(l,1);continue}}var j=C[E]?C[E]:Y(e,n,p,c,m,L,S,i,d,C,x),M=P.id+"-"+g;if(j<U[M][U[M].length-1])u.splice(l,1);else{var I=Z(q,g,v,b),w=I.minPatternNodeLabelDegree;I.minPatternNodeLabelInDegree,I.minPatternNodeLabelOutDegree,c[p.id].degree<w&&u.splice(l,1)}}}else u.splice(l,1);else u.splice(l,1)}h||ee.push({nodes:[n].concat(u)})}));var te=j(t,P.id,!1).length,re={};r?(Object.keys(te).forEach((function(e){var t=v[e].node[i];re[t]?re[t].push(te[e]):re[t]=[te[e]]})),Object.keys(re).forEach((function(e){re[e].sort((function(e,t){return e-t}))}))):re=$;for(var ne=function(n){var o=ee[n],a=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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[d]]?h[e[d]]++:h[e[d]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var l=Object.keys(E).length,p=!1,g=0;g<l;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return ee.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return ee.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[d],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue");var a=u[t.source].node[i],s=u[t.target].node[i],l=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===a&&n[i]===s&&(l=!0),r||t[i]!==s||n[i]!==a||(l=!0)})),l?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return ee.splice(n,1),"continue";o.edges=f;var k=j(o,o.nodes[0].id,!1).length;if(Object.keys(k).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(k[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=c[e].node[i];if(!re[n]||!re[n].length||k[e]>re[n][re[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return ee.splice(n,1),"continue";for(var x=!0,M=0;x&&!L;){if(x=!1,r?u[a.id].degree<v[P.id].degree||u[a.id].inDegree<v[P.id].inDegree||u[a.id].outDegree<v[P.id].outDegree:u[a.id].degree<v[P.id].degree){L=!0;break}if(s[a[i]]<b[a[i]].length){L=!0;break}for(var I=o.nodes.length-1;I>=0;I--){var w=o.nodes[I],O=u[w.id].degree,D=u[w.id].inDegree,S=u[w.id].outDegree,C=w[i],A=Z(q,C,v,b),T=A.minPatternNodeLabelDegree,F=A.minPatternNodeLabelInDegree,R=A.minPatternNodeLabelOutDegree;if(r?O<T||D<F||S<R:O<T){if(s[w[i]]--,s[w[i]]<b[w[i]].length){L=!0;break}o.nodes.splice(I,1),u[w.id]=void 0,x=!0}}if(L||!x&&0!==M)break;for(var G=(y=f.length)-1;G>=0;G--){var U=f[G];if(!u[U.source]||!u[U.target]){f.splice(G,1);var z=U[d];if(h[z]--,u[U.source]&&(u[U.source].degree--,u[U.source].outDegree--),u[U.target]&&(u[U.target].degree--,u[U.target].inDegree--),E[z]&&h[z]<E[z].length){L=!0;break}x=!0}}M++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(ee.splice(n,1),"continue"):void 0},oe=ee.length-1;oe>=0&&"break"!==ne(oe);oe--);var ie=ee.length,de=function(e){var t=ee[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=ee[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&ee.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=ee.length};for(oe=0;oe<=ie-1;oe++)de(oe);return ee}}}};return t.default})()})); | ||
//# sourceMappingURL=index.min.js.map |
@@ -1,2 +0,2 @@ | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>oe,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>k,findAllPath:()=>x,findShortestPath:()=>w,floydWarshall:()=>O,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>g,labelPropagation:()=>D,louvain:()=>P,minimumSpanningTree:()=>R,pageRank:()=>U});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r,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 f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(a[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var g=p[l];s[g.id]||0===s[g.id]||c(g)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},g=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function v(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})&&v(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){v(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var M=Array.prototype;M.splice,M.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const j=function e(t){if("object"!=typeof t||null===t)return t;var r;if(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const k=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},g=0;g<l;g++)p();c[t]=[t];var v={};for(var b in h)h[b]!==1/0&&I(t,b,c,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function I(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=I(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}var w=function(e,t,r,n,o){var i=k(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},x=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h};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},D=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var g=0,v=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}};var S=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const P=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u=1,f={},h={};a.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},g=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,g+=e}})),l.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=S(a,c,l,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*g),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),a.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(N[d])N[d].weight+=o,N[d].count++;else{var s={source:i,target:a,weight:o,count:1};N[d]=s,L.push(s)}}));var M=[];return Object.keys(f).forEach((function(e){M.push(f[e])})),{clusters:M,clusterEdges:L}},C=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 T=function(e,t){return e-t};const q=function(){function e(e){void 0===e&&(e=T),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 F=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new q((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},A=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 C(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const R=function(e,t,r){return r?{prim:F,kruskal:A}[r](e,t):A(e,t)},U=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},g={},v=0;v<c;++v)p[E=(M=u[v]).id]=1/c,g[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,v=0;v<c;++v){var E=(M=u[v]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var m=d(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,v=0;v<c;++v){var M;n=p[E=(M=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}a-=1}return g};var G="-1",_=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},z=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),B=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 z(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 _(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 _(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),H=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new H(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 B(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),i!==G&&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}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);if(d){i.dfsEdgeList.push(new H(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,g=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},v=d.length-1;v>p&&"break"!==g(v);v--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new H(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};c=!1;var y=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!c)return!0;var M=e.findMinLabel(m);i.dfsEdgeList.push(new H(y,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(m[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)}},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(j(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new H(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 H(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new H(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,g=0;g<p;g++){var v=o[c[g]];n[i].nodes.push(v),l[v.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o={};e.nodes.forEach((function(e){o[e.id]=e}));var i=0;return e.edges.forEach((function(e){var a=o[e.source][r],d=o[e.target][r],s=null==t?void 0:t.nodes[0][r],u=null==t?void 0:t.nodes[1][r],f=null==t?void 0:t.edges[0][n];e[n]===f&&(a===s&&d===u||a===u&&d===s)&&i++})),i},$=function(e,t){var r={},n={};return e.forEach((function(e,o){r[e.id]={idx:o,node:e,degree:0,inDegree:0,outDegree:0};var i=e[t];n[i]||(n[i]=[]),n[i].push(e)})),{nodeMap:r,nodeLabelMap:n}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&(d.degree++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o},re=function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)},ne=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}};const oe=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=O(e,r),u=O(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,g=$(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),j=Y(M,L,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 B(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:j,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=I.length,x=[];I.forEach((function(e,t){x[t]={},Object.keys(j).forEach((function(r){var n=j[r],o=Z(n,e,i,a);x[t][r]=o}))}));var D=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(x,w,I),S=D.structure,P=D.structureCountMap,C=t.nodes[0],T=C[i],q=p[T],F={},A={},R={},U={},G={},_={};Object.keys(b).forEach((function(n,o){G[n]=[],r&&(_[n]=[]);var d=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[C.id+"-"+e.id];if(t&&G[n].push(t),d<t&&(d=t),u[C.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+C.id];o&&_[n].push(o)}})),G[n]=G[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),A=Y(u,N,t,A);var c=[];if(Object.keys(u).forEach((function(e){if(R[e])c.push(R[e]);else{var t=A[e];R[e]=Z(t,S,i,a),c.push(R[e])}})),c=c.sort((function(e,t){return t-e})),U[C.id+"-"+n]=c,n!==T)for(var p=function(t){var r=q[t],o=L[l[r.id].idx],d=o.nodeLabelCountMap[n],s=b[n].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>G[n][h]){u=!0;break}if(u)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:l[r.id].idx,end:l[e.id].idx,distance:t}})),j=Y(p,L,e,j);var g=[];Object.keys(p).forEach((function(e){if(P[e])g.push(P[e]);else{var t=j[e];P[e]=Z(t,S,i,a),g.push(P[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<c[h]){v=!0;break}return v?(q.splice(t,1),"continue"):void 0},g=q.length-1;g>=0;g--)p(g)}));var z=[];null==q||q.forEach((function(n){for(var d=l[n.id].idx,u=X(e.nodes,s[d],d,i,o).neighbors,h=!1,c=u.length-1;c>=0;c--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[c],g=p[i];if(b[g]&&b[g].length)if(G[g]&&G[g].length){var E=n.id+"-"+p.id,m=f[E],y=G[g].length-1;if(m>G[g][y])u.splice(c,1);else{if(r){var N=p.id+"-"+n.id,M=f[N];if(y=_[g].length-1,M>_[g][y]){u.splice(c,1);continue}}var k=P[E]?P[E]:re(e,n,p,l,m,L,S,i,a,P,j),I=C.id+"-"+g;if(k<U[I][U[I].length-1])u.splice(c,1);else{var w=ne(F,g,v,b),x=w.minPatternNodeLabelDegree;w.minPatternNodeLabelInDegree,w.minPatternNodeLabelOutDegree,l[p.id].degree<x&&u.splice(c,1)}}}else u.splice(c,1);else u.splice(c,1)}h||z.push({nodes:[n].concat(u)})}));var H=k(t,C.id,!1).length,K={};r?(Object.keys(H).forEach((function(e){var t=v[e].node[i];K[t]?K[t].push(H[e]):K[t]=[H[e]]})),Object.keys(K).forEach((function(e){K[e].sort((function(e,t){return e-t}))}))):K=G;for(var W=function(n){var o=z[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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var c=Object.keys(E).length,p=!1,g=0;g<c;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return z.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return z.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.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],c=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return z.splice(n,1),"continue";o.edges=f;var M=k(o,o.nodes[0].id,!1).length;if(Object.keys(M).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(M[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=l[e].node[i];if(!K[n]||!K[n].length||M[e]>K[n][K[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return z.splice(n,1),"continue";for(var j=!0,I=0;j&&!L;){if(j=!1,r?u[d.id].degree<v[C.id].degree||u[d.id].inDegree<v[C.id].inDegree||u[d.id].outDegree<v[C.id].outDegree:u[d.id].degree<v[C.id].degree){L=!0;break}if(s[d[i]]<b[d[i]].length){L=!0;break}for(var w=o.nodes.length-1;w>=0;w--){var x=o.nodes[w],O=u[x.id].degree,D=u[x.id].inDegree,S=u[x.id].outDegree,P=x[i],T=ne(F,P,v,b),q=T.minPatternNodeLabelDegree,A=T.minPatternNodeLabelInDegree,R=T.minPatternNodeLabelOutDegree;if(r?O<q||D<A||S<R:O<q){if(s[x[i]]--,s[x[i]]<b[x[i]].length){L=!0;break}o.nodes.splice(w,1),u[x.id]=void 0,j=!0}}if(L||!j&&0!==I)break;for(var U=(y=f.length)-1;U>=0;U--){var G=f[U];if(!u[G.source]||!u[G.target]){f.splice(U,1);var _=G[a];if(h[_]--,u[G.source]&&(u[G.source].degree--,u[G.source].outDegree--),u[G.target]&&(u[G.target].degree--,u[G.target].inDegree--),E[_]&&h[_]<E[_].length){L=!0;break}j=!0}}I++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(z.splice(n,1),"continue"):void 0},oe=z.length-1;oe>=0&&"break"!==W(oe);oe--);var ie=z.length,ae=function(e){var t=z[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=z[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&z.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=z.length};for(oe=0;oe<=ie-1;oe++)ae(oe);return z}}};var ie="undefined"!=typeof self?self:{};ie.onmessage=function(e){var r=e.data,n=r._algorithmType,o=r.data;if(n)if("function"!=typeof t[n])ie.postMessage({_algorithmType:"FAILURE"});else{var i=t[n].apply(t,o);ie.postMessage({_algorithmType:"SUCCESS",data:i})}}})(); | ||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GADDI:()=>oe,breadthFirstSearch:()=>f,connectedComponent:()=>h,depthFirstSearch:()=>b,detectCycle:()=>E,dijkstra:()=>k,findAllPath:()=>x,findShortestPath:()=>w,floydWarshall:()=>O,getAdjMatrix:()=>r,getDegree:()=>l,getInDegree:()=>p,getNeighbors:()=>d,getOutDegree:()=>g,labelPropagation:()=>D,louvain:()=>P,minimumSpanningTree:()=>R,pageRank:()=>U});const r=function(e,t){var r=e.nodes,n=e.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(e,t){i[e.id]=t,o.push([])})),n&&n.forEach((function(e){var r=e.source,n=e.target,a=i[r],d=i[n];!a&&0!==a||!d&&0!==d||(o[a][d]=1,t||(o[d][a]=1))})),o};var n=function(e,t){return e===t},o=function(){function e(e,t){void 0===t&&(t=null),this.value=e,this.next=t}return e.prototype.toString=function(e){return e?e(this.value):""+this.value},e}();const i=function(){function e(e){void 0===e&&(e=n),this.head=null,this.tail=null,this.compare=e}return e.prototype.prepend=function(e){var t=new o(e,this.head);return this.head=t,this.tail||(this.tail=t),this},e.prototype.append=function(e){var t=new o(e);return this.head?(this.tail.next=t,this.tail=t,this):(this.head=t,this.tail=t,this)},e.prototype.delete=function(e){if(!this.head)return null;for(var t=null;this.head&&this.compare(this.head.value,e);)t=this.head,this.head=this.head.next;var r=this.head;if(null!==r)for(;r.next;)this.compare(r.next.value,e)?(t=r.next,r.next=r.next.next):r=r.next;return this.compare(this.tail.value,e)&&(this.tail=r),t},e.prototype.find=function(e){var t=e.value,r=void 0===t?void 0:t,n=e.callback,o=void 0===n?void 0:n;if(!this.head)return null;for(var i=this.head;i;){if(o&&o(i.value))return i;if(void 0!==r&&this.compare(i.value,r))return i;i=i.next}return null},e.prototype.deleteTail=function(){var e=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,e;for(var t=this.head;t.next;)t.next.next?t=t.next:t.next=null;return this.tail=t,e},e.prototype.deleteHead=function(){if(!this.head)return null;var e=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),e},e.prototype.fromArray=function(e){var t=this;return e.forEach((function(e){return t.append(e)})),this},e.prototype.toArray=function(){for(var e=[],t=this.head;t;)e.push(t),t=t.next;return e},e.prototype.reverse=function(){for(var e=this.head,t=null,r=null;e;)r=e.next,e.next=t,t=e,e=r;this.tail=this.head,this.head=t},e.prototype.toString=function(e){return void 0===e&&(e=void 0),this.toArray().map((function(t){return t.toString(e)})).toString()},e}(),a=function(){function e(){this.linkedList=new i}return e.prototype.isEmpty=function(){return!this.linkedList.head},e.prototype.peek=function(){return this.linkedList.head?this.linkedList.head.value:null},e.prototype.enqueue=function(e){this.linkedList.append(e)},e.prototype.dequeue=function(){var e=this.linkedList.deleteHead();return e?e.value:null},e.prototype.toString=function(e){return this.linkedList.toString(e)},e}();var d=function(e,t,r){void 0===t&&(t=[]);var n=t.filter((function(t){return t.source===e||t.target===e}));return"target"===r?n.filter((function(t){return t.source===e})).map((function(e){return e.target})):"source"===r?n.filter((function(t){return t.target===e})).map((function(e){return e.source})):n.map((function(t){return t.source===e?t.target:t.source}))},s=function(e,t){return t.filter((function(t){return t.source===e||t.target===e}))},u=function(e){return void 0===e&&(e=0),e+"-"+(""+Math.random()).split(".")[1].substr(0,5)+(""+Math.random()).split(".")[1].substr(0,5)};const f=function(e,t,r,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 f="",h=function(){var e=i.dequeue();o.enter({current:e,previous:f}),d(e,u,n?"target":void 0).forEach((function(t){o.allowTraversal({previous:f,current:e,next:t})&&i.enqueue(t)})),o.leave({current:e,previous:f}),f=e};!i.isEmpty();)h()};function h(e,t){return t?function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s={},u={},f=[],h=0,c=function(e){s[e.id]=h,u[e.id]=h,h+=1,i.push(e),a[e.id]=!0;for(var t=d(e.id,o,"target").filter((function(e){return r.map((function(e){return e.id})).indexOf(e)>-1})),n=function(n){var o=t[n];if(s[o]||0===s[o])a[o]&&(u[e.id]=Math.min(u[e.id],s[o]));else{var i=r.filter((function(e){return e.id===o}));i.length>0&&c(i[0]),u[e.id]=Math.min(u[e.id],u[o])}},l=0;l<t.length;l++)n(l);if(u[e.id]===s[e.id]){for(var p=[];i.length>0;){var g=i.pop();if(a[g.id]=!1,p.push(g),g===e)break}p.length>0&&f.push(p)}},l=0,p=r;l<p.length;l++){var g=p[l];s[g.id]||0===s[g.id]||c(g)}return f}(e):function(e){for(var t=e.nodes,r=void 0===t?[]:t,n=e.edges,o=void 0===n?[]:n,i=[],a={},s=[],u=function(e){s.push(e),a[e.id]=!0;for(var t=d(e.id,o),n=function(e){var n=t[e];if(!a[n]){var o=r.filter((function(e){return e.id===n}));o.length>0&&u(o[0])}},i=0;i<t.length;++i)n(i)},f=0;f<r.length;f++){var h=r[f];if(!a[h.id]){u(h);for(var c=[];s.length>0;)c.push(s.pop());i.push(c)}}return i}(e)}var c=function(e){var t={},r=e.nodes,n=void 0===r?[]:r,o=e.edges,i=void 0===o?[]:o;return n.forEach((function(e){t[e.id]={degree:0,inDegree:0,outDegree:0}})),i.forEach((function(e){t[e.source].degree++,t[e.source].outDegree++,t[e.target].degree++,t[e.target].inDegree++})),t};const l=c;var p=function(e,t){return c(e)[t]?c(e)[t].inDegree:0},g=function(e,t){return c(e)[t]?c(e)[t].outDegree:0};function v(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})&&v(e,o,t,n)})),n.leave({current:t,previous:r})}function b(e,t,r){v(e,t,"",function(e){void 0===e&&(e={});var t,r=e,n=function(){},o=(t={},function(e){var r=e.next;return!t[r]&&(t[r]=!0,!0)});return r.allowTraversal=e.allowTraversal||o,r.enter=e.enter||n,r.leave=e.leave||n,r}(r))}const E=function(e){var t=null,r=e.nodes,n={},o={},i={},a={};(void 0===r?[]:r).forEach((function(e){o[e.id]=e}));for(var d={enter:function(e){var r=e.current,a=e.previous;if(i[r]){t={};for(var d=r,s=a;s!==r;)t[d]=s,d=s,s=n[s];t[d]=s}else i[r]=r,delete o[r],n[r]=a},leave:function(e){var t=e.current;a[t]=t,delete i[t]},allowTraversal:function(e){var r=e.next;return!t&&!a[r]}};Object.keys(o).length;)b(e,Object.keys(o)[0],d);return t};function m(e,t){for(var r=0,n=t.length,o=e.length;r<n;r++,o++)e[o]=t[r];return e}Object.create,Object.create;var y={}.toString;const L=function(e,t){return y.call(e)==="[object "+t+"]"},N=function(e){return Array.isArray?Array.isArray(e):L(e,"Array")};Object.keys;var M=Array.prototype;M.splice,M.indexOf,Array.prototype.splice,Object.prototype.hasOwnProperty;Number.isInteger&&Number.isInteger,Math.PI,parseInt,Math.PI,Object.values,Object.prototype;const j=function e(t){if("object"!=typeof t||null===t)return t;var r;if(N(t)){r=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?r[n]=e(t[n]):r[n]=t[n]}else for(var i in r={},t)"object"==typeof t[i]&&null!=t[i]?r[i]=e(t[i]):r[i]=t[i];return r};Object.prototype.hasOwnProperty,Object.prototype.hasOwnProperty,function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var r=this.map[e];return void 0===r?t:r},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();const k=function(e,t,r,n){var o=e.nodes,i=void 0===o?[]:o,a=e.edges,d=void 0===a?[]:a,u=[],f={},h={},c={};i.forEach((function(e,r){var n=e.id;u.push(n),h[n]=1/0,n===t&&(h[n]=0)}));for(var l=i.length,p=function(e){var t=function(e,t,r){for(var n,o=1/0,i=0;i<t.length;i++){var a=t[i].id;!r[a]&&e[a]<=o&&(o=e[a],n=t[i])}return n}(h,i,f),o=t.id;if(f[o]=!0,h[o]===1/0)return"continue";(r?function(e,t){return t.filter((function(t){return t.source===e}))}(o,d):s(o,d)).forEach((function(e){var r=e.target,i=e.source,a=r===o?i:r,d=n&&e[n]?e[n]:1;h[a]>h[t.id]+d?(h[a]=h[t.id]+d,c[a]=[t.id]):h[a]===h[t.id]+d&&c[a].push(t.id)}))},g=0;g<l;g++)p();c[t]=[t];var v={};for(var b in h)h[b]!==1/0&&I(t,b,c,v);var E={};for(var b in v)E[b]=v[b][0];return{length:h,path:E,allPath:v}};function I(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=I(e,a[i],r,n);if(!d)return;for(var s=0,u=d;s<u.length;s++){var f=u[s];N(f)?o.push(m(m([],f),[t])):o.push([f,t])}}return n[t]=o,n[t]}var w=function(e,t,r,n,o){var i=k(e,t,n,o),a=i.length,d=i.path,s=i.allPath;return{length:a[r],path:d[r],allPath:s[r]}},x=function(e,t,r,n){var o;if(t===r)return[[t]];var i=e.edges,a=void 0===i?[]:i,s=[t],u=((o={})[t]=!0,o),f=[],h=[],c=n?d(t,a,"target"):d(t,a);for(f.push(c);s.length>0&&f.length>0;){var l=f[f.length-1];if(l.length){var p=l.shift();if(p&&(s.push(p),u[p]=!0,c=n?d(p,a,"target"):d(p,a),f.push(c.filter((function(e){return!u[e]})))),s[s.length-1]===r){var g=s.map((function(e){return e}));h.push(g),v=s.pop(),u[v]=!1,f.pop()}}else{var v=s.pop();u[v]=!1,f.pop()}}return h};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},D=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e3);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,f={},h={};a.forEach((function(e,t){var r=u();e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={};c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e}})),l.push(r)}));for(var g=0,v=function(){var e=!1;if(a.forEach((function(t){var r={};Object.keys(p[t.id]).forEach((function(e){var n=p[t.id][e],o=h[e].node.clusterId;r[o]||(r[o]=0),r[o]+=n}));var n=-1/0,o=[];if(Object.keys(r).forEach((function(e){n<r[e]?(n=r[e],o=[e]):n===r[e]&&o.push(e)})),1!==o.length||o[0]!==t.clusterId){var i=o.indexOf(t.clusterId);if(i>=0&&o.splice(i,1),o&&o.length){e=!0;var a=f[t.clusterId],d=a.nodes.indexOf(t);a.nodes.splice(d,1);var s=Math.floor(Math.random()*o.length),u=f[o[s]];u.nodes.push(t),t.clusterId=u.id}}})),!e)return"break";g++};g<o&&"break"!==v(););Object.keys(f).forEach((function(e){var t=f[e];t.nodes&&t.nodes.length||delete f[e]}));var b=[],E={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(E[d])E[d].weight+=o,E[d].count++;else{var s={source:i,target:a,weight:o,count:1};E[d]=s,b.push(s)}}));var m=[];return Object.keys(f).forEach((function(e){m.push(f[e])})),{clusters:m,clusterEdges:b}};var S=function(e,t,r,n){for(var o=t.length,i=2*n,a=0,d=0;d<o;d++)for(var s=e[d].clusterId,u=0;u<o;u++)s===e[u].clusterId&&(a+=(t[d][u]||0)-(r[d]||0)*(r[u]||0)/i);return a*(1/i)};const P=function(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n="weight"),void 0===o&&(o=1e-4);var i=e.nodes,a=void 0===i?[]:i,d=e.edges,s=void 0===d?[]:d,u=1,f={},h={};a.forEach((function(e,t){var r=String(u++);e.clusterId=r,f[r]={id:r,nodes:[e]},h[e.id]={node:e,idx:t}}));var c=r(e,t),l=[],p={},g=0;c.forEach((function(e,t){var r=0,n=a[t].id;p[n]={},e.forEach((function(e,t){if(e){r+=e;var o=a[t].id;p[n][o]=e,g+=e}})),l.push(r)})),g/=2;for(var v=1/0,b=1/0,E=0;v=S(a,c,l,g),!(Math.abs(v-b)<o||E>100);)b=v,E++,Object.keys(f).forEach((function(e){var t=0;s.forEach((function(r){var o=r.source,i=r.target,a=h[o].node.clusterId,d=h[i].node.clusterId;(a===e&&d!==e||d===e&&a!==e)&&(t+=r[n]||1)})),f[e].sumTot=t})),a.forEach((function(e,t){var r,o=f[e.clusterId],i=0,a=l[t]/(2*g),d=0;o.nodes.forEach((function(e){var r=h[e.id].idx;d+=c[t][r]||0}));var u=d-o.sumTot*a,v=p[e.id];if(Object.keys(v).forEach((function(n){var o=h[n].node.clusterId;if(o!==e.clusterId){var d=f[o],s=d.nodes;if(s&&s.length){var l=0;s.forEach((function(e){var r=h[e.id].idx;l+=c[t][r]||0}));var p=l-d.sumTot*a-u;p>i&&(i=p,r=d)}}})),i>0){r.nodes.push(e);var b=e.clusterId;e.clusterId=r.id;var E=o.nodes.indexOf(e);o.nodes.splice(E,1);var m=0,y=0;s.forEach((function(e){var t=e.source,o=e.target,i=h[t].node.clusterId,a=h[o].node.clusterId;(i===r.id&&a!==r.id||a===r.id&&i!==r.id)&&(m+=e[n]||1),(i===b&&a!==b||a===b&&i!==b)&&(y+=e[n]||1)})),r.sumTot=m,o.sumTot=y}}));var m={},y=0;Object.keys(f).forEach((function(e){var t=f[e];if(t.nodes&&t.nodes.length){var r=String(y+1);r!==e&&(t.id=r,t.nodes=t.nodes.map((function(e){return{id:e.id,clusterId:r}})),f[r]=t,m[e]=r,delete f[e],y++)}else delete f[e]})),a.forEach((function(e){e.clusterId&&m[e.clusterId]&&(e.clusterId=m[e.clusterId])}));var L=[],N={};s.forEach((function(e){var t=e.source,r=e.target,o=e[n]||1,i=h[t].node.clusterId,a=h[r].node.clusterId,d=i+"---"+a;if(N[d])N[d].weight+=o,N[d].count++;else{var s={source:i,target:a,weight:o,count:1};N[d]=s,L.push(s)}}));var M=[];return Object.keys(f).forEach((function(e){M.push(f[e])})),{clusters:M,clusterEdges:L}},C=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 T=function(e,t){return e-t};const q=function(){function e(e){void 0===e&&(e=T),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 F=function(e,t){var r=[],n=e.nodes,o=void 0===n?[]:n,i=e.edges,a=void 0===i?[]:i;if(0===o.length)return r;var d=o[0],u=new Set;u.add(d);var f=new q((function(e,r){return t?e.weight-r.weight:0}));for(s(d.id,a).forEach((function(e){f.insert(e)}));!f.isEmpty();){var h=f.delMin(),c=h.source,l=h.target;u.has(c)&&u.has(l)||(r.push(h),u.has(c)||(u.add(c),s(c,a).forEach((function(e){f.insert(e)}))),u.has(l)||(u.add(l),s(l,a).forEach((function(e){f.insert(e)}))))}return r},A=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 C(o.map((function(e){return e.id})));d.length>0;){var u=d.shift(),f=u.source,h=u.target;s.connected(f,h)||(r.push(u),s.union(f,h))}return r};const R=function(e,t,r){return r?{prim:F,kruskal:A}[r](e,t):A(e,t)},U=function(e,t,r){"number"!=typeof t&&(t=1e-6),"number"!=typeof r&&(r=.85);for(var n,o=1,i=0,a=1e3,s=e.nodes,u=void 0===s?[]:s,f=e.edges,h=void 0===f?[]:f,c=u.length,p={},g={},v=0;v<c;++v)p[E=(M=u[v]).id]=1/c,g[E]=1/c;for(var b=l(e);a>0&&o>t;){for(i=0,v=0;v<c;++v){var E=(M=u[v]).id;if(n=0,0===b[M.id].inDegree)p[E]=0;else{for(var m=d(E,h,"source"),y=0;y<m.length;++y){var L=m[y],N=b[L].outDegree;N>0&&(n+=g[L]/N)}p[E]=r*n,i+=p[E]}}for(i=(1-i)/c,o=0,v=0;v<c;++v){var M;n=p[E=(M=u[v]).id]+i,o+=Math.abs(n-g[E]),g[E]=n}a-=1}return g};var G="-1",_=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},z=function(){function e(e,t){void 0===e&&(e=-1),void 0===t&&(t=G),this.id=e,this.label=t,this.edges=[],this.edgeMap={}}return e.prototype.addEdge=function(e){this.edges.push(e),this.edgeMap[e.id]=e},e}(),B=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 z(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 _(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 _(e,r,t,n);this.nodeMap[r].addEdge(i),this.edgeLabelMap[n].push(i)}}},e}(),H=function(){function e(e,t,r,n,o){this.fromNode=e,this.toNode=t,this.nodeEdgeNodeLabel={nodeLabel1:r||G,edgeLabel:n||"-1",nodeLabel2:o||G}}return e.prototype.equalTo=function(e){return this.fromNode===e.formNode&&this.toNode===e.toNode&&this.nodeEdgeNodeLabel===e.nodeEdgeNodeLabel},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e}(),K=function(){function e(){this.rmpath=[],this.dfsEdgeList=[]}return e.prototype.equalTo=function(e){var t=this.dfsEdgeList.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(this.dfsEdgeList[r]!==e[r])return!1;return!0},e.prototype.notEqualTo=function(e){return!this.equalTo(e)},e.prototype.pushBack=function(e,t,r,n,o){return this.dfsEdgeList.push(new H(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 B(e,!0,t);return this.dfsEdgeList.forEach((function(e){var t=e.fromNode,n=e.toNode,o=e.nodeEdgeNodeLabel,i=o.nodeLabel1,a=o.edgeLabel,d=o.nodeLabel2;i!==G&&r.addNode(t,i),d!==G&&r.addNode(n,d),i!==G&&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}(),W=function(){function e(e){if(this.his={},this.nodesUsed={},this.edgesUsed={},this.edges=[],e){for(;e;){var t=e.edge;this.edges.push(t),this.nodesUsed[t.from]=1,this.nodesUsed[t.to]=1,this.edgesUsed[t.id]=1,e=e.preNode}this.edges=this.edges.reverse()}}return e.prototype.hasNode=function(e){return 1===this.nodesUsed[e.id]},e.prototype.hasEdge=function(e){return 1===this.edgesUsed[e.id]},e}(),J=function(){function e(e){var t=e.graphs,r=e.minSupport,n=void 0===r?2:r,o=e.minNodeNum,i=void 0===o?1:o,a=e.maxNodeNum,d=void 0===a?4:a,s=e.top,u=void 0===s?10:s,f=e.directed,h=void 0!==f&&f,c=e.verbose,l=void 0!==c&&c;this.graphs=t,this.dfsCode=new K,this.support=0,this.frequentSize1Subgraphs=[],this.frequentSubgraphs=[],this.minSupport=n,this.top=u,this.directed=h,this.counter=0,this.maxNodeNum=d,this.minNodeNum=i,this.verbose=l,this.maxNodeNum<this.minNodeNum&&(this.maxNodeNum=this.minNodeNum),this.reportDF=[]}return e.prototype.findForwardRootEdges=function(e,t){var r=this,n=[],o=e.nodeMap;return t.edges.forEach((function(e){(r.directed||t.label<=o[e.to].label)&&n.push(e)})),n},e.prototype.findBackwardEdge=function(e,t,r,n){if(!this.directed&&t===r)return null;for(var o=e.nodeMap,i=o[r.to].edges,a=i.length,d=0;d<a;d++){var s=i[d];if(!n.hasEdge(s)&&s.to===t.from)if(this.directed){if(o[t.from].label<o[r.to].label||o[t.from].label===o[r.to].label&&t.label<=s.label)return s}else if(t.label<s.label||t.label===s.label&&o[t.to].label<=o[r.to].label)return s}return null},e.prototype.findForwardPureEdges=function(e,t,r,n){for(var o=[],i=t.to,a=e.nodeMap[i].edges,d=a.length,s=0;s<d;s++){var u=a[s],f=e.nodeMap[u.to];r<=f.label&&!n.hasNode(f)&&o.push(u)}return o},e.prototype.findForwardRmpathEdges=function(e,t,r,n){for(var o=[],i=e.nodeMap,a=i[t.to].label,d=i[t.from].edges,s=d.length,u=0;u<s;u++){var f=d[u],h=i[f.to].label;t.to===f.to||r>h||n.hasNode(i[f.to])||(t.label<f.label||t.label===f.label&&a<=h)&&o.push(f)}return o},e.prototype.getSupport=function(e){var t={};return e.forEach((function(e){t[e.graphId]||(t[e.graphId]=!0)})),Object.keys(t).length},e.prototype.findMinLabel=function(e){var t=void 0;return Object.keys(e).forEach((function(r){var n=e[r],o=n.nodeLabel1,i=n.edgeLabel,a=n.nodeLabel2;t?(o<t.nodeLabel1||o===t.nodeLabel1&&i<t.edgeLabel||o===t.nodeLabel1&&i===t.edgeLabel&&a<t.nodeLabel2)&&(t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}):t={nodeLabel1:o,edgeLabel:i,nodeLabel2:a}})),t},e.prototype.isMin=function(){var e=this,t=this.dfsCode;if(this.verbose&&console.log("isMin checking",t),1===t.dfsEdgeList.length)return!0;var r=this.directed,n=t.toGraph(-1,r),o=n.nodeMap,i=new K,a={};n.nodes.forEach((function(t){e.findForwardRootEdges(n,t).forEach((function(e){var r=o[e.to],i=t.label+"-"+e.label+"-"+r.label;a[i]||(a[i]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:r.label});var d={graphId:n.id,edge:e,preNode:null};a[i].projected.push(d)}))}));var d=this.findMinLabel(a);if(d){i.dfsEdgeList.push(new H(0,1,d.nodeLabel1,d.edgeLabel,d.nodeLabel2));var s=function(a){for(var d=i.buildRmpath(),u=i.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,f=i.dfsEdgeList[d[0]].toNode,h={},c=!1,l=0,p=r?-1:0,g=function(t){if(c)return"break";a.forEach((function(r){var o=new W(r),a=e.findBackwardEdge(n,o.edges[d[t]],o.edges[d[0]],o);a&&(h[a.label]||(h[a.label]={projected:[],edgeLabel:a.label}),h[a.label].projected.push({graphId:n.id,edge:h,preNode:r}),l=i.dfsEdgeList[d[t]].fromNode,c=!0)}))},v=d.length-1;v>p&&"break"!==g(v);v--);if(c){var b=e.findMinLabel(h);i.dfsEdgeList.push(new H(f,l,G,b.edgeLabel,G));var E=i.dfsEdgeList.length-1;return e.dfsCode.dfsEdgeList[E]===i.dfsEdgeList[E]&&s(h[b.edgeLabel].projected)}var m={};c=!1;var y=0;a.forEach((function(t){var r=new W(t),i=e.findForwardPureEdges(n,r.edges[d[0]],u,r);i.length>0&&(c=!0,y=f,i.forEach((function(e){var r=e.label+"-"+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(c)return"break";var r=d[t];a.forEach((function(t){var a=new W(t),d=e.findForwardRmpathEdges(n,a.edges[r],u,a);d.length>0&&(c=!0,y=i.dfsEdgeList[r].fromNode,d.forEach((function(e){var r=e.label+"-"+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(v=0;v<L&&"break"!==N(v);v++);if(!c)return!0;var M=e.findMinLabel(m);i.dfsEdgeList.push(new H(y,f+1,G,M.edgeLabel,M.nodeLabel2));var j=i.dfsEdgeList.length-1;return t.dfsEdgeList[j]===i.dfsEdgeList[j]&&s(m[M.edgeLabel+"-"+M.nodeLabel2].projected)},u=d.nodeLabel1+"-"+d.edgeLabel+"-"+d.nodeLabel2;return s(a[u].projected)}},e.prototype.report=function(){if(!(this.dfsCode.getNodeNum()<this.minNodeNum)){this.counter++;var e=this.dfsCode.toGraph(this.counter,this.directed);this.frequentSubgraphs.push(j(e))}},e.prototype.subGraphMining=function(e){var t=this;if(!(this.getSupport(e)<this.minSupport)&&this.isMin()){this.report();var r=this.dfsCode.getNodeNum(),n=this.dfsCode.buildRmpath(),o=this.dfsCode.dfsEdgeList[n[0]].toNode,i=this.dfsCode.dfsEdgeList[0].nodeEdgeNodeLabel.nodeLabel1,a={},d={};e.forEach((function(e){for(var s=t.graphs[e.graphId],u=s.nodeMap,f=new W(e),h=n.length-1;h>=0;h--){var c=t.findBackwardEdge(s,f.edges[n[h]],f.edges[n[0]],f);if(c){var l=t.dfsCode.dfsEdgeList[n[h]].fromNode+"-"+c.label;d[l]||(d[l]={projected:[],toNodeId:t.dfsCode.dfsEdgeList[n[h]].fromNode,edgeLabel:c.label}),d[l].projected.push({graphId:e.graphId,edge:c,preNode:e})}}if(!(r>=t.maxNodeNum)){t.findForwardPureEdges(s,f.edges[n[0]],i,f).forEach((function(t){var r=o+"-"+t.label+"-"+u[t.to].label;a[r]||(a[r]={projected:[],fromNodeId:o,edgeLabel:t.label,nodeLabel2:u[t.to].label}),a[r].projected.push({graphId:e.graphId,edge:t,preNode:e})}));var p=function(r){t.findForwardRmpathEdges(s,f.edges[n[r]],i,f).forEach((function(o){var i=t.dfsCode.dfsEdgeList[n[r]].fromNode+"-"+o.label+"-"+u[o.to].label;a[i]||(a[i]={projected:[],fromNodeId:t.dfsCode.dfsEdgeList[n[r]].fromNode,edgeLabel:o.label,nodeLabel2:u[o.to].label}),a[i].projected.push({graphId:e.graphId,edge:o,preNode:e})}))};for(h=0;h<n.length;h++)p(h)}})),Object.keys(d).forEach((function(e){var r=d[e],n=r.toNodeId,i=r.edgeLabel;t.dfsCode.dfsEdgeList.push(new H(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 H(n,o+1,G,i,d)),t.subGraphMining(a[e].projected),t.dfsCode.dfsEdgeList.pop()}))}},e.prototype.generate1EdgeFrequentSubGraphs=function(){var e=this.graphs,t=this.directed,r=this.minSupport,n=this.frequentSize1Subgraphs,o={},i={},a={},d={};return Object.keys(e).forEach((function(r){var n=e[r],s=n.nodeMap;n.nodes.forEach((function(e,n){var u=e.label,f=r+"-"+u;if(!a[f]){var h=o[u]||0;h++,o[u]=h}a[f]={graphKey:r,label:u},e.edges.forEach((function(e){var n=u,o=s[e.to].label;if(!t&&n>o){var a=o;o=n,n=a}var f=e.label,h=r+"-"+n+"-"+f+"-"+o,c=n+"-"+f+"-"+o;if(!i[c]){var l=i[c]||0;l++,i[c]=l}d[h]={graphId:r,nodeLabel1:n,edgeLabel:f,nodeLabel2:o}}))}))})),Object.keys(o).forEach((function(e){if(!(o[e]<r)){var t={nodes:[],edges:[]};t.nodes.push({id:"0",label:e}),n.push(t)}})),n},e.prototype.run=function(){var e=this;if(this.frequentSize1Subgraphs=this.generate1EdgeFrequentSubGraphs(),!(this.maxNodeNum<2)){var t=this.graphs,r=(this.directed,{});Object.keys(t).forEach((function(n){var o=t[n],i=o.nodeMap;o.nodes.forEach((function(t){e.findForwardRootEdges(o,t).forEach((function(e){var o=i[e.to],a=t.label+"-"+e.label+"-"+o.label;r[a]||(r[a]={projected:[],nodeLabel1:t.label,edgeLabel:e.label,nodeLabel2:o.label});var d={graphId:n,edge:e,preNode:null};r[a].projected.push(d)}))}))})),Object.keys(r).forEach((function(t){var n=r[t],o=n.projected,i=n.nodeLabel1,a=n.edgeLabel,d=n.nodeLabel2;e.dfsCode.dfsEdgeList.push(new H(0,1,i,a,d)),e.subGraphMining(o),e.dfsCode.dfsEdgeList.pop()}))}},e}(),Q="cluster";var V=function(e,t,r,n){void 0===r&&(r="cluster"),void 0===n&&(n=2);var o=[],i=e.nodes;return t.forEach((function(e,t){o.push(X(i,e,t,r,n))})),o},X=function(e,t,r,n,o){var i=[r],a=[],d={};return t.forEach((function(t,s){if(t<=o&&r!==s){i.push(s),a.push(e[s]);var u=e[s][n];d[u]?(d[u].count++,d[u].dists.push(t)):d[u]={count:1,dists:[t]}}})),Object.keys(d).forEach((function(e){d[e].dists=d[e].dists.sort((function(e,t){return e-t}))})),{nodeIdx:r,nodeId:e[r].id,nodeIdxs:i,neighbors:a,neighborNum:i.length-1,nodeLabelCountMap:d}},Y=function(e,t,r,n){var o=r.nodes;return n||(n={}),Object.keys(e).forEach((function(i){var a,d;if(!n||!n[i]){n[i]={nodes:[],edges:[]};var s=e[i],u=null===(a=t[s.start])||void 0===a?void 0:a.nodeIdxs,f=null===(d=t[s.end])||void 0===d?void 0:d.nodeIdxs;if(u&&f){var h=new Set(f),c=u.filter((function(e){return h.has(e)}));if(c&&c.length){for(var l={},p=c.length,g=0;g<p;g++){var v=o[c[g]];n[i].nodes.push(v),l[v.id]=!0}r.edges.forEach((function(e){l[e.source]&&l[e.target]&&n[i].edges.push(e)}))}}}})),n},Z=function(e,t,r,n){var o,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],f=null==t?void 0:t.edges[0][n];e[n]===f&&(o===s&&i===u||o===u&&i===s)&&d++})),d)},$=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}},ee=function(e,t,r){var n={},o={};return e.forEach((function(e,i){n[""+u]={idx:i,edge:e};var a=e[t];o[a]||(o[a]=[]),o[a].push(e);var d=r[e.source];d&&(d.degree++,d.outDegree++);var s=r[e.target];s&&(s.degree++,s.inDegree++)})),{edgeMap:n,edgeLabelMap:o}},te=function(e,t,r){var n=t.length,o={};return t.forEach((function(t,i){for(var a=r?0:i+1,d=e[i].id,s=a;s<n;s++)if(i!==s){var u=e[s].id,f=t[s];o[d+"-"+u]=f,r||(o[u+"-"+d]=f)}})),o},re=function(e,t,r,n,o,i,a,d,s,u,f){var h,c=t.id+"-"+r.id;if(u&&u[c])return u[c];var l=f?f[c]:void 0;if(!l){var p=((h={})[c]={start:n[t.id].idx,end:n[r.id].idx,distance:o},h);l=(f=Y(p,i,e,f))[c]}return Z(l,a,d,s)},ne=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}};const oe=function(e,t,r,n,o,i,a){if(void 0===r&&(r=!1),void 0===i&&(i="cluster"),void 0===a&&(a="cluster"),e&&e.nodes){var d=e.nodes.length;if(d){var s=O(e,r),u=O(t,r),f=te(e.nodes,s,r),h=te(t.nodes,u,r),c=$(e.nodes,i),l=c.nodeMap,p=c.nodeLabelMap,g=$(t.nodes,i),v=g.nodeMap,b=g.nodeLabelMap;ee(e.edges,a,l);var E=ee(t.edges,a,v).edgeLabelMap,y=[];null==u||u.forEach((function(e){y=y.concat(e)})),o||(o=Math.max.apply(Math,m(m([],y),[2]))),n||(n=o);var L=V(e,s,i,n),N=V(t,u,i,n),M=function(e,t,r,n,o){var i=Math.ceil(r/t),a={},d=0;return n.forEach((function(e,n){for(var s=0,u=0,f=e.nodeIdxs,h=e.neighborNum-1;s<i;){for(var c=f[1+Math.floor(Math.random()*h)],l=0;(a[n+"-"+c]||a[c+"-"+n])&&(c=Math.floor(Math.random()*t),!(++l>2*t)););if(l<2*t&&(a[n+"-"+c]={start:n,end:c,distance:o[n][c]},s++,++d>=r))return a;if(++u>2*t)break}s<i&&(i=(i+(i-s))/(t-n-1))})),a}(0,d,Math.min(100,d*(d-1)/2),N,s),j=Y(M,L,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 B(a,!0,t),u={};d.nodes.forEach((function(e,t){s.addNode(t,e[r]),u[e.id]=t})),d.edges.forEach((function(e,t){var r=u[e.source],o=u[e.target];s.addEdge(-1,r,o,e[n])})),s&&s.getNodeNum()&&(o[s.id]=s)})),o}(t,n,i,d),u=e.minSupport,f=e.maxNodeNum,h=e.minNodeNum,c=e.verbose,l=e.top,p=new J({graphs:s,minSupport:u,maxNodeNum:f,minNodeNum:h,top:l,verbose:c,directed:n});return p.run(),function(e,t,r){var n=[];return e.forEach((function(e){var o={nodes:[],edges:[]};e.nodes.forEach((function(e){var r;o.nodes.push(((r={id:""+e.id})[t]=e.label,r))})),e.edges.forEach((function(e){var t;o.edges.push(((t={source:""+e.from,target:""+e.to})[r]=e.label,t))})),n.push(o)})),n}(p.frequentSubgraphs,i,d)}({graphs:j,nodeLabelProp:i,edgeLabelProp:a,minSupport:1,minNodeNum:1,maxNodeNum:4,directed:r}).slice(0,10),w=I.length,x=[];I.forEach((function(e,t){x[t]={},Object.keys(j).forEach((function(r){var n=j[r],o=Z(n,e,i,a);x[t][r]=o}))}));var D=function(e,t,r){for(var n=1/0,o=0,i=function(t){var r=e[t],i=Object.keys(r).sort((function(e,t){return r[e]-r[t]})),a=[];i.forEach((function(e,t){a[t%10]||(a[t%10]={graphs:[],totalCount:0,aveCount:0}),a[t%10].graphs.push(e),a[t%10].totalCount+=r[e]}));var d=0,s=[];a.forEach((function(e){var t=e.totalCount/e.graphs.length;e.aveCount=t,s.push(t);var n=0,o=e.length;e.graphs.forEach((function(t,o){var i=r[t];e.graphs.forEach((function(e,t){o!==t&&(n+=Math.abs(i-r[e]))}))})),d+=n/=o*(o-1)/2})),d/=a.length;var u=0;s.forEach((function(e,t){s.forEach((function(r,n){t!==n&&(u+=Math.abs(e-r))})),u/=s.length*(s.length-1)/2}));var f=u-d;n<f&&(n=f,o=t)},a=0;a<t;a++)i(a);return{structure:r[o],structureCountMap:e[o]}}(x,w,I),S=D.structure,P=D.structureCountMap,C=t.nodes[0],T=C[i],q=p[T],F={},A={},R={},U={},G={},_={};Object.keys(b).forEach((function(n,o){G[n]=[],r&&(_[n]=[]);var d=-1/0,s=b[n],u={};s.forEach((function(e){var t=h[C.id+"-"+e.id];if(t&&G[n].push(t),d<t&&(d=t),u[C.id+"-"+e.id]={start:0,end:v[e.id].idx,distance:t},r){var o=h[e.id+"-"+C.id];o&&_[n].push(o)}})),G[n]=G[n].sort((function(e,t){return e-t})),r&&(_[n]=_[n].sort((function(e,t){return e-t}))),A=Y(u,N,t,A);var c=[];if(Object.keys(u).forEach((function(e){if(R[e])c.push(R[e]);else{var t=A[e];R[e]=Z(t,S,i,a),c.push(R[e])}})),c=c.sort((function(e,t){return t-e})),U[C.id+"-"+n]=c,n!==T)for(var p=function(t){var r=q[t],o=L[l[r.id].idx],d=o.nodeLabelCountMap[n],s=b[n].length;if(!d||d.count<s)return q.splice(t,1),"continue";for(var u=!1,h=0;h<s;h++)if(d.dists[h]>G[n][h]){u=!0;break}if(u)return q.splice(t,1),"continue";var p={};o.neighbors.forEach((function(e){var t=f[r.id+"-"+e.id];p[r.id+"-"+e.id]={start:l[r.id].idx,end:l[e.id].idx,distance:t}})),j=Y(p,L,e,j);var g=[];Object.keys(p).forEach((function(e){if(P[e])g.push(P[e]);else{var t=j[e];P[e]=Z(t,S,i,a),g.push(P[e])}})),g=g.sort((function(e,t){return t-e}));var v=!1;for(h=0;h<s;h++)if(g[h]<c[h]){v=!0;break}return v?(q.splice(t,1),"continue"):void 0},g=q.length-1;g>=0;g--)p(g)}));var z=[];null==q||q.forEach((function(n){for(var d=l[n.id].idx,u=X(e.nodes,s[d],d,i,o).neighbors,h=!1,c=u.length-1;c>=0;c--){if(u.length+1<t.nodes.length)return void(h=!0);var p=u[c],g=p[i];if(b[g]&&b[g].length)if(G[g]&&G[g].length){var E=n.id+"-"+p.id,m=f[E],y=G[g].length-1;if(m>G[g][y])u.splice(c,1);else{if(r){var N=p.id+"-"+n.id,M=f[N];if(y=_[g].length-1,M>_[g][y]){u.splice(c,1);continue}}var k=P[E]?P[E]:re(e,n,p,l,m,L,S,i,a,P,j),I=C.id+"-"+g;if(k<U[I][U[I].length-1])u.splice(c,1);else{var w=ne(F,g,v,b),x=w.minPatternNodeLabelDegree;w.minPatternNodeLabelInDegree,w.minPatternNodeLabelOutDegree,l[p.id].degree<x&&u.splice(c,1)}}}else u.splice(c,1);else u.splice(c,1)}h||z.push({nodes:[n].concat(u)})}));var H=k(t,C.id,!1).length,K={};r?(Object.keys(H).forEach((function(e){var t=v[e].node[i];K[t]?K[t].push(H[e]):K[t]=[H[e]]})),Object.keys(K).forEach((function(e){K[e].sort((function(e,t){return e-t}))}))):K=G;for(var W=function(n){var o=z[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 f=[],h={};e.edges.forEach((function(e){u[e.source]&&u[e.target]&&(f.push(e),h[e[a]]?h[e[a]]++:h[e[a]]=1,u[e.source].degree++,u[e.target].degree++,u[e.source].outDegree++,u[e.target].inDegree++)}));for(var c=Object.keys(E).length,p=!1,g=0;g<c;g++){var m=Object.keys(E)[g];if(!h[m]||h[m]<E[m].length){p=!0;break}}if(p)return z.splice(n,1),"continue";var y=f.length;if(y<t.edges.length)return z.splice(n,1),"break";var L=!1,N=function(e){var t=f[e],n=t[a],o=E[n];if(!o||!o.length)return h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.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],c=!1;return o.forEach((function(e){var t=v[e.source].node,n=v[e.target].node;t[i]===d&&n[i]===s&&(c=!0),r||t[i]!==s||n[i]!==d||(c=!0)})),c?void 0:(h[n]--,o&&h[n]<o.length?(L=!0,"break"):(f.splice(e,1),u[t.source].degree--,u[t.target].degree--,u[t.source].outDegree--,u[t.target].inDegree--,"continue"))};for(g=y-1;g>=0&&"break"!==N(g);g--);if(L)return z.splice(n,1),"continue";o.edges=f;var M=k(o,o.nodes[0].id,!1).length;if(Object.keys(M).reverse().forEach((function(e){if(e!==o.nodes[0].id&&!L){if(M[e]===1/0){var t=u[e].node[i];if(s[t]--,s[t]<b[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=l[e].node[i];if(!K[n]||!K[n].length||M[e]>K[n][K[n].length-1]){if(t=u[e].node[i],s[t]--,s[t]<b[t].length)return void(L=!0);r=o.nodes.indexOf(u[e].node),o.nodes.splice(r,1),u[e]=void 0}}})),L)return z.splice(n,1),"continue";for(var j=!0,I=0;j&&!L;){if(j=!1,r?u[d.id].degree<v[C.id].degree||u[d.id].inDegree<v[C.id].inDegree||u[d.id].outDegree<v[C.id].outDegree:u[d.id].degree<v[C.id].degree){L=!0;break}if(s[d[i]]<b[d[i]].length){L=!0;break}for(var w=o.nodes.length-1;w>=0;w--){var x=o.nodes[w],O=u[x.id].degree,D=u[x.id].inDegree,S=u[x.id].outDegree,P=x[i],T=ne(F,P,v,b),q=T.minPatternNodeLabelDegree,A=T.minPatternNodeLabelInDegree,R=T.minPatternNodeLabelOutDegree;if(r?O<q||D<A||S<R:O<q){if(s[x[i]]--,s[x[i]]<b[x[i]].length){L=!0;break}o.nodes.splice(w,1),u[x.id]=void 0,j=!0}}if(L||!j&&0!==I)break;for(var U=(y=f.length)-1;U>=0;U--){var G=f[U];if(!u[G.source]||!u[G.target]){f.splice(U,1);var _=G[a];if(h[_]--,u[G.source]&&(u[G.source].degree--,u[G.source].outDegree--),u[G.target]&&(u[G.target].degree--,u[G.target].inDegree--),E[_]&&h[_]<E[_].length){L=!0;break}j=!0}}I++}return L||L||o.nodes.length<t.nodes.length||f.length<t.edges.length?(z.splice(n,1),"continue"):void 0},oe=z.length-1;oe>=0&&"break"!==W(oe);oe--);var ie=z.length,ae=function(e){var t=z[e],r={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;r[t]?r[t]++:r[t]=1}));for(var n=function(e){var t=z[e],n={};t.edges.forEach((function(e){var t=e.source+"-"+e.target+"-"+e.label;n[t]?n[t]++:n[t]=1}));var o=!0;Object.keys(n).length!==Object.keys(r).length?o=!1:Object.keys(r).forEach((function(e){n[e]!==r[e]&&(o=!1)})),o&&z.splice(e,1)},o=ie-1;o>e;o--)n(o);ie=z.length};for(oe=0;oe<=ie-1;oe++)ae(oe);return z}}};var ie="undefined"!=typeof self?self:{};ie.onmessage=function(e){var r=e.data,n=r._algorithmType,o=r.data;if(n)if("function"!=typeof t[n])ie.postMessage({_algorithmType:"FAILURE"});else{var i=t[n].apply(t,o);ie.postMessage({_algorithmType:"SUCCESS",data:i})}}})(); | ||
//# sourceMappingURL=index.worker.js.map |
@@ -183,2 +183,4 @@ import { __spreadArray } from "tslib"; | ||
var getMatchedCount = function getMatchedCount(graph, structure, nodeLabelProp, edgeLabelProp) { | ||
var _a, _b; | ||
var nodeMap = {}; | ||
@@ -189,2 +191,3 @@ graph.nodes.forEach(function (node) { | ||
var count = 0; | ||
if (!((_a = structure === null || structure === void 0 ? void 0 : structure.edges) === null || _a === void 0 ? void 0 : _a.length) || ((_b = structure === null || structure === void 0 ? void 0 : structure.nodes) === null || _b === void 0 ? void 0 : _b.length) < 2) return 0; | ||
graph.edges.forEach(function (e) { | ||
@@ -191,0 +194,0 @@ var sourceLabel = nodeMap[e.source][nodeLabelProp]; |
@@ -196,2 +196,4 @@ "use strict"; | ||
var getMatchedCount = function getMatchedCount(graph, structure, nodeLabelProp, edgeLabelProp) { | ||
var _a, _b; | ||
var nodeMap = {}; | ||
@@ -202,2 +204,3 @@ graph.nodes.forEach(function (node) { | ||
var count = 0; | ||
if (!((_a = structure === null || structure === void 0 ? void 0 : structure.edges) === null || _a === void 0 ? void 0 : _a.length) || ((_b = structure === null || structure === void 0 ? void 0 : structure.nodes) === null || _b === void 0 ? void 0 : _b.length) < 2) return 0; | ||
graph.edges.forEach(function (e) { | ||
@@ -204,0 +207,0 @@ var sourceLabel = nodeMap[e.source][nodeLabelProp]; |
{ | ||
"name": "@antv/algorithm", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "graph algorithm", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1033200
10461