dhotson/springy

Unstable optimisation in growing densely-connected graphs

Opened this issue · 0 comments

Consider the following code (using the springyui.js framework):

<!doctype html>
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="springy.js"></script>
<script src="springyui.js"></script>
<script>
var graph = new Springy.Graph();
var nodes = [];

jQuery(function(){
  jQuery('#springydemo').springy({graph: graph});
});

var nodeIndex = 0;
var interval = setInterval(function() {
    nodes.push(graph.newNode({label: nodeIndex.toString()}));
    for (var i = 0; i < nodeIndex; i++) {
        if (Math.random() < 0.5) graph.newEdge(nodes[nodeIndex], nodes[i]);
    }
    nodeIndex++;
}, 1500);
</script>
<canvas id="springydemo" width="640" height="480"></canvas><br>
<input type="button" onclick="clearInterval(interval)" value="Stop generating nodes"/>
</body>
</html>

That is, every 1.5 seconds we add a new node that we connect to each existing node with probability 0.5. Invariably, after a couple of nodes (14 or so), the optimisation process seems to diverge, and even if you stop adding nodes by pressing the button, the layout does not converge.

Is this perhaps a known issue, or a limitation of the optimisation process?