-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1 lines (1 loc) · 1.51 KB
/
index.js
1
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("@seregpie/bron-kerbosch")):"function"==typeof define&&define.amd?define(["@seregpie/bron-kerbosch"],n):(r=r||self).NearestNeighborChain=n(r.BronKerbosch)}(this,(function(r){"use strict";function n(r,n){return r[function(r,n){var e=0;return n&&(r=r.map(n)),r.reduce((function(r,n,t){return n<r&&(r=n,e=t),r})),e}(r,n)]}function e(r,n){var e=n.map((function(n){return r[n]}));return n.slice().sort((function(r,n){return n-r})).forEach((function(n){r.splice(n,1)})),e}return r=r&&r.hasOwnProperty("default")?r.default:r,function(t,u){for(var o=(t=Array.from(t)).map((function(){return t.map((function(){return 1/0}))})),f=t.length,i=0;i<f;i++)for(var a=t[i],c=i+1;c<f;c++){var p=u(a,t[c]);o[i][c]=p,o[c][i]=p}u=function(r,e){return r=[r].flat(1/0),e=[e].flat(1/0),n(r.map((function(r){return n(e.map((function(n){return o[r][n]})))})))};for(var s,l=t.map((function(r,n){return n}));l.length>2;){for(var h=[],m=1/0,v=l.length,d=0;d<v;d++)for(var g=l[d],b=d+1;b<v;b++){var y=u(g,l[b]);y<m?(m=y,h=[[d,b]]):y===m&&h.push([d,b])}h=r(h);var k=(s=h)[function(r,n){var e=0;return n&&(r=r.map(n)),r.reduce((function(r,n,t){return n>r&&(r=n,e=t),r})),e}(s,(function(r){return r.length}))];if(k.length===l.length)break;k=e(l,k),l.push(k)}return function(r){var n=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return r.call.apply(r,[this,n].concat(e))};return n}((function(r,n){return n.map((function(n){return Array.isArray(n)?r(n):t[n]}))}))(l)}}));