iwmlib/pixi/lib/graphology-layout-forceatlas2.min.js
2019-03-21 09:57:27 +01:00

1 line
8.6 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.forceAtlas2=e():t.forceAtlas2=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(n){if(o[n])return o[n].exports;var a=o[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var o={};return e.m=t,e.c=o,e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,o){function n(t,e,o){if(!r(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");"number"==typeof o&&(o={iterations:o});var n=o.iterations;if("number"!=typeof n)throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(n<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var a=s.assign({},u,o.settings),l=s.validateSettings(a);if(l)throw new Error("graphology-layout-forceatlas2: "+l.message);var g,f=s.graphToByteArrays(e);for(g=0;g<n;g++)i(a,f.nodes,f.edges);return t?void s.applyLayoutChanges(e,f.nodes):s.collectLayoutChanges(e,f.nodes)}function a(t){var e=t.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}}var r=o(1),i=o(2),s=o(3),u=o(4),l=n.bind(null,!1);l.assign=n.bind(null,!0),l.inferSettings=a,t.exports=l},function(t,e){t.exports=function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.addUndirectedEdgeWithKey&&"function"==typeof t.dropNodes&&"boolean"==typeof t.multi}},function(t,e){t.exports=function(t,e,o){var n,a,r,i,s,u,l,g,f,h,d,b,c,p,y,M=e.length,w=o.length,m=[];for(r=0;r<M;r+=10)e[r+4]=e[r+2],e[r+5]=e[r+3],e[r+2]=0,e[r+3]=0;if(t.outboundAttractionDistribution){for(f=0,r=0;r<M;r+=10)f+=e[r+6];f/=M}if(t.barnesHutOptimize){var v,A,D,x=1/0,z=-1/0,j=1/0,q=-1/0;for(r=0;r<M;r+=10)x=Math.min(x,e[r+0]),z=Math.max(z,e[r+0]),j=Math.min(j,e[r+1]),q=Math.max(q,e[r+1]);var H=z-x,S=q-j;for(H>S?(j-=(H-S)/2,q=j+H):(x-=(S-H)/2,z=x+S),m[0]=-1,m[1]=(x+z)/2,m[2]=(j+q)/2,m[3]=Math.max(z-x,q-j),m[4]=-1,m[5]=-1,m[6]=0,m[7]=0,m[8]=0,n=1,r=0;r<M;r+=10)for(a=0,D=3;;){if(!(m[a+5]>=0)){if(m[a+0]<0){m[a+0]=r;break}if(m[a+5]=9*n,l=m[a+3]/2,g=m[a+5],m[g+0]=-1,m[g+1]=m[a+1]-l,m[g+2]=m[a+2]-l,m[g+3]=l,m[g+4]=g+9,m[g+5]=-1,m[g+6]=0,m[g+7]=0,m[g+8]=0,g+=9,m[g+0]=-1,m[g+1]=m[a+1]-l,m[g+2]=m[a+2]+l,m[g+3]=l,m[g+4]=g+9,m[g+5]=-1,m[g+6]=0,m[g+7]=0,m[g+8]=0,g+=9,m[g+0]=-1,m[g+1]=m[a+1]+l,m[g+2]=m[a+2]-l,m[g+3]=l,m[g+4]=g+9,m[g+5]=-1,m[g+6]=0,m[g+7]=0,m[g+8]=0,g+=9,m[g+0]=-1,m[g+1]=m[a+1]+l,m[g+2]=m[a+2]+l,m[g+3]=l,m[g+4]=m[a+4],m[g+5]=-1,m[g+6]=0,m[g+7]=0,m[g+8]=0,n+=4,v=e[m[a+0]+0]<m[a+1]?e[m[a+0]+1]<m[a+2]?m[a+5]:m[a+5]+9:e[m[a+0]+1]<m[a+2]?m[a+5]+18:m[a+5]+27,m[a+6]=e[m[a+0]+6],m[a+7]=e[m[a+0]+0],m[a+8]=e[m[a+0]+1],m[v+0]=m[a+0],m[a+0]=-1,A=e[r+0]<m[a+1]?e[r+1]<m[a+2]?m[a+5]:m[a+5]+9:e[r+1]<m[a+2]?m[a+5]+18:m[a+5]+27,v===A){if(D--){a=v;continue}D=3;break}m[A+0]=r;break}v=e[r+0]<m[a+1]?e[r+1]<m[a+2]?m[a+5]:m[a+5]+9:e[r+1]<m[a+2]?m[a+5]+18:m[a+5]+27,m[a+7]=(m[a+7]*m[a+6]+e[r+0]*e[r+6])/(m[a+6]+e[r+6]),m[a+8]=(m[a+8]*m[a+6]+e[r+1]*e[r+6])/(m[a+6]+e[r+6]),m[a+6]+=e[r+6],a=v}}if(t.barnesHutOptimize)for(h=t.scalingRatio,r=0;r<M;r+=10)for(a=0;;)if(m[a+5]>=0){if(p=Math.sqrt(Math.pow(e[r+0]-m[a+7],2)+Math.pow(e[r+1]-m[a+8],2)),2*m[a+3]/p<t.barnesHutTheta){if(d=e[r+0]-m[a+7],b=e[r+1]-m[a+8],t.adjustSizes?p>0?(y=h*e[r+6]*m[a+6]/p/p,e[r+2]+=d*y,e[r+3]+=b*y):p<0&&(y=-h*e[r+6]*m[a+6]/p,e[r+2]+=d*y,e[r+3]+=b*y):p>0&&(y=h*e[r+6]*m[a+6]/p/p,e[r+2]+=d*y,e[r+3]+=b*y),m[a+4]<0)break;a=m[a+4];continue}a=m[a+5]}else{if(m[a+0]>=0&&m[a+0]!==r&&(d=e[r+0]-e[m[a+0]+0],b=e[r+1]-e[m[a+0]+1],p=Math.sqrt(d*d+b*b),t.adjustSizes?p>0?(y=h*e[r+6]*e[m[a+0]+6]/p/p,e[r+2]+=d*y,e[r+3]+=b*y):p<0&&(y=-h*e[r+6]*e[m[a+0]+6]/p,e[r+2]+=d*y,e[r+3]+=b*y):p>0&&(y=h*e[r+6]*e[m[a+0]+6]/p/p,e[r+2]+=d*y,e[r+3]+=b*y)),m[a+4]<0)break;a=m[a+4]}else for(h=t.scalingRatio,i=0;i<M;i+=10)for(s=0;s<i;s+=10)d=e[i+0]-e[s+0],b=e[i+1]-e[s+1],t.adjustSizes?(p=Math.sqrt(d*d+b*b)-e[i+8]-e[s+8],p>0?(y=h*e[i+6]*e[s+6]/p/p,e[i+2]+=d*y,e[i+3]+=b*y,e[s+2]+=d*y,e[s+3]+=b*y):p<0&&(y=100*h*e[i+6]*e[s+6],e[i+2]+=d*y,e[i+3]+=b*y,e[s+2]-=d*y,e[s+3]-=b*y)):(p=Math.sqrt(d*d+b*b))>0&&(y=h*e[i+6]*e[s+6]/p/p,e[i+2]+=d*y,e[i+3]+=b*y,e[s+2]-=d*y,e[s+3]-=b*y);for(g=t.gravity/t.scalingRatio,h=t.scalingRatio,r=0;r<M;r+=10)y=0,d=e[r+0],b=e[r+1],p=Math.sqrt(Math.pow(d,2)+Math.pow(b,2)),t.strongGravityMode?p>0&&(y=h*e[r+6]*g):p>0&&(y=h*e[r+6]*g/p),e[r+2]-=d*y,e[r+3]-=b*y;for(h=1*(t.outboundAttractionDistribution?f:1),u=0;u<w;u+=3)i=o[u+0],s=o[u+1],l=o[u+2],c=Math.pow(l,t.edgeWeightInfluence),d=e[i+0]-e[s+0],b=e[i+1]-e[s+1],t.adjustSizes?(p=Math.sqrt(Math.pow(d,2)+Math.pow(b,2)-e[i+8]-e[s+8]),t.linLogMode?t.outboundAttractionDistribution?p>0&&(y=-h*c*Math.log(1+p)/p/e[i+6]):p>0&&(y=-h*c*Math.log(1+p)/p):t.outboundAttractionDistribution?p>0&&(y=-h*c/e[i+6]):p>0&&(y=-h*c)):(p=Math.sqrt(Math.pow(d,2)+Math.pow(b,2)),t.linLogMode?t.outboundAttractionDistribution?p>0&&(y=-h*c*Math.log(1+p)/p/e[i+6]):p>0&&(y=-h*c*Math.log(1+p)/p):t.outboundAttractionDistribution?(p=1,y=-h*c/e[i+6]):(p=1,y=-h*c)),p>0&&(e[i+2]+=d*y,e[i+3]+=b*y,e[s+2]-=d*y,e[s+3]-=b*y);var O,L,R,T;if(t.adjustSizes)for(r=0;r<M;r+=10)e[r+9]||(O=Math.sqrt(Math.pow(e[r+2],2)+Math.pow(e[r+3],2)),O>10&&(e[r+2]=10*e[r+2]/O,e[r+3]=10*e[r+3]/O),L=e[r+6]*Math.sqrt((e[r+4]-e[r+2])*(e[r+4]-e[r+2])+(e[r+5]-e[r+3])*(e[r+5]-e[r+3])),R=Math.sqrt((e[r+4]+e[r+2])*(e[r+4]+e[r+2])+(e[r+5]+e[r+3])*(e[r+5]+e[r+3]))/2,T=.1*Math.log(1+R)/(1+Math.sqrt(L)),e[r+0]=e[r+0]+e[r+2]*(T/t.slowDown),e[r+1]=e[r+1]+e[r+3]*(T/t.slowDown));else for(r=0;r<M;r+=10)e[r+9]||(L=e[r+6]*Math.sqrt((e[r+4]-e[r+2])*(e[r+4]-e[r+2])+(e[r+5]-e[r+3])*(e[r+5]-e[r+3])),R=Math.sqrt((e[r+4]+e[r+2])*(e[r+4]+e[r+2])+(e[r+5]+e[r+3])*(e[r+5]+e[r+3]))/2,T=e[r+7]*Math.log(1+R)/(1+Math.sqrt(L)),e[r+7]=Math.min(1,Math.sqrt(T*(Math.pow(e[r+2],2)+Math.pow(e[r+3],2))/(1+Math.sqrt(L)))),e[r+0]=e[r+0]+e[r+2]*(T/t.slowDown),e[r+1]=e[r+1]+e[r+3]*(T/t.slowDown));return{}}},function(t,e){e.assign=function(t){t=t||{};var e,o,n,a=Array.prototype.slice.call(arguments).slice(1);for(e=0,n=a.length;e<n;e++)if(a[e])for(o in a[e])t[o]=a[e][o];return t},e.validateSettings=function(t){return"linLogMode"in t&&"boolean"!=typeof t.linLogMode?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&"boolean"!=typeof t.outboundAttractionDistribution?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&"boolean"!=typeof t.adjustSizes?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&"number"!=typeof t.edgeWeightInfluence&&t.edgeWeightInfluence<0?{message:"the `edgeWeightInfluence` setting should be a number >= 0."}:"scalingRatio"in t&&"number"!=typeof t.scalingRatio&&t.scalingRatio<0?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&"boolean"!=typeof t.strongGravityMode?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&"number"!=typeof t.gravity&&t.gravity<0?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&"number"!=typeof t.slowDown&&t.slowDown<0?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&"boolean"!=typeof t.barnesHutOptimize?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&"number"!=typeof t.barnesHutTheta&&t.barnesHutTheta<0?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},e.graphToByteArrays=function(t){var e,o,n=t.nodes(),a=t.edges(),r=n.length,i=a.length,s={},u=new Float32Array(10*r),l=new Float32Array(3*i);for(e=o=0;e<r;e++)s[n[e]]=o,u[o]=t.getNodeAttribute(n[e],"x"),u[o+1]=t.getNodeAttribute(n[e],"y"),u[o+2]=0,u[o+3]=0,u[o+4]=0,u[o+5]=0,u[o+6]=1+t.degree(n[e]),u[o+7]=1,u[o+8]=t.getNodeAttribute(n[e],"size")||1,u[o+9]=0,o+=10;for(e=o=0;e<i;e++)l[o]=s[t.source(a[e])],l[o+1]=s[t.target(a[e])],l[o+2]=t.getEdgeAttribute(a[e],"weight")||0,o+=3;return{nodes:u,edges:l}},e.applyLayoutChanges=function(t,e){for(var o=t.nodes(),n=0,a=0,r=e.length;n<r;n+=10)t.setNodeAttribute(o[a],"x",e[n]),t.setNodeAttribute(o[a],"y",e[n+1]),a++},e.collectLayoutChanges=function(t,e){for(var o=t.nodes(),n=Object.create(null),a=0,r=0,i=e.length;a<i;a+=10)n[o[r]]={x:e[a],y:e[a+1]},r++;return n}},function(t,e){t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:0,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}}])});