@dagrejs/dagre 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dagre.js +12 -6
- package/dist/dagre.min.js +4 -4
- package/index.d.ts +4 -4
- package/lib/layout.js +1 -1
- package/lib/rank/index.js +6 -0
- package/lib/util.js +4 -4
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/dist/dagre.js
CHANGED
|
@@ -532,7 +532,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
|
|
|
532
532
|
let graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
|
|
533
533
|
let graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
|
|
534
534
|
let graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
|
|
535
|
-
let nodeNumAttrs = ["width", "height"];
|
|
535
|
+
let nodeNumAttrs = ["width", "height", "rank"];
|
|
536
536
|
let nodeDefaults = { width: 0, height: 0 };
|
|
537
537
|
let edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
|
|
538
538
|
let edgeDefaults = {
|
|
@@ -2330,10 +2330,16 @@ module.exports = rank;
|
|
|
2330
2330
|
* fix them up later.
|
|
2331
2331
|
*/
|
|
2332
2332
|
function rank(g) {
|
|
2333
|
+
var ranker = g.graph().ranker;
|
|
2334
|
+
if (ranker instanceof Function) {
|
|
2335
|
+
return ranker(g);
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2333
2338
|
switch(g.graph().ranker) {
|
|
2334
2339
|
case "network-simplex": networkSimplexRanker(g); break;
|
|
2335
2340
|
case "tight-tree": tightTreeRanker(g); break;
|
|
2336
2341
|
case "longest-path": longestPathRanker(g); break;
|
|
2342
|
+
case "none": break;
|
|
2337
2343
|
default: networkSimplexRanker(g);
|
|
2338
2344
|
}
|
|
2339
2345
|
}
|
|
@@ -2690,10 +2696,10 @@ module.exports = {
|
|
|
2690
2696
|
* Adds a dummy node to the graph and return v.
|
|
2691
2697
|
*/
|
|
2692
2698
|
function addDummyNode(g, type, attrs, name) {
|
|
2693
|
-
|
|
2694
|
-
|
|
2699
|
+
var v = name;
|
|
2700
|
+
while (g.hasNode(v)) {
|
|
2695
2701
|
v = uniqueId(name);
|
|
2696
|
-
}
|
|
2702
|
+
}
|
|
2697
2703
|
|
|
2698
2704
|
attrs.dummy = type;
|
|
2699
2705
|
g.setNode(v, attrs);
|
|
@@ -2937,7 +2943,7 @@ function notime(name, fn) {
|
|
|
2937
2943
|
let idCounter = 0;
|
|
2938
2944
|
function uniqueId(prefix) {
|
|
2939
2945
|
var id = ++idCounter;
|
|
2940
|
-
return
|
|
2946
|
+
return prefix + ("" + id);
|
|
2941
2947
|
}
|
|
2942
2948
|
|
|
2943
2949
|
function range(start, limit, step = 1) {
|
|
@@ -2990,7 +2996,7 @@ function zipObject(props, values) {
|
|
|
2990
2996
|
}
|
|
2991
2997
|
|
|
2992
2998
|
},{"@dagrejs/graphlib":29}],28:[function(require,module,exports){
|
|
2993
|
-
module.exports = "1.1.
|
|
2999
|
+
module.exports = "1.1.5";
|
|
2994
3000
|
|
|
2995
3001
|
},{}],29:[function(require,module,exports){
|
|
2996
3002
|
/**
|
package/dist/dagre.min.js
CHANGED
|
@@ -44,7 +44,7 @@ g.edges().forEach(e=>{let prevWeight=fasGraph.edge(e.v,e.w)||0;let weight=weight
|
|
|
44
44
|
* graph. This process only copies whitelisted attributes from the layout graph
|
|
45
45
|
* to the input graph, so it serves as a good place to determine what
|
|
46
46
|
* attributes can influence layout.
|
|
47
|
-
*/function updateInputGraph(inputGraph,layoutGraph){inputGraph.nodes().forEach(v=>{let inputLabel=inputGraph.node(v);let layoutLabel=layoutGraph.node(v);if(inputLabel){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y;inputLabel.rank=layoutLabel.rank;if(layoutGraph.children(v).length){inputLabel.width=layoutLabel.width;inputLabel.height=layoutLabel.height}}});inputGraph.edges().forEach(e=>{let inputLabel=inputGraph.edge(e);let layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points;if(Object.hasOwn(layoutLabel,"x")){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y}});inputGraph.graph().width=layoutGraph.graph().width;inputGraph.graph().height=layoutGraph.graph().height}let graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"];let graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"};let graphAttrs=["acyclicer","ranker","rankdir","align"];let nodeNumAttrs=["width","height"];let nodeDefaults={width:0,height:0};let edgeNumAttrs=["minlen","weight","width","height","labeloffset"];let edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"};let edgeAttrs=["labelpos"];
|
|
47
|
+
*/function updateInputGraph(inputGraph,layoutGraph){inputGraph.nodes().forEach(v=>{let inputLabel=inputGraph.node(v);let layoutLabel=layoutGraph.node(v);if(inputLabel){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y;inputLabel.rank=layoutLabel.rank;if(layoutGraph.children(v).length){inputLabel.width=layoutLabel.width;inputLabel.height=layoutLabel.height}}});inputGraph.edges().forEach(e=>{let inputLabel=inputGraph.edge(e);let layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points;if(Object.hasOwn(layoutLabel,"x")){inputLabel.x=layoutLabel.x;inputLabel.y=layoutLabel.y}});inputGraph.graph().width=layoutGraph.graph().width;inputGraph.graph().height=layoutGraph.graph().height}let graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"];let graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"};let graphAttrs=["acyclicer","ranker","rankdir","align"];let nodeNumAttrs=["width","height","rank"];let nodeDefaults={width:0,height:0};let edgeNumAttrs=["minlen","weight","width","height","labeloffset"];let edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"};let edgeAttrs=["labelpos"];
|
|
48
48
|
/*
|
|
49
49
|
* Constructs a new graph from the input graph, which can be used for layout.
|
|
50
50
|
* This process copies only whitelisted attributes from the input graph to the
|
|
@@ -365,7 +365,7 @@ var start=g.nodes()[0];var size=g.nodeCount();t.setNode(start,{});var edge,delta
|
|
|
365
365
|
* 1. Graph nodes will have a "rank" attribute based on the results of the
|
|
366
366
|
* algorithm. Ranks can start at any index (including negative), we'll
|
|
367
367
|
* fix them up later.
|
|
368
|
-
*/function rank(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)}}
|
|
368
|
+
*/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)}}
|
|
369
369
|
// A fast and simple ranker, but results are far from optimal.
|
|
370
370
|
var longestPathRanker=longestPath;function tightTreeRanker(g){longestPath(g);feasibleTree(g)}function networkSimplexRanker(g){networkSimplex(g)}},{"./feasible-tree":23,"./network-simplex":25,"./util":26}],25:[function(require,module,exports){"use strict";var feasibleTree=require("./feasible-tree");var slack=require("./util").slack;var initRank=require("./util").longestPath;var preorder=require("@dagrejs/graphlib").alg.preorder;var postorder=require("@dagrejs/graphlib").alg.postorder;var simplify=require("../util").simplify;module.exports=networkSimplex;
|
|
371
371
|
// Expose some internals for testing purposes
|
|
@@ -461,7 +461,7 @@ if(vLabel.lim>wLabel.lim){tailLabel=wLabel;flip=true}var candidates=g.edges().fi
|
|
|
461
461
|
"use strict";let Graph=require("@dagrejs/graphlib").Graph;module.exports={addBorderNode:addBorderNode,addDummyNode:addDummyNode,applyWithChunking:applyWithChunking,asNonCompoundGraph:asNonCompoundGraph,buildLayerMatrix:buildLayerMatrix,intersectRect:intersectRect,mapValues:mapValues,maxRank:maxRank,normalizeRanks:normalizeRanks,notime:notime,partition:partition,pick:pick,predecessorWeights:predecessorWeights,range:range,removeEmptyRanks:removeEmptyRanks,simplify:simplify,successorWeights:successorWeights,time:time,uniqueId:uniqueId,zipObject:zipObject};
|
|
462
462
|
/*
|
|
463
463
|
* Adds a dummy node to the graph and return v.
|
|
464
|
-
*/function addDummyNode(g,type,attrs,name){
|
|
464
|
+
*/function addDummyNode(g,type,attrs,name){var v=name;while(g.hasNode(v)){v=uniqueId(name)}attrs.dummy=type;g.setNode(v,attrs);return v}
|
|
465
465
|
/*
|
|
466
466
|
* Returns a new graph with only simple edges. Handles aggregation of data
|
|
467
467
|
* associated with multi-edges.
|
|
@@ -495,7 +495,7 @@ let nodeRanks=g.nodes().map(v=>g.node(v).rank);let offset=applyWithChunking(Math
|
|
|
495
495
|
/*
|
|
496
496
|
* Returns a new function that wraps `fn` with a timer. The wrapper logs the
|
|
497
497
|
* time it takes to execute the function.
|
|
498
|
-
*/function time(name,fn){let start=Date.now();try{return fn()}finally{console.log(name+" time: "+(Date.now()-start)+"ms")}}function notime(name,fn){return fn()}let idCounter=0;function uniqueId(prefix){var id=++idCounter;return
|
|
498
|
+
*/function time(name,fn){let start=Date.now();try{return fn()}finally{console.log(name+" time: "+(Date.now()-start)+"ms")}}function notime(name,fn){return fn()}let idCounter=0;function uniqueId(prefix){var id=++idCounter;return prefix+(""+id)}function range(start,limit,step=1){if(limit==null){limit=start;start=0}let endCon=i=>i<limit;if(step<0){endCon=i=>limit<i}const range=[];for(let i=start;endCon(i);i+=step){range.push(i)}return range}function pick(source,keys){const dest={};for(const key of keys){if(source[key]!==undefined){dest[key]=source[key]}}return dest}function mapValues(obj,funcOrProp){let func=funcOrProp;if(typeof funcOrProp==="string"){func=val=>val[funcOrProp]}return Object.entries(obj).reduce((acc,[k,v])=>{acc[k]=func(v,k);return acc},{})}function zipObject(props,values){return props.reduce((acc,key,i)=>{acc[key]=values[i];return acc},{})}},{"@dagrejs/graphlib":29}],28:[function(require,module,exports){module.exports="1.1.5"},{}],29:[function(require,module,exports){
|
|
499
499
|
/**
|
|
500
500
|
* Copyright (c) 2014, Chris Pettitt
|
|
501
501
|
* All rights reserved.
|
package/index.d.ts
CHANGED
|
@@ -29,14 +29,14 @@ declare module '@dagrejs/dagre' {
|
|
|
29
29
|
setEdge(params: Edge, value?: string | { [key: string]: any }): Graph<T>;
|
|
30
30
|
setEdge(sourceId: string, targetId: string, value?: string | Label, name?: string): Graph<T>;
|
|
31
31
|
|
|
32
|
-
children(parentName: string): string
|
|
32
|
+
children(parentName: string): string[];
|
|
33
33
|
hasNode(name: string): boolean;
|
|
34
|
-
neighbors(name: string):
|
|
34
|
+
neighbors(name: string): string[] | undefined;
|
|
35
35
|
node(id: string | Label): Node<T>;
|
|
36
36
|
nodeCount(): number;
|
|
37
37
|
nodes(): string[];
|
|
38
38
|
parent(childName: string): string | undefined;
|
|
39
|
-
predecessors(name: string):
|
|
39
|
+
predecessors(name: string): string[] | undefined;
|
|
40
40
|
removeNode(name: string): Graph<T>;
|
|
41
41
|
filterNodes(callback: (nodeId: string) => boolean): Graph<T>;
|
|
42
42
|
setDefaultNodeLabel(callback: string | ((nodeId: string) => string | Label)): Graph<T>;
|
|
@@ -44,7 +44,7 @@ declare module '@dagrejs/dagre' {
|
|
|
44
44
|
setParent(childName: string, parentName: string): void;
|
|
45
45
|
sinks(): Array<Node<T>>;
|
|
46
46
|
sources(): Array<Node<T>>;
|
|
47
|
-
successors(name: string):
|
|
47
|
+
successors(name: string): string[] | undefined;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
namespace json {
|
package/lib/layout.js
CHANGED
|
@@ -97,7 +97,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
|
|
|
97
97
|
let graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
|
|
98
98
|
let graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
|
|
99
99
|
let graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
|
|
100
|
-
let nodeNumAttrs = ["width", "height"];
|
|
100
|
+
let nodeNumAttrs = ["width", "height", "rank"];
|
|
101
101
|
let nodeDefaults = { width: 0, height: 0 };
|
|
102
102
|
let edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
|
|
103
103
|
let edgeDefaults = {
|
package/lib/rank/index.js
CHANGED
|
@@ -27,10 +27,16 @@ module.exports = rank;
|
|
|
27
27
|
* fix them up later.
|
|
28
28
|
*/
|
|
29
29
|
function rank(g) {
|
|
30
|
+
var ranker = g.graph().ranker;
|
|
31
|
+
if (ranker instanceof Function) {
|
|
32
|
+
return ranker(g);
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
switch(g.graph().ranker) {
|
|
31
36
|
case "network-simplex": networkSimplexRanker(g); break;
|
|
32
37
|
case "tight-tree": tightTreeRanker(g); break;
|
|
33
38
|
case "longest-path": longestPathRanker(g); break;
|
|
39
|
+
case "none": break;
|
|
34
40
|
default: networkSimplexRanker(g);
|
|
35
41
|
}
|
|
36
42
|
}
|
package/lib/util.js
CHANGED
|
@@ -31,10 +31,10 @@ module.exports = {
|
|
|
31
31
|
* Adds a dummy node to the graph and return v.
|
|
32
32
|
*/
|
|
33
33
|
function addDummyNode(g, type, attrs, name) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var v = name;
|
|
35
|
+
while (g.hasNode(v)) {
|
|
36
36
|
v = uniqueId(name);
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
39
|
attrs.dummy = type;
|
|
40
40
|
g.setNode(v, attrs);
|
|
@@ -278,7 +278,7 @@ function notime(name, fn) {
|
|
|
278
278
|
let idCounter = 0;
|
|
279
279
|
function uniqueId(prefix) {
|
|
280
280
|
var id = ++idCounter;
|
|
281
|
-
return
|
|
281
|
+
return prefix + ("" + id);
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
function range(start, limit, step = 1) {
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = "1.1.
|
|
1
|
+
module.exports = "1.1.5";
|