Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-force

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-force - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

22

build/d3-force.js

@@ -7,3 +7,3 @@ (function (global, factory) {

var version = "0.6.0";
var version = "0.6.1";

@@ -151,3 +151,3 @@ function center(x, y) {

var id = index,
strength = constant(0.7),
strength = defaultStrength,
strengths,

@@ -157,2 +157,3 @@ distance = constant(30),

nodes,
count,
bias,

@@ -163,2 +164,6 @@ iterations = 1;

function defaultStrength(link) {
return 1 / Math.min(count[link.source.index], count[link.target.index]);
}
function force(alpha) {

@@ -187,11 +192,10 @@ for (var k = 0, n = links.length; k < iterations; ++k) {

m = links.length,
count = new Array(n),
nodeById = d3Collection.map(nodes, id),
link;
for (i = 0; i < n; ++i) {
for (i = 0, count = new Array(n); i < n; ++i) {
count[i] = 0;
}
for (i = 0, bias = new Array(m); i < m; ++i) {
for (i = 0; i < m; ++i) {
link = links[i], link.index = i;

@@ -203,3 +207,3 @@ if (typeof link.source !== "object") link.source = nodeById.get(link.source);

for (i = 0; i < m; ++i) {
for (i = 0, bias = new Array(m); i < m; ++i) {
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);

@@ -216,3 +220,3 @@ }

for (var i = 0, n = links.length; i < n; ++i) {
strengths[i] = +strength(links[i]);
strengths[i] = +strength(links[i], i, links);
}

@@ -225,3 +229,3 @@ }

for (var i = 0, n = links.length; i < n; ++i) {
distances[i] = +distance(links[i]);
distances[i] = +distance(links[i], i, links);
}

@@ -393,3 +397,3 @@ }

alpha,
strength = constant(-100),
strength = constant(-30),
strengths,

@@ -396,0 +400,0 @@ distanceMin2 = 1,

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-quadtree"),require("d3-collection"),require("d3-dispatch"),require("d3-timer")):"function"==typeof define&&define.amd?define(["exports","d3-quadtree","d3-collection","d3-dispatch","d3-timer"],t):t(n.d3_force=n.d3_force||{},n.d3_quadtree,n.d3_collection,n.d3_dispatch,n.d3_timer)}(this,function(n,t,e,r,i){"use strict";function o(n,t){function e(){var e,i,o=r.length,u=0,f=0;for(e=0;o>e;++e)i=r[e],u+=i.x,f+=i.y;for(u=u/o-n,f=f/o-t,e=0;o>e;++e)i=r[e],i.x-=u,i.y-=f}var r;return null==n&&(n=0),null==t&&(t=0),e.initialize=function(n){r=n},e.x=function(t){return arguments.length?(n=+t,e):n},e.y=function(n){return arguments.length?(t=+n,e):t},e}function u(n){return function(){return n}}function f(){return 1e-6*(Math.random()-.5)}function a(n){return n.x+n.vx}function c(n){return n.y+n.vy}function l(n){function e(){function n(n,t,r,i,o){var u=n.data,a=n.r,c=x+a;{if(!u)return t>y+c||y-c>i||r>d+c||d-c>o;if(u.index>e){var h=y-u.x-u.vx,s=d-u.y-u.vy,p=h*h+s*s;c*c>p&&(0===h&&(h=f(),p+=h*h),0===s&&(s=f(),p+=s*s),p=(c-(p=Math.sqrt(p)))/p*l,v.vx+=(h*=p)*(c=(a*=a)/(g+a)),v.vy+=(s*=p)*c,u.vx-=h*(c=1-c),u.vy-=s*c)}}}for(var e,u,v,y,d,x,g,s=i.length,p=0;h>p;++p)for(u=t.quadtree(i,a,c).visitAfter(r),e=0;s>e;++e)v=i[e],x=o[e],g=x*x,y=v.x+v.vx,d=v.y+v.vy,u.visit(n)}function r(n){if(n.data)return n.r=o[n.data.index];for(var t=n.r=0;4>t;++t)n[t]&&n[t].r>n.r&&(n.r=n[t].r)}var i,o,l=1,h=1;return"function"!=typeof n&&(n=u(null==n?1:+n)),e.initialize=function(t){var e,r=(i=t).length;for(o=new Array(r),e=0;r>e;++e)o[e]=+n(i[e],e,i)},e.iterations=function(n){return arguments.length?(h=+n,e):h},e.strength=function(n){return arguments.length?(l=+n,e):l},e.radius=function(t){return arguments.length?(n="function"==typeof t?t:u(+t),e):n},e}function h(n,t){return t}function v(n){function t(t){for(var e=0,r=n.length;g>e;++e)for(var i,o,u,l,h,y,d,x=0;r>x;++x)i=n[x],o=i.source,u=i.target,l=u.x+u.vx-o.x-o.vx||f(),h=u.y+u.vy-o.y-o.vy||f(),y=Math.sqrt(l*l+h*h),y=(y-c[x])/y*t*a[x],l*=y,h*=y,u.vx-=l*(d=v[x]),u.vy-=h*d,o.vx+=l*(d=1-d),o.vy+=h*d}function r(){if(l){var t,r,u=l.length,f=n.length,h=new Array(u),d=e.map(l,y);for(t=0;u>t;++t)h[t]=0;for(t=0,v=new Array(f);f>t;++t)r=n[t],r.index=t,"object"!=typeof r.source&&(r.source=d.get(r.source)),"object"!=typeof r.target&&(r.target=d.get(r.target)),++h[r.source.index],++h[r.target.index];for(t=0;f>t;++t)r=n[t],v[t]=h[r.source.index]/(h[r.source.index]+h[r.target.index]);a=new Array(f),i(),c=new Array(f),o()}}function i(){if(l)for(var t=0,e=n.length;e>t;++t)a[t]=+d(n[t])}function o(){if(l)for(var t=0,e=n.length;e>t;++t)c[t]=+x(n[t])}var a,c,l,v,y=h,d=u(.7),x=u(30),g=1;return null==n&&(n=[]),t.initialize=function(n){l=n,r()},t.links=function(e){return arguments.length?(n=e,r(),t):n},t.id=function(n){return arguments.length?(y=n,t):y},t.iterations=function(n){return arguments.length?(g=+n,t):g},t.strength=function(n){return arguments.length?(d="function"==typeof n?n:u(+n),i(),t):d},t.distance=function(n){return arguments.length?(x="function"==typeof n?n:u(+n),o(),t):x},t}function y(n){return n.x}function d(n){return n.y}function x(n){function t(){o(),s.call("tick",a),l>c&&(g.stop(),s.call("end",a))}function o(){var t,e,r,i=n.length;for(c+=(v-c)*h,d.each(function(n){n(c)}),t=0;i>t;++t)e=n[t],e.x+=e.vx*=y,e.y+=e.vy*=y;for(t in x)r=x[t],e=n[t],e.x=r.x,e.y=r.y,e.vx=e.vy=0}function u(){for(var t,e=0,r=n.length;r>e;++e){if(t=n[e],t.index=e,isNaN(t.x)||isNaN(t.y)){var i=M*Math.sqrt(e),o=e*w;t.x=i*Math.cos(o),t.y=i*Math.sin(o)}(isNaN(t.vx)||isNaN(t.vy))&&(t.vx=t.vy=0)}}function f(t){return t.initialize&&t.initialize(n),t}var a,c=1,l=.001,h=1-Math.pow(l,1/300),v=0,y=.6,d=e.map(),x={},g=i.timer(t),s=r.dispatch("tick","end");return null==n&&(n=[]),u(),a={tick:o,restart:function(){return g.restart(t),a},stop:function(){return g.stop(),a},nodes:function(t){return arguments.length?(n=t,u(),d.each(f),a):n},alpha:function(n){return arguments.length?(c=+n,a):c},alphaMin:function(n){return arguments.length?(l=+n,a):l},alphaDecay:function(n){return arguments.length?(h=+n,a):+h},alphaTarget:function(n){return arguments.length?(v=+n,a):v},drag:function(n){return arguments.length?(y=1-n,a):1-y},force:function(n,t){return arguments.length>1?(null==t?d.remove(n):d.set(n,f(t)),a):d.get(n)},fix:function(n,t,e){return x[n.index]={x:null==t?n.x:+t,y:null==e?n.y:+e},a},unfix:function(n){return delete x[n.index],a},on:function(n,t){return arguments.length>1?(s.on(n,t),a):s.on(n)}}}function g(){function n(n){var e,u=o.length,f=t.quadtree(o,y,d).visitAfter(r);for(c=n,e=0;u>e;++e)a=o[e],f.visit(i)}function e(){if(o){var n,t=o.length;for(l=new Array(t),n=0;t>n;++n)l[n]=+h(o[n],n,o)}}function r(n){var t,e,r,i,o,u=0;if(n.length){for(r=i=o=0;4>o;++o)(t=n[o])&&(e=t.value)&&(u+=e,r+=e*t.x,i+=e*t.y);n.x=r/u,n.y=i/u}else{t=n,t.x=t.data.x,t.y=t.data.y;do u+=l[t.data.index];while(t=t.next)}n.value=u}function i(n,t,e,r){if(!n.value)return!0;var i=n.x-a.x,o=n.y-a.y,u=r-t,h=i*i+o*o;if(h>u*u/g)return x>h&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)),a.vx+=i*n.value*c/h,a.vy+=o*n.value*c/h),!0;if(!(n.length||h>=x)){(n.data!==a||n.next)&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)));do n.data!==a&&(u=l[n.data.index]*c/h,a.vx+=i*u,a.vy+=o*u);while(n=n.next)}}var o,a,c,l,h=u(-100),v=1,x=1/0,g=.81;return n.initialize=function(n){o=n,e()},n.strength=function(t){return arguments.length?(h="function"==typeof t?t:u(+t),e(),n):h},n.distanceMin=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n.distanceMax=function(t){return arguments.length?(x=t*t,n):Math.sqrt(x)},n.theta=function(t){return arguments.length?(g=t*t,n):Math.sqrt(g)},n}function s(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vx+=(o[e]-t.x)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.x=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}function p(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vy+=(o[e]-t.y)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.y=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}var q="0.6.0",M=10,w=Math.PI*(3-Math.sqrt(5));n.version=q,n.forceCenter=o,n.forceCollide=l,n.forceLink=v,n.forceManyBody=g,n.forceSimulation=x,n.forceX=s,n.forceY=p});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-quadtree"),require("d3-collection"),require("d3-dispatch"),require("d3-timer")):"function"==typeof define&&define.amd?define(["exports","d3-quadtree","d3-collection","d3-dispatch","d3-timer"],t):t(n.d3_force=n.d3_force||{},n.d3_quadtree,n.d3_collection,n.d3_dispatch,n.d3_timer)}(this,function(n,t,e,r,i){"use strict";function o(n,t){function e(){var e,i,o=r.length,u=0,f=0;for(e=0;o>e;++e)i=r[e],u+=i.x,f+=i.y;for(u=u/o-n,f=f/o-t,e=0;o>e;++e)i=r[e],i.x-=u,i.y-=f}var r;return null==n&&(n=0),null==t&&(t=0),e.initialize=function(n){r=n},e.x=function(t){return arguments.length?(n=+t,e):n},e.y=function(n){return arguments.length?(t=+n,e):t},e}function u(n){return function(){return n}}function f(){return 1e-6*(Math.random()-.5)}function a(n){return n.x+n.vx}function c(n){return n.y+n.vy}function l(n){function e(){function n(n,t,r,i,o){var u=n.data,a=n.r,c=x+a;{if(!u)return t>d+c||d-c>i||r>y+c||y-c>o;if(u.index>e){var h=d-u.x-u.vx,s=y-u.y-u.vy,p=h*h+s*s;c*c>p&&(0===h&&(h=f(),p+=h*h),0===s&&(s=f(),p+=s*s),p=(c-(p=Math.sqrt(p)))/p*l,v.vx+=(h*=p)*(c=(a*=a)/(g+a)),v.vy+=(s*=p)*c,u.vx-=h*(c=1-c),u.vy-=s*c)}}}for(var e,u,v,d,y,x,g,s=i.length,p=0;h>p;++p)for(u=t.quadtree(i,a,c).visitAfter(r),e=0;s>e;++e)v=i[e],x=o[e],g=x*x,d=v.x+v.vx,y=v.y+v.vy,u.visit(n)}function r(n){if(n.data)return n.r=o[n.data.index];for(var t=n.r=0;4>t;++t)n[t]&&n[t].r>n.r&&(n.r=n[t].r)}var i,o,l=1,h=1;return"function"!=typeof n&&(n=u(null==n?1:+n)),e.initialize=function(t){var e,r=(i=t).length;for(o=new Array(r),e=0;r>e;++e)o[e]=+n(i[e],e,i)},e.iterations=function(n){return arguments.length?(h=+n,e):h},e.strength=function(n){return arguments.length?(l=+n,e):l},e.radius=function(t){return arguments.length?(n="function"==typeof t?t:u(+t),e):n},e}function h(n,t){return t}function v(n){function t(n){return 1/Math.min(d[n.source.index],d[n.target.index])}function r(t){for(var e=0,r=n.length;p>e;++e)for(var i,o,u,a,h,v,d,x=0;r>x;++x)i=n[x],o=i.source,u=i.target,a=u.x+u.vx-o.x-o.vx||f(),h=u.y+u.vy-o.y-o.vy||f(),v=Math.sqrt(a*a+h*h),v=(v-l[x])/v*t*c[x],a*=v,h*=v,u.vx-=a*(d=y[x]),u.vy-=h*d,o.vx+=a*(d=1-d),o.vy+=h*d}function i(){if(v){var t,r,i=v.length,u=n.length,f=e.map(v,x);for(t=0,d=new Array(i);i>t;++t)d[t]=0;for(t=0;u>t;++t)r=n[t],r.index=t,"object"!=typeof r.source&&(r.source=f.get(r.source)),"object"!=typeof r.target&&(r.target=f.get(r.target)),++d[r.source.index],++d[r.target.index];for(t=0,y=new Array(u);u>t;++t)r=n[t],y[t]=d[r.source.index]/(d[r.source.index]+d[r.target.index]);c=new Array(u),o(),l=new Array(u),a()}}function o(){if(v)for(var t=0,e=n.length;e>t;++t)c[t]=+g(n[t],t,n)}function a(){if(v)for(var t=0,e=n.length;e>t;++t)l[t]=+s(n[t],t,n)}var c,l,v,d,y,x=h,g=t,s=u(30),p=1;return null==n&&(n=[]),r.initialize=function(n){v=n,i()},r.links=function(t){return arguments.length?(n=t,i(),r):n},r.id=function(n){return arguments.length?(x=n,r):x},r.iterations=function(n){return arguments.length?(p=+n,r):p},r.strength=function(n){return arguments.length?(g="function"==typeof n?n:u(+n),o(),r):g},r.distance=function(n){return arguments.length?(s="function"==typeof n?n:u(+n),a(),r):s},r}function d(n){return n.x}function y(n){return n.y}function x(n){function t(){o(),s.call("tick",a),l>c&&(g.stop(),s.call("end",a))}function o(){var t,e,r,i=n.length;for(c+=(v-c)*h,y.each(function(n){n(c)}),t=0;i>t;++t)e=n[t],e.x+=e.vx*=d,e.y+=e.vy*=d;for(t in x)r=x[t],e=n[t],e.x=r.x,e.y=r.y,e.vx=e.vy=0}function u(){for(var t,e=0,r=n.length;r>e;++e){if(t=n[e],t.index=e,isNaN(t.x)||isNaN(t.y)){var i=q*Math.sqrt(e),o=e*w;t.x=i*Math.cos(o),t.y=i*Math.sin(o)}(isNaN(t.vx)||isNaN(t.vy))&&(t.vx=t.vy=0)}}function f(t){return t.initialize&&t.initialize(n),t}var a,c=1,l=.001,h=1-Math.pow(l,1/300),v=0,d=.6,y=e.map(),x={},g=i.timer(t),s=r.dispatch("tick","end");return null==n&&(n=[]),u(),a={tick:o,restart:function(){return g.restart(t),a},stop:function(){return g.stop(),a},nodes:function(t){return arguments.length?(n=t,u(),y.each(f),a):n},alpha:function(n){return arguments.length?(c=+n,a):c},alphaMin:function(n){return arguments.length?(l=+n,a):l},alphaDecay:function(n){return arguments.length?(h=+n,a):+h},alphaTarget:function(n){return arguments.length?(v=+n,a):v},drag:function(n){return arguments.length?(d=1-n,a):1-d},force:function(n,t){return arguments.length>1?(null==t?y.remove(n):y.set(n,f(t)),a):y.get(n)},fix:function(n,t,e){return x[n.index]={x:null==t?n.x:+t,y:null==e?n.y:+e},a},unfix:function(n){return delete x[n.index],a},on:function(n,t){return arguments.length>1?(s.on(n,t),a):s.on(n)}}}function g(){function n(n){var e,u=o.length,f=t.quadtree(o,d,y).visitAfter(r);for(c=n,e=0;u>e;++e)a=o[e],f.visit(i)}function e(){if(o){var n,t=o.length;for(l=new Array(t),n=0;t>n;++n)l[n]=+h(o[n],n,o)}}function r(n){var t,e,r,i,o,u=0;if(n.length){for(r=i=o=0;4>o;++o)(t=n[o])&&(e=t.value)&&(u+=e,r+=e*t.x,i+=e*t.y);n.x=r/u,n.y=i/u}else{t=n,t.x=t.data.x,t.y=t.data.y;do u+=l[t.data.index];while(t=t.next)}n.value=u}function i(n,t,e,r){if(!n.value)return!0;var i=n.x-a.x,o=n.y-a.y,u=r-t,h=i*i+o*o;if(h>u*u/g)return x>h&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)),a.vx+=i*n.value*c/h,a.vy+=o*n.value*c/h),!0;if(!(n.length||h>=x)){(n.data!==a||n.next)&&(0===i&&(i=f(),h+=i*i),0===o&&(o=f(),h+=o*o),v>h&&(h=Math.sqrt(v*h)));do n.data!==a&&(u=l[n.data.index]*c/h,a.vx+=i*u,a.vy+=o*u);while(n=n.next)}}var o,a,c,l,h=u(-30),v=1,x=1/0,g=.81;return n.initialize=function(n){o=n,e()},n.strength=function(t){return arguments.length?(h="function"==typeof t?t:u(+t),e(),n):h},n.distanceMin=function(t){return arguments.length?(v=t*t,n):Math.sqrt(v)},n.distanceMax=function(t){return arguments.length?(x=t*t,n):Math.sqrt(x)},n.theta=function(t){return arguments.length?(g=t*t,n):Math.sqrt(g)},n}function s(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vx+=(o[e]-t.x)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.x=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}function p(n){function t(n){for(var t,e=0,u=r.length;u>e;++e)t=r[e],t.vy+=(o[e]-t.y)*i[e]*n}function e(){if(r){var t,e=r.length;for(i=new Array(e),o=new Array(e),t=0;e>t;++t)i[t]=+f(r[t],t,r),o[t]=+n(r[t],t,r)}}var r,i,o,f=u(.1);return"function"!=typeof n&&(n=u(null==n?0:+n)),t.initialize=function(n){r=n,e()},t.strength=function(n){return arguments.length?(f="function"==typeof n?n:u(+n),e(),t):f},t.y=function(r){return arguments.length?(n="function"==typeof r?r:u(+r),e(),t):n},t}var M="0.6.1",q=10,w=Math.PI*(3-Math.sqrt(5));n.version=M,n.forceCenter=o,n.forceCollide=l,n.forceLink=v,n.forceManyBody=g,n.forceSimulation=x,n.forceX=s,n.forceY=p});
export var name = "d3-force";
export var version = "0.6.0";
export var version = "0.6.1";
export var description = "Force-directed graph layout using velocity Verlet integration.";

