arbor icon indicating copy to clipboard operation
arbor copied to clipboard

Single-node graph

Open ZoltanLajosKis opened this issue 13 years ago • 10 comments

If I start off with a graph consisting of a single node, then the node will start running around like I was doing a Brownian motion simulation. Furthermore, if I later add nodes and edges to this graph, the initial node will stabilize in the center, but the new nodes and edges will not appear. Also, after this, firefox dies pretty soon because of low resources.

I'm using the basic example codes, with the following settings: sys = arbor.ParticleSystem(1000, 600, 0.5); sys.parameters({gravity:true});

To reproduce, in $(document). ... do: sys.addNode('a') window.setTimeout(add,3000);

and in add(), add additional elements:

function add() { sys.addNode('b'); sys.addEdge('b', 'a'); }

ZoltanLajosKis avatar Jul 18 '11 21:07 ZoltanLajosKis

I'm having this problem too. Very frustrating

chrisbeach avatar Oct 07 '11 12:10 chrisbeach

Will offer a £25 bounty to anyone who can fix this to the satisfaction of the author, samizdatco

chrisbeach avatar Oct 07 '11 12:10 chrisbeach

In the meantime I checked out d3.js. There the solution for the "jerking" problem seems to be that every node has an invisible edge connected to the center of the canvas. This makes sure that the graph tends to the center, while not losing on overall shape.

As for the rest of my problem, I wonder if it is caused by the jerking, or is completely independent.

ZoltanLajosKis avatar Oct 07 '11 13:10 ZoltanLajosKis

Thanks Zoltan. Checking out d3.js now...

2011/10/7 Zoltán Lajos Kis [email protected]:

In the meantime I checked out d3.js. There the solution for the "jerking" problem seems to be that every node has an invisible edge connected to the center of the canvas. This makes sure that the graph tends to the center, while not losing on overall shape.

As for the rest of my problem, I wonder if it is caused by the jerking, or is completely independent.

Reply to this email directly or view it on GitHub: https://github.com/samizdatco/arbor/issues/12#issuecomment-2321270

chrisbeach avatar Oct 07 '11 14:10 chrisbeach

I am also experiencing this problem.

kflorence avatar Dec 12 '11 01:12 kflorence

I've come up with a workaround that 'solves' the problem. This issue occurs when you are adding nodes dynamically, and not loading anything initially.

The resolution is as follows (I realize its hacky, but it 'works'):

var temp= {}; temp["initialNode"] = { 'color': 'red', 'shape': 'dot', 'label': '' };

var data = {
    nodes: temp,
    edges: {}
};
sys.graft(data);
setTimeout(function () {
    sys.pruneNode("initialNode");
}, 2000);

For whatever reason, it solved the problem for me

MichaelPar avatar May 28 '13 23:05 MichaelPar

Here's another solution taken from this stackoverflow post.

// We assume 'system' is your ParticleSystem

// First we need this function
function countNodes() {
    var count = 0;

    system.eachNode(function() {
        count++;
    });

    return count;
}

// Then, in the redraw() method of your renderer try this:
var friction = countNodes() === 1 ? 1.0 : 0.5;
system.parameters({ friction : friction });

hay avatar Jun 28 '13 10:06 hay

Thanks very much for your sharing. Now I have an extra problem in arborjs. I add a text besides every edge,the text will be jittered if I dragged any node serval times and now the page will be crashed if I refresh it. Have you met similar situations?Or some suggestions? Thanks in advance!

Jianbin Wang

JianbinWang avatar Nov 11 '13 13:11 JianbinWang

It's 2017 and I'm also having the single spastic node problem.. Is this project still alive (I realize the last commit is in 2012)?

herbertml avatar Jan 18 '17 16:01 herbertml

i try to add a virtual node(color is white and label is '') when the node has only one, and obviously it works

x8142831 avatar Jan 25 '18 00:01 x8142831