Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Fix memory usage issue caused by adding same node multiple times
Browse files Browse the repository at this point in the history
This issue happens when multiple nodes share same target node, and
will consume lots of memory and slow down the layout calculation
greatly when a graph being rendered is close to a complete bipartite
graph at each step of the flow.
  • Loading branch information
hongtaobai committed Sep 3, 2014
1 parent 6400fd4 commit 65730dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sankey/sankey.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ d3.sankey = function() {
remainingNodes.forEach(function(node) {
node.x = x;
node.dx = nodeWidth;
node.sourceLinks.forEach(function(link) {
nextNodes.push(link.target);
node.sourceLinks.forEach(function (link) {
if (nextNodes.indexOf(link.target) == -1) {
nextNodes.push(link.target);
}
});
});
remainingNodes = nextNodes;
Expand Down

0 comments on commit 65730dc

Please sign in to comment.