Force Directed : Locked Nodes

141 views
Skip to first unread message

Saneth

unread,
Jun 1, 2012, 4:11:12 AM6/1/12
to javascript-information...@googlegroups.com
Hello,

With no previous experience in InfoVis, I am discovering the toolkit.

Currently my need would be the following :

I would like to use Force Directed Graph with locked nodes, that is to say, some node with a fixed position that the algorithm will never move.

So far what I have done is forcing on each step of the calculation a position for the nodes, according to some data I have provided to them.

myGraph.computeIncremental({
            property: ['end', 'start', 'current'],
            onStep: function(perc){
               
                myGraph.graph.eachNode(function(node) {
               
                    var x = null, y = null;

                    if(node.data.pos){
                        x = node.data.pos.x;
                        y = node.data.pos.y;
                    }else if(node.data.posX && node.data.posY){
                        x = node.data.posX;
                        y = node.data.posY;
                    }

                    if(x && y){
                        var newPos = new $jit.Complex();
                        newPos.x = x;
                        newPos.y = y;
                        node.endPos.setc(parseInt(x), parseInt(y));
                    }
               
                });

            },
            onComplete: function(){
                myGraph.animate({
                    modes: ['linear'],
                    duration: 100
                });
            }
        });

This works more or less.

My understanding of the algorithm is approximate, but I have the feeling that some non-locked nodes are prevented to reach optimal position because their move is repulsed by locked ones.

Also I can see that the result is a little random, although the random factor is less important when I increase iterations.


It would be great to read some community experience input on this subject.


Is it possible to achieve in a clean and consistent way ?

If it is the case, does it require editing toolkit method, or can it be done with configuration/overriding ?

I am correct thinking that this could prevent some node from moving to more 'elegant' position ?
Reply all
Reply to author
Forward
0 new messages