Skip to content

Commit

Permalink
Maintain the structure when dynamically add nodes
Browse files Browse the repository at this point in the history
Based on the following post:
dagrejs#201 (comment)
  • Loading branch information
ImanYZ authored Mar 21, 2020
1 parent 91005a8 commit c534abb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ function order(g) {
var bestCC = Number.POSITIVE_INFINITY,
best;

for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);
// for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
// sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);

layering = util.buildLayerMatrix(g);
var cc = crossCount(g, layering);
if (cc < bestCC) {
lastBest = 0;
best = _.cloneDeep(layering);
bestCC = cc;
}
}
// layering = util.buildLayerMatrix(g);
// var cc = crossCount(g, layering);
// if (cc < bestCC) {
// lastBest = 0;
// best = _.cloneDeep(layering);
// bestCC = cc;
// }
// }
best = _.cloneDeep(util.buildLayerMatrix(g));

assignOrder(g, best);
}
Expand Down

0 comments on commit c534abb

Please sign in to comment.