Skip to content

Commit

Permalink
Prep v0.7.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt committed Dec 15, 2014
1 parent bd1c10b commit 584bf8b
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 130 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dagre",
"version": "0.6.4",
"version": "0.7.0",
"main": [
"dist/dagre.core.js",
"dist/dagre.core.min.js"
Expand Down
118 changes: 58 additions & 60 deletions dist/dagre.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ function postorder(g) {
"use strict";

var _ = require("../lodash"),
Graph = require("../graphlib").Graph,
util = require("../util");

/*
Expand Down Expand Up @@ -1994,74 +1995,71 @@ function verticalAlignment(g, layering, conflicts, neighborFn) {
}

function horizontalCompaction(g, layering, root, align, reverseSep) {
// We use local variables for these parameters instead of manipulating the
// graph because it becomes more verbose to access them in a chained manner.
var shift = {},
shiftNeighbor = {},
sink = {},
xs = {},
pred = {},
graphLabel = g.graph(),
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);

_.each(layering, function(layer) {
_.each(layer, function(v, order) {
sink[v] = v;
shift[v] = Number.POSITIVE_INFINITY;
pred[v] = layer[order - 1];
});
});

_.each(g.nodes(), function(v) {
if (root[v] === v) {
placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v);
// This portion of the algorithm differs from BK due to a number of problems.
// Instead of their algorithm we construct a new block graph and do two
// sweeps. The first sweep places blocks with the smallest possible
// coordinates. The second sweep removes unused space by moving blocks to the
// greatest coordinates without violating separation.
var xs = {},
blockG = buildBlockGraph(g, layering, root, reverseSep);

// First pass, assign smallest coordinates via DFS
var visited = {};
function pass1(v) {
if (!_.has(visited, v)) {
visited[v] = true;
xs[v] = _.reduce(blockG.inEdges(v), function(max, e) {
pass1(e.v);
return Math.max(max, xs[e.v] + blockG.edge(e));
}, 0);
}
});

_.each(layering, function(layer) {
_.each(layer, function(v) {
xs[v] = xs[root[v]];
// This line differs from the source paper. See
// http://www.inf.uni-konstanz.de/~brandes/publications/ for details.
if (v === root[v] && shift[sink[root[v]]] < Number.POSITIVE_INFINITY) {
xs[v] += shift[sink[root[v]]];

// Cascade shifts as necessary
var w = shiftNeighbor[sink[root[v]]];
if (w && shift[w] !== Number.POSITIVE_INFINITY) {
xs[v] += shift[w];
}
}
_.each(blockG.nodes(), pass1);

function pass2(v) {
if (visited[v] !== 2) {
visited[v]++;
var min = _.reduce(blockG.outEdges(v), function(min, e) {
pass2(e.w);
return Math.min(min, xs[e.w] - blockG.edge(e));
}, Number.POSITIVE_INFINITY);
if (min !== Number.POSITIVE_INFINITY) {
xs[v] = Math.max(xs[v], min);
}
});
}
}
_.each(blockG.nodes(), pass2);


// Assign x coordinates to all nodes
_.each(align, function(v) {
xs[v] = xs[root[v]];
});

return xs;
}

function placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v) {
if (_.has(xs, v)) return;
xs[v] = 0;

var w = v,
u;
do {
if (pred[w]) {
u = root[pred[w]];
placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, u);
if (sink[v] === v) {
sink[v] = sink[u];
}
function buildBlockGraph(g, layering, root, reverseSep) {
var blockGraph = new Graph(),
graphLabel = g.graph(),
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);

var delta = sepFn(g, w, pred[w]);
if (sink[v] !== sink[u]) {
shift[sink[u]] = Math.min(shift[sink[u]], xs[v] - xs[u] - delta);
shiftNeighbor[sink[u]] = sink[v];
} else {
xs[v] = Math.max(xs[v], xs[u] + delta);
_.each(layering, function(layer) {
var u;
_.each(layer, function(v) {
var vRoot = root[v];
blockGraph.setNode(vRoot);
if (u) {
var uRoot = root[u],
prevMax = blockGraph.edge(uRoot, vRoot);
blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
}
}
w = align[w];
} while (w !== v);
u = v;
});
});

return blockGraph;
}

/*
Expand Down Expand Up @@ -2188,7 +2186,7 @@ function width(g, v) {
return g.node(v).width;
}

},{"../lodash":10,"../util":29}],24:[function(require,module,exports){
},{"../graphlib":7,"../lodash":10,"../util":29}],24:[function(require,module,exports){
"use strict";

var _ = require("../lodash"),
Expand Down Expand Up @@ -2899,7 +2897,7 @@ function notime(name, fn) {
}

},{"./graphlib":7,"./lodash":10}],30:[function(require,module,exports){
module.exports = "0.6.4";
module.exports = "0.7.0";

},{}]},{},[1])(1)
});
4 changes: 2 additions & 2 deletions dist/dagre.core.min.js

Large diffs are not rendered by default.

118 changes: 58 additions & 60 deletions dist/dagre.js
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ function postorder(g) {
"use strict";

var _ = require("../lodash"),
Graph = require("../graphlib").Graph,
util = require("../util");

/*
Expand Down Expand Up @@ -1994,74 +1995,71 @@ function verticalAlignment(g, layering, conflicts, neighborFn) {
}

function horizontalCompaction(g, layering, root, align, reverseSep) {
// We use local variables for these parameters instead of manipulating the
// graph because it becomes more verbose to access them in a chained manner.
var shift = {},
shiftNeighbor = {},
sink = {},
xs = {},
pred = {},
graphLabel = g.graph(),
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);

_.each(layering, function(layer) {
_.each(layer, function(v, order) {
sink[v] = v;
shift[v] = Number.POSITIVE_INFINITY;
pred[v] = layer[order - 1];
});
});

_.each(g.nodes(), function(v) {
if (root[v] === v) {
placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v);
// This portion of the algorithm differs from BK due to a number of problems.
// Instead of their algorithm we construct a new block graph and do two
// sweeps. The first sweep places blocks with the smallest possible
// coordinates. The second sweep removes unused space by moving blocks to the
// greatest coordinates without violating separation.
var xs = {},
blockG = buildBlockGraph(g, layering, root, reverseSep);

// First pass, assign smallest coordinates via DFS
var visited = {};
function pass1(v) {
if (!_.has(visited, v)) {
visited[v] = true;
xs[v] = _.reduce(blockG.inEdges(v), function(max, e) {
pass1(e.v);
return Math.max(max, xs[e.v] + blockG.edge(e));
}, 0);
}
});
}
_.each(blockG.nodes(), pass1);

_.each(layering, function(layer) {
_.each(layer, function(v) {
xs[v] = xs[root[v]];
// This line differs from the source paper. See
// http://www.inf.uni-konstanz.de/~brandes/publications/ for details.
if (v === root[v] && shift[sink[root[v]]] < Number.POSITIVE_INFINITY) {
xs[v] += shift[sink[root[v]]];

// Cascade shifts as necessary
var w = shiftNeighbor[sink[root[v]]];
if (w && shift[w] !== Number.POSITIVE_INFINITY) {
xs[v] += shift[w];
}
function pass2(v) {
if (visited[v] !== 2) {
visited[v]++;
var min = _.reduce(blockG.outEdges(v), function(min, e) {
pass2(e.w);
return Math.min(min, xs[e.w] - blockG.edge(e));
}, Number.POSITIVE_INFINITY);
if (min !== Number.POSITIVE_INFINITY) {
xs[v] = Math.max(xs[v], min);
}
});
}
}
_.each(blockG.nodes(), pass2);


// Assign x coordinates to all nodes
_.each(align, function(v) {
xs[v] = xs[root[v]];
});

return xs;
}

function placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, v) {
if (_.has(xs, v)) return;
xs[v] = 0;

var w = v,
u;
do {
if (pred[w]) {
u = root[pred[w]];
placeBlock(g, layering, sepFn, root, align, shift, shiftNeighbor, sink, pred, xs, u);
if (sink[v] === v) {
sink[v] = sink[u];
}
function buildBlockGraph(g, layering, root, reverseSep) {
var blockGraph = new Graph(),
graphLabel = g.graph(),
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);

var delta = sepFn(g, w, pred[w]);
if (sink[v] !== sink[u]) {
shift[sink[u]] = Math.min(shift[sink[u]], xs[v] - xs[u] - delta);
shiftNeighbor[sink[u]] = sink[v];
} else {
xs[v] = Math.max(xs[v], xs[u] + delta);
}
}
w = align[w];
} while (w !== v);
_.each(layering, function(layer) {
var u;
_.each(layer, function(v) {
var vRoot = root[v];
blockGraph.setNode(vRoot);
if (u) {
var uRoot = root[u],
prevMax = blockGraph.edge(uRoot, vRoot);
blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
}
u = v;
});
});

return blockGraph;
}

/*
Expand Down Expand Up @@ -2188,7 +2186,7 @@ function width(g, v) {
return g.node(v).width;
}

},{"../lodash":10,"../util":29}],24:[function(require,module,exports){
},{"../graphlib":7,"../lodash":10,"../util":29}],24:[function(require,module,exports){
"use strict";

var _ = require("../lodash"),
Expand Down Expand Up @@ -2899,7 +2897,7 @@ function notime(name, fn) {
}

},{"./graphlib":7,"./lodash":10}],30:[function(require,module,exports){
module.exports = "0.6.4";
module.exports = "0.7.0";

},{}],31:[function(require,module,exports){
/**
Expand Down
8 changes: 4 additions & 4 deletions dist/dagre.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = "0.6.5-pre";
module.exports = "0.7.0";
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dagre",
"version": "0.6.5-pre",
"version": "0.7.0",
"description": "Graph layout for JavaScript",
"author": "Chris Pettitt <cpettitt@gmail.com>",
"main": "index.js",
Expand Down Expand Up @@ -36,4 +36,4 @@
"url": "https://github.com/cpettitt/dagre.git"
},
"license": "MIT"
}
}

0 comments on commit 584bf8b

Please sign in to comment.