@@ -4,0 +4,0 @@ export var keywords = ["d3","layout","network","graphc","force","verlet","infovis"];

{
"name": "d3-force",
"version": "0.6.0",
"version": "0.6.1",
"description": "Force-directed graph layout using velocity Verlet integration.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -84,3 +84,3 @@ # d3-force

If *decay* is specified, sets the [*alpha*](#simulation_alpha) decay rate to the specified number in [0,1] and returns this simulation. If *decay* is not specified, returns the current *alpha* decay rate, which defaults to 0.0228… = 1 - *pow*(0.001, 1 / 300).
If *decay* is specified, sets the [*alpha*](#simulation_alpha) decay rate to the specified number in [0,1] and returns this simulation. If *decay* is not specified, returns the current *alpha* decay rate, which defaults to 0.0228… = 1 - *pow*(0.001, 1 / 300) where 0.001 is the default [minimum *alpha*](#simulation_alphaMin).

@@ -298,7 +298,9 @@ The alpha decay rate determines how quickly the current alpha interpolates towards the desired [target *alpha*](#simulation_alphaTarget); since the default target *alpha* is zero, by default this controls how quickly the simulation cools. Higher decay rates cause the simulation to stabilize more quickly, but risk getting stuck in a local minimum; lower values cause the simulation to take longer to run, but typically converge on a better layout. To have the simulation run forever at the current *alpha*, set the *decay* rate to zero; alternatively, set a [target *alpha*](#simulation_alphaTarget) greater than the [minimum *alpha*](#simulation_alphaMin).

```js
function strength() {
return 0.7;
function strength(link) {
return 1 / Math.min(count(link.source), count(link.target));
}
```
Where *count*(*node*) is a function that returns the number of links with the given node as a source or target. This default was chosen because it automatically reduces the strength of links connected to heavily-connected nodes, improving stability.
The strength accessor is invoked for each [link](#link_links), being passed the *link* and its zero-based *index*. The resulting number is then stored internally, such that the strength of each link is only recomputed when the force is initialized or when this method is called, and not on every application of the force.

@@ -326,3 +328,3 @@

function strength() {
return -100;
return -30;
}

@@ -329,0 +331,0 @@ ```

@@ -11,3 +11,3 @@ import constant from "./constant";

var id = index,
strength = constant(0.7),
strength = defaultStrength,
strengths,

@@ -17,2 +17,3 @@ distance = constant(30),

nodes,
count,
bias,

@@ -23,2 +24,6 @@ iterations = 1;

function defaultStrength(link) {
return 1 / Math.min(count[link.source.index], count[link.target.index]);
}
function force(alpha) {

@@ -47,11 +52,10 @@ for (var k = 0, n = links.length; k < iterations; ++k) {

m = links.length,
count = new Array(n),
nodeById = map(nodes, id),
link;
for (i = 0; i < n; ++i) {
for (i = 0, count = new Array(n); i < n; ++i) {
count[i] = 0;
}
for (i = 0, bias = new Array(m); i < m; ++i) {
for (i = 0; i < m; ++i) {
link = links[i], link.index = i;

@@ -63,3 +67,3 @@ if (typeof link.source !== "object") link.source = nodeById.get(link.source);

for (i = 0; i < m; ++i) {
for (i = 0, bias = new Array(m); i < m; ++i) {
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);

@@ -76,3 +80,3 @@ }

for (var i = 0, n = links.length; i < n; ++i) {
strengths[i] = +strength(links[i]);
strengths[i] = +strength(links[i], i, links);
}

@@ -85,3 +89,3 @@ }

for (var i = 0, n = links.length; i < n; ++i) {
distances[i] = +distance(links[i]);
distances[i] = +distance(links[i], i, links);
}

@@ -88,0 +92,0 @@ }

@@ -10,3 +10,3 @@ import constant from "./constant";

alpha,
strength = constant(-100),
strength = constant(-30),
strengths,

@@ -13,0 +13,0 @@ distanceMin2 = 1,

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc