From 60723173d22ddc032dbecb066196d3dbb8e92a1a Mon Sep 17 00:00:00 2001 From: ethan-keller Date: Tue, 18 Jan 2022 16:45:43 +0100 Subject: [PATCH 1/2] Add align and acyclicer layout option --- cytoscape-dagre.js | 4 ++++ src/defaults.js | 3 +++ src/layout.js | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cytoscape-dagre.js b/cytoscape-dagre.js index c0506dfd..96bacd25 100644 --- a/cytoscape-dagre.js +++ b/cytoscape-dagre.js @@ -190,7 +190,9 @@ DagreLayout.prototype.run = function () { setGObj('edgesep', options.edgeSep); setGObj('ranksep', options.rankSep); setGObj('rankdir', options.rankDir); + setGObj('align', options.align); setGObj('ranker', options.ranker); + setGObj('acyclicer', options.acyclicer); g.setGraph(gObj); g.setDefaultEdgeLabel(function () { return {}; @@ -304,6 +306,8 @@ var defaults = { rankSep: undefined, // the separation between adjacent nodes in the same rank rankDir: undefined, + // alignment for rank nodes. Can be 'UL', 'UR', 'DL', or 'DR', where U = up, D = down, L = left, and R = right + align: undefined, // 'TB' for top to bottom flow, 'LR' for left to right, ranker: undefined, // Type of algorithm to assigns a rank to each node in the input graph. diff --git a/src/defaults.js b/src/defaults.js index f1ee6f05..106137d1 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -4,6 +4,9 @@ let defaults = { edgeSep: undefined, // the separation between adjacent edges in the same rank rankSep: undefined, // the separation between adjacent nodes in the same rank rankDir: undefined, // 'TB' for top to bottom flow, 'LR' for left to right, + align: undefined, // alignment for rank nodes. Can be 'UL', 'UR', 'DL', or 'DR', where U = up, D = down, L = left, and R = right + acyclicer: undefined, // If set to 'greedy', uses a greedy heuristic for finding a feedback arc set for a graph. + // A feedback arc set is a set of edges that can be removed to make a graph acyclic. ranker: undefined, // Type of algorithm to assigns a rank to each node in the input graph. // Possible values: network-simplex, tight-tree or longest-path minLen: function( edge ){ return 1; }, // number of ranks to keep between the source and target of the edge diff --git a/src/layout.js b/src/layout.js index bff132af..79ed913a 100644 --- a/src/layout.js +++ b/src/layout.js @@ -43,7 +43,9 @@ DagreLayout.prototype.run = function(){ setGObj( 'edgesep', options.edgeSep ); setGObj( 'ranksep', options.rankSep ); setGObj( 'rankdir', options.rankDir ); + setGObj( 'align', options.align); setGObj( 'ranker', options.ranker ); + setGObj( 'acyclicer', options.acyclicer); g.setGraph( gObj ); From 19feca84956a531f7d138d1edf93d39ca5115755 Mon Sep 17 00:00:00 2001 From: ethan-keller Date: Tue, 18 Jan 2022 16:46:02 +0100 Subject: [PATCH 2/2] Add align and acyclicer to readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2c628432..8ca6937c 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,9 @@ var defaults = { edgeSep: undefined, // the separation between adjacent edges in the same rank rankSep: undefined, // the separation between each rank in the layout rankDir: undefined, // 'TB' for top to bottom flow, 'LR' for left to right, + align: undefined, // alignment for rank nodes. Can be 'UL', 'UR', 'DL', or 'DR', where U = up, D = down, L = left, and R = right + acyclicer: undefined, // If set to 'greedy', uses a greedy heuristic for finding a feedback arc set for a graph. + // A feedback arc set is a set of edges that can be removed to make a graph acyclic. ranker: undefined, // Type of algorithm to assign a rank to each node in the input graph. Possible values: 'network-simplex', 'tight-tree' or 'longest-path' minLen: function( edge ){ return 1; }, // number of ranks to keep between the source and target of the edge edgeWeight: function( edge ){ return 1; }, // higher weight edges are generally made shorter and straighter than lower weight edges