From c866cda90cb98768d03ae928ad75ae0d74f37ca2 Mon Sep 17 00:00:00 2001 From: Anya Date: Fri, 28 Jun 2019 11:59:13 +0200 Subject: [PATCH] Allow manual ranking --- lib/layout.js | 2 +- lib/rank/index.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/layout.js b/lib/layout.js index 26b07304..e68d8e79 100644 --- a/lib/layout.js +++ b/lib/layout.js @@ -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 = { diff --git a/lib/rank/index.js b/lib/rank/index.js index 5ec26c8d..b24a0774 100644 --- a/lib/rank/index.js +++ b/lib/rank/index.js @@ -27,10 +27,16 @@ 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; + case "none": break; default: networkSimplexRanker(g); } }