Skip to content

Commit

Permalink
Allow manual ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
Anya committed Jun 27, 2019
1 parent 52b2b4f commit cdd91d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
var graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
var graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
var nodeNumAttrs = ["width", "height"];
var nodeNumAttrs = ["width", "height", "rank"],
var nodeDefaults = { width: 0, height: 0 };
var edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
var edgeDefaults = {
Expand Down
15 changes: 11 additions & 4 deletions lib/rank/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ module.exports = rank;
* fix them up later.
*/
function rank(g) {
var ranker = g.graph().ranker;
if (ranker instanceof Function) {
return ranker(g)
}

switch(g.graph().ranker) {
case "network-simplex": networkSimplexRanker(g); break;
case "tight-tree": tightTreeRanker(g); break;
case "longest-path": longestPathRanker(g); break;
default: networkSimplexRanker(g);
case "network-simplex": networkSimplexRanker(g); break;
case "tight-tree": tightTreeRanker(g); break;
case "longest-path": longestPathRanker(g); break;
case "none": break;
default: networkSimplexRanker(g);
}
}


// A fast and simple ranker, but results are far from optimal.
var longestPathRanker = longestPath;

Expand Down

0 comments on commit cdd91d0

Please sign in to comment.