@statewalker/fsm-charts 0.2.4 → 0.2.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.
Files changed (123) hide show
  1. package/dist/{chunk-AZBRQNTU.js → chunk-2LFUT2C6.js} +1062 -1110
  2. package/dist/{chunk-SVKVQY7B.js → chunk-ARZYBFNA.js} +4 -4
  3. package/dist/{chunk-36ZLXJVD.js → chunk-CR2M4445.js} +35 -33
  4. package/dist/{chunk-TZHCBZVP.js → chunk-GW2Z65BN.js} +22 -15
  5. package/dist/chunk-PKBMQBKP.js +5 -0
  6. package/dist/{chunk-VILLJJJD.js → chunk-RZ4FP6JB.js} +11 -9
  7. package/dist/index-config.js +2 -1
  8. package/dist/index-dom.js +2 -1
  9. package/dist/{index-html-DgSCNHkR.d.ts → index-html-BBQqYoST.d.ts} +10 -10
  10. package/dist/index-html.d.ts +1 -1
  11. package/dist/index-html.js +2 -1
  12. package/dist/index-layout.d.ts +15 -15
  13. package/dist/index-layout.js +2 -1
  14. package/dist/index-runtime.js +2 -1
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +6 -5
  17. package/package.json +16 -18
  18. package/src/config/concatTransitionsToString.ts +2 -2
  19. package/src/config/index.ts +4 -4
  20. package/src/config/serializeProcessConfig.ts +3 -3
  21. package/src/config/splitTransitionString.ts +2 -2
  22. package/src/config/toFsmStateConfig.ts +3 -3
  23. package/src/dagre/acyclic.js +9 -10
  24. package/src/dagre/add-border-segments.js +11 -7
  25. package/src/dagre/coordinate-system.js +12 -12
  26. package/src/dagre/data/list.js +2 -2
  27. package/src/dagre/debug.d.ts +1 -1
  28. package/src/dagre/debug.js +11 -11
  29. package/src/dagre/greedy-fas.js +17 -21
  30. package/src/dagre/index.d.ts +4 -4
  31. package/src/dagre/index.js +4 -4
  32. package/src/dagre/layout.js +107 -96
  33. package/src/dagre/nesting-graph.js +13 -19
  34. package/src/dagre/normalize.js +7 -7
  35. package/src/dagre/order/add-subgraph-constraints.js +2 -2
  36. package/src/dagre/order/barycenter.d.ts +1 -1
  37. package/src/dagre/order/barycenter.js +4 -4
  38. package/src/dagre/order/build-layer-graph.d.ts +1 -1
  39. package/src/dagre/order/build-layer-graph.js +7 -9
  40. package/src/dagre/order/cross-count.js +14 -17
  41. package/src/dagre/order/index.js +19 -17
  42. package/src/dagre/order/init-order.js +5 -15
  43. package/src/dagre/order/resolve-conflicts.js +10 -14
  44. package/src/dagre/order/sort-subgraph.d.ts +1 -1
  45. package/src/dagre/order/sort-subgraph.js +13 -14
  46. package/src/dagre/order/sort.d.ts +1 -1
  47. package/src/dagre/order/sort.js +6 -10
  48. package/src/dagre/parent-dummy-chains.js +10 -4
  49. package/src/dagre/position/bk.d.ts +3 -3
  50. package/src/dagre/position/bk.js +84 -65
  51. package/src/dagre/position/index.js +7 -11
  52. package/src/dagre/rank/feasible-tree.d.ts +1 -1
  53. package/src/dagre/rank/feasible-tree.js +6 -6
  54. package/src/dagre/rank/index.js +6 -6
  55. package/src/dagre/rank/network-simplex.d.ts +0 -1
  56. package/src/dagre/rank/network-simplex.js +20 -25
  57. package/src/dagre/rank/util.js +2 -6
  58. package/src/dagre/util.d.ts +12 -6
  59. package/src/dagre/util.js +31 -37
  60. package/src/dom/buildSections.ts +16 -12
  61. package/src/dom/description-panels.ts +3 -3
  62. package/src/dom/getStatesDescriptions.ts +1 -1
  63. package/src/full/index.ts +1 -1
  64. package/src/full/toFsmStateCharts.ts +10 -10
  65. package/src/graphlib/alg/components.js +2 -2
  66. package/src/graphlib/alg/dfs.js +5 -5
  67. package/src/graphlib/alg/dijkstra-all.js +4 -4
  68. package/src/graphlib/alg/dijkstra.js +9 -12
  69. package/src/graphlib/alg/find-cycles.js +7 -5
  70. package/src/graphlib/alg/floyd-warshall.js +8 -11
  71. package/src/graphlib/alg/index.d.ts +11 -11
  72. package/src/graphlib/alg/index.js +11 -11
  73. package/src/graphlib/alg/is-acyclic.js +1 -1
  74. package/src/graphlib/alg/postorder.js +2 -2
  75. package/src/graphlib/alg/preorder.js +2 -2
  76. package/src/graphlib/alg/prim.d.ts +1 -1
  77. package/src/graphlib/alg/prim.js +5 -5
  78. package/src/graphlib/alg/tarjan.js +3 -3
  79. package/src/graphlib/alg/topsort.js +1 -1
  80. package/src/graphlib/data/priority-queue.js +8 -10
  81. package/src/graphlib/graph.js +53 -52
  82. package/src/graphlib/index.d.ts +2 -2
  83. package/src/graphlib/index.js +2 -2
  84. package/src/graphlib/json.d.ts +1 -1
  85. package/src/graphlib/json.js +6 -6
  86. package/src/html/buildStatechartCss.ts +2 -2
  87. package/src/html/buildStatechartStyles.ts +1 -1
  88. package/src/html/buildStatechartSvg.ts +7 -7
  89. package/src/html/buildStatechartsPanel.ts +2 -2
  90. package/src/html/index.ts +4 -4
  91. package/src/index-config.ts +2 -2
  92. package/src/index-dom.ts +1 -1
  93. package/src/index-html.ts +2 -2
  94. package/src/index-layout.ts +2 -2
  95. package/src/index-runtime.ts +2 -2
  96. package/src/index.ts +8 -8
  97. package/src/layout/buildCharts.ts +5 -5
  98. package/src/layout/buildFlatCharts.ts +11 -13
  99. package/src/layout/getGraphParamsProvider.ts +5 -8
  100. package/src/layout/getLabelDimensions.ts +5 -5
  101. package/src/layout/index.ts +5 -4
  102. package/src/lodash-es/index.ts +2 -2
  103. package/src/lodash-es/types.ts +37 -35
  104. package/src/runtime/RuntimeStatechartApi.ts +12 -23
  105. package/src/runtime/StateChartIndex.ts +3 -3
  106. package/src/runtime/index.ts +2 -2
  107. package/src/types/FsmStateConfig.ts +1 -1
  108. package/src/types/GraphParamsProvider.ts +2 -2
  109. package/src/types/Position.ts +1 -1
  110. package/src/types/StateChart.ts +2 -2
  111. package/src/types/StateGraphEdge.ts +2 -2
  112. package/src/types/StateGraphNode.ts +2 -2
  113. package/src/types/TransitionsGraph.ts +4 -4
  114. package/src/types/index.ts +11 -11
  115. package/src/utils/BasisCurve.ts +3 -3
  116. package/src/utils/domToText.ts +1 -1
  117. package/src/utils/getPadding.ts +1 -1
  118. package/src/utils/newRegistry.ts +1 -1
  119. package/src/utils/serializeAttrs.ts +6 -6
  120. package/src/utils/serializeCss.ts +3 -3
  121. package/src/utils/serializeStyle.ts +2 -2
  122. package/src/utils/toKebabCase.ts +1 -1
  123. package/CHANGELOG.md +0 -1
@@ -1,6 +1,6 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import { Graph } from '../../graphlib/index.js';
3
- import * as util from '../util.js';
1
+ import { Graph } from "../../graphlib/index.js";
2
+ import { _ } from "../../lodash-es/index.ts";
3
+ import * as util from "../util.js";
4
4
 
5
5
  /*
6
6
  * This module provides coordinate assignment based on Brandes and Köpf, "Fast
@@ -50,16 +50,19 @@ function findType1Conflicts(g, layering) {
50
50
  prevLayerLength = prevLayer.length,
51
51
  lastNode = _.last(layer);
52
52
 
53
- _.forEach(layer, function (v, i) {
53
+ _.forEach(layer, (v, i) => {
54
54
  var w = findOtherInnerSegmentNode(g, v),
55
55
  k1 = w ? g.node(w).order : prevLayerLength;
56
56
 
57
57
  if (w || v === lastNode) {
58
- _.forEach(layer.slice(scanPos, i + 1), function (scanNode) {
59
- _.forEach(g.predecessors(scanNode), function (u) {
58
+ _.forEach(layer.slice(scanPos, i + 1), (scanNode) => {
59
+ _.forEach(g.predecessors(scanNode), (u) => {
60
60
  var uLabel = g.node(u),
61
61
  uPos = uLabel.order;
62
- if ((uPos < k0 || k1 < uPos) && !(uLabel.dummy && g.node(scanNode).dummy)) {
62
+ if (
63
+ (uPos < k0 || k1 < uPos) &&
64
+ !(uLabel.dummy && g.node(scanNode).dummy)
65
+ ) {
63
66
  addConflict(conflicts, u, scanNode);
64
67
  }
65
68
  });
@@ -82,12 +85,15 @@ function findType2Conflicts(g, layering) {
82
85
 
83
86
  function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) {
84
87
  var v;
85
- _.forEach(_.range(southPos, southEnd), function (i) {
88
+ _.forEach(_.range(southPos, southEnd), (i) => {
86
89
  v = south[i];
87
90
  if (g.node(v).dummy) {
88
- _.forEach(g.predecessors(v), function (u) {
91
+ _.forEach(g.predecessors(v), (u) => {
89
92
  var uNode = g.node(u);
90
- if (uNode.dummy && (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) {
93
+ if (
94
+ uNode.dummy &&
95
+ (uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)
96
+ ) {
91
97
  addConflict(conflicts, u, v);
92
98
  }
93
99
  });
@@ -100,8 +106,8 @@ function findType2Conflicts(g, layering) {
100
106
  nextNorthPos,
101
107
  southPos = 0;
102
108
 
103
- _.forEach(south, function (v, southLookahead) {
104
- if (g.node(v).dummy === 'border') {
109
+ _.forEach(south, (v, southLookahead) => {
110
+ if (g.node(v).dummy === "border") {
105
111
  var predecessors = g.predecessors(v);
106
112
  if (predecessors.length) {
107
113
  nextNorthPos = g.node(predecessors[0]).order;
@@ -123,9 +129,7 @@ function findType2Conflicts(g, layering) {
123
129
 
124
130
  function findOtherInnerSegmentNode(g, v) {
125
131
  if (g.node(v).dummy) {
126
- return _.find(g.predecessors(v), function (u) {
127
- return g.node(u).dummy;
128
- });
132
+ return _.find(g.predecessors(v), (u) => g.node(u).dummy);
129
133
  }
130
134
  }
131
135
 
@@ -160,7 +164,7 @@ function hasConflict(conflicts, v, w) {
160
164
  * we're trying to form a block with, we also ignore that possibility - our
161
165
  * blocks would be split in that scenario.
162
166
  */
163
- function verticalAlignment(g, layering, conflicts, neighborFn) {
167
+ function verticalAlignment(_g, layering, conflicts, neighborFn) {
164
168
  var root = {},
165
169
  align = {},
166
170
  pos = {};
@@ -168,26 +172,28 @@ function verticalAlignment(g, layering, conflicts, neighborFn) {
168
172
  // We cache the position here based on the layering because the graph and
169
173
  // layering may be out of sync. The layering matrix is manipulated to
170
174
  // generate different extreme alignments.
171
- _.forEach(layering, function (layer) {
172
- _.forEach(layer, function (v, order) {
175
+ _.forEach(layering, (layer) => {
176
+ _.forEach(layer, (v, order) => {
173
177
  root[v] = v;
174
178
  align[v] = v;
175
179
  pos[v] = order;
176
180
  });
177
181
  });
178
182
 
179
- _.forEach(layering, function (layer) {
183
+ _.forEach(layering, (layer) => {
180
184
  var prevIdx = -1;
181
- _.forEach(layer, function (v) {
185
+ _.forEach(layer, (v) => {
182
186
  var ws = neighborFn(v);
183
187
  if (ws.length) {
184
- ws = _.sortBy(ws, function (w) {
185
- return pos[w];
186
- });
188
+ ws = _.sortBy(ws, (w) => pos[w]);
187
189
  var mp = (ws.length - 1) / 2;
188
190
  for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) {
189
191
  var w = ws[i];
190
- if (align[v] === v && prevIdx < pos[w] && !hasConflict(conflicts, v, w)) {
192
+ if (
193
+ align[v] === v &&
194
+ prevIdx < pos[w] &&
195
+ !hasConflict(conflicts, v, w)
196
+ ) {
191
197
  align[w] = v;
192
198
  align[v] = root[v] = root[w];
193
199
  prevIdx = pos[w];
@@ -208,7 +214,7 @@ function horizontalCompaction(g, layering, root, align, reverseSep) {
208
214
  // greatest coordinates without violating separation.
209
215
  var xs = {},
210
216
  blockG = buildBlockGraph(g, layering, root, reverseSep),
211
- borderType = reverseSep ? 'borderLeft' : 'borderRight';
217
+ borderType = reverseSep ? "borderLeft" : "borderRight";
212
218
 
213
219
  function iterate(setXsFunc, nextNodesFunc) {
214
220
  var stack = blockG.nodes();
@@ -229,16 +235,19 @@ function horizontalCompaction(g, layering, root, align, reverseSep) {
229
235
 
230
236
  // First pass, assign smallest coordinates
231
237
  function pass1(elem) {
232
- xs[elem] = blockG.inEdges(elem).reduce(function (acc, e) {
233
- return Math.max(acc, xs[e.v] + blockG.edge(e));
234
- }, 0);
238
+ xs[elem] = blockG
239
+ .inEdges(elem)
240
+ .reduce((acc, e) => Math.max(acc, xs[e.v] + blockG.edge(e)), 0);
235
241
  }
236
242
 
237
243
  // Second pass, assign greatest coordinates
238
244
  function pass2(elem) {
239
- var min = blockG.outEdges(elem).reduce(function (acc, e) {
240
- return Math.min(acc, xs[e.w] - blockG.edge(e));
241
- }, Number.POSITIVE_INFINITY);
245
+ var min = blockG
246
+ .outEdges(elem)
247
+ .reduce(
248
+ (acc, e) => Math.min(acc, xs[e.w] - blockG.edge(e)),
249
+ Number.POSITIVE_INFINITY,
250
+ );
242
251
 
243
252
  var node = g.node(elem);
244
253
  if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) {
@@ -250,7 +259,7 @@ function horizontalCompaction(g, layering, root, align, reverseSep) {
250
259
  iterate(pass2, blockG.successors.bind(blockG));
251
260
 
252
261
  // Assign x coordinates to all nodes
253
- _.forEach(align, function (v) {
262
+ _.forEach(align, (v) => {
254
263
  xs[v] = xs[root[v]];
255
264
  });
256
265
 
@@ -262,15 +271,19 @@ function buildBlockGraph(g, layering, root, reverseSep) {
262
271
  graphLabel = g.graph(),
263
272
  sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
264
273
 
265
- _.forEach(layering, function (layer) {
274
+ _.forEach(layering, (layer) => {
266
275
  var u;
267
- _.forEach(layer, function (v) {
276
+ _.forEach(layer, (v) => {
268
277
  var vRoot = root[v];
269
278
  blockGraph.setNode(vRoot);
270
279
  if (u) {
271
280
  var uRoot = root[u],
272
281
  prevMax = blockGraph.edge(uRoot, vRoot);
273
- blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
282
+ blockGraph.setEdge(
283
+ uRoot,
284
+ vRoot,
285
+ Math.max(sepFn(g, v, u), prevMax || 0),
286
+ );
274
287
  }
275
288
  u = v;
276
289
  });
@@ -283,11 +296,11 @@ function buildBlockGraph(g, layering, root, reverseSep) {
283
296
  * Returns the alignment that has the smallest width of the given alignments.
284
297
  */
285
298
  function findSmallestWidthAlignment(g, xss) {
286
- return _.minBy(_.values(xss), function (xs) {
299
+ return _.minBy(_.values(xss), (xs) => {
287
300
  var max = Number.NEGATIVE_INFINITY;
288
301
  var min = Number.POSITIVE_INFINITY;
289
302
 
290
- _.forIn(xs, function (x, v) {
303
+ _.forIn(xs, (x, v) => {
291
304
  var halfWidth = width(g, v) / 2;
292
305
 
293
306
  max = Math.max(x + halfWidth, max);
@@ -310,27 +323,26 @@ function alignCoordinates(xss, alignTo) {
310
323
  alignToMin = _.min(alignToVals),
311
324
  alignToMax = _.max(alignToVals);
312
325
 
313
- _.forEach(['u', 'd'], function (vert) {
314
- _.forEach(['l', 'r'], function (horiz) {
326
+ _.forEach(["u", "d"], (vert) => {
327
+ _.forEach(["l", "r"], (horiz) => {
315
328
  var alignment = vert + horiz,
316
329
  xs = xss[alignment],
317
330
  delta;
318
331
  if (xs === alignTo) return;
319
332
 
320
333
  var xsVals = _.values(xs);
321
- delta = horiz === 'l' ? alignToMin - _.min(xsVals) : alignToMax - _.max(xsVals);
334
+ delta =
335
+ horiz === "l" ? alignToMin - _.min(xsVals) : alignToMax - _.max(xsVals);
322
336
 
323
337
  if (delta) {
324
- xss[alignment] = _.mapValues(xs, function (x) {
325
- return x + delta;
326
- });
338
+ xss[alignment] = _.mapValues(xs, (x) => x + delta);
327
339
  }
328
340
  });
329
341
  });
330
342
  }
331
343
 
332
344
  function balance(xss, align) {
333
- return _.mapValues(xss.ul, function (ignore, v) {
345
+ return _.mapValues(xss.ul, (_ignore, v) => {
334
346
  if (align) {
335
347
  return xss[align.toLowerCase()][v];
336
348
  } else {
@@ -342,26 +354,33 @@ function balance(xss, align) {
342
354
 
343
355
  function positionX(g) {
344
356
  var layering = util.buildLayerMatrix(g);
345
- var conflicts = _.merge(findType1Conflicts(g, layering), findType2Conflicts(g, layering));
357
+ var conflicts = _.merge(
358
+ findType1Conflicts(g, layering),
359
+ findType2Conflicts(g, layering),
360
+ );
346
361
 
347
362
  var xss = {};
348
363
  var adjustedLayering;
349
- _.forEach(['u', 'd'], function (vert) {
350
- adjustedLayering = vert === 'u' ? layering : _.values(layering).reverse();
351
- _.forEach(['l', 'r'], function (horiz) {
352
- if (horiz === 'r') {
353
- adjustedLayering = _.map(adjustedLayering, function (inner) {
354
- return _.values(inner).reverse();
355
- });
364
+ _.forEach(["u", "d"], (vert) => {
365
+ adjustedLayering = vert === "u" ? layering : _.values(layering).reverse();
366
+ _.forEach(["l", "r"], (horiz) => {
367
+ if (horiz === "r") {
368
+ adjustedLayering = _.map(adjustedLayering, (inner) =>
369
+ _.values(inner).reverse(),
370
+ );
356
371
  }
357
372
 
358
- var neighborFn = (vert === 'u' ? g.predecessors : g.successors).bind(g);
373
+ var neighborFn = (vert === "u" ? g.predecessors : g.successors).bind(g);
359
374
  var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn);
360
- var xs = horizontalCompaction(g, adjustedLayering, align.root, align.align, horiz === 'r');
361
- if (horiz === 'r') {
362
- xs = _.mapValues(xs, function (x) {
363
- return -x;
364
- });
375
+ var xs = horizontalCompaction(
376
+ g,
377
+ adjustedLayering,
378
+ align.root,
379
+ align.align,
380
+ horiz === "r",
381
+ );
382
+ if (horiz === "r") {
383
+ xs = _.mapValues(xs, (x) => -x);
365
384
  }
366
385
  xss[vert + horiz] = xs;
367
386
  });
@@ -373,19 +392,19 @@ function positionX(g) {
373
392
  }
374
393
 
375
394
  function sep(nodeSep, edgeSep, reverseSep) {
376
- return function (g, v, w) {
395
+ return (g, v, w) => {
377
396
  var vLabel = g.node(v);
378
397
  var wLabel = g.node(w);
379
398
  var sum = 0;
380
399
  var delta;
381
400
 
382
401
  sum += vLabel.width / 2;
383
- if (_.has(vLabel, 'labelpos')) {
402
+ if (_.has(vLabel, "labelpos")) {
384
403
  switch (vLabel.labelpos.toLowerCase()) {
385
- case 'l':
404
+ case "l":
386
405
  delta = -vLabel.width / 2;
387
406
  break;
388
- case 'r':
407
+ case "r":
389
408
  delta = vLabel.width / 2;
390
409
  break;
391
410
  }
@@ -399,12 +418,12 @@ function sep(nodeSep, edgeSep, reverseSep) {
399
418
  sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;
400
419
 
401
420
  sum += wLabel.width / 2;
402
- if (_.has(wLabel, 'labelpos')) {
421
+ if (_.has(wLabel, "labelpos")) {
403
422
  switch (wLabel.labelpos.toLowerCase()) {
404
- case 'l':
423
+ case "l":
405
424
  delta = wLabel.width / 2;
406
425
  break;
407
- case 'r':
426
+ case "r":
408
427
  delta = -wLabel.width / 2;
409
428
  break;
410
429
  }
@@ -1,6 +1,6 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import * as util from '../util.js';
3
- import { positionX } from './bk.js';
1
+ import { _ } from "../../lodash-es/index.ts";
2
+ import * as util from "../util.js";
3
+ import { positionX } from "./bk.js";
4
4
 
5
5
  export { position };
6
6
 
@@ -8,7 +8,7 @@ function position(g) {
8
8
  g = util.asNonCompoundGraph(g);
9
9
 
10
10
  positionY(g);
11
- _.forOwn(positionX(g), function (x, v) {
11
+ _.forOwn(positionX(g), (x, v) => {
12
12
  g.node(v).x = x;
13
13
  });
14
14
  }
@@ -17,13 +17,9 @@ function positionY(g) {
17
17
  var layering = util.buildLayerMatrix(g);
18
18
  var rankSep = g.graph().ranksep;
19
19
  var prevY = 0;
20
- _.forEach(layering, function (layer) {
21
- var maxHeight = _.max(
22
- _.map(layer, function (v) {
23
- return g.node(v).height;
24
- })
25
- );
26
- _.forEach(layer, function (v) {
20
+ _.forEach(layering, (layer) => {
21
+ var maxHeight = _.max(_.map(layer, (v) => g.node(v).height));
22
+ _.forEach(layer, (v) => {
27
23
  g.node(v).y = prevY + maxHeight / 2;
28
24
  });
29
25
  prevY += maxHeight + rankSep;
@@ -1,2 +1,2 @@
1
1
  export function feasibleTree(g: any): Graph;
2
- import { Graph } from '../../graphlib/index.js';
2
+ import { Graph } from "../../graphlib/index.js";
@@ -1,6 +1,6 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import { Graph } from '../../graphlib/index.js';
3
- import { slack } from './util.js';
1
+ import { Graph } from "../../graphlib/index.js";
2
+ import { _ } from "../../lodash-es/index.ts";
3
+ import { slack } from "./util.js";
4
4
 
5
5
  export { feasibleTree };
6
6
 
@@ -53,7 +53,7 @@ function feasibleTree(g) {
53
53
  */
54
54
  function tightTree(t, g) {
55
55
  function dfs(v) {
56
- _.forEach(g.nodeEdges(v), function (e) {
56
+ _.forEach(g.nodeEdges(v), (e) => {
57
57
  var edgeV = e.v,
58
58
  w = v === edgeV ? e.w : edgeV;
59
59
  if (!t.hasNode(w) && !slack(g, e)) {
@@ -73,7 +73,7 @@ function tightTree(t, g) {
73
73
  * it.
74
74
  */
75
75
  function findMinSlackEdge(t, g) {
76
- return _.minBy(g.edges(), function (e) {
76
+ return _.minBy(g.edges(), (e) => {
77
77
  if (t.hasNode(e.v) !== t.hasNode(e.w)) {
78
78
  return slack(g, e);
79
79
  }
@@ -81,7 +81,7 @@ function findMinSlackEdge(t, g) {
81
81
  }
82
82
 
83
83
  function shiftRanks(t, g, delta) {
84
- _.forEach(t.nodes(), function (v) {
84
+ _.forEach(t.nodes(), (v) => {
85
85
  g.node(v).rank += delta;
86
86
  });
87
87
  }
@@ -1,6 +1,6 @@
1
- import { feasibleTree } from './feasible-tree.js';
2
- import { networkSimplex } from './network-simplex.js';
3
- import { longestPath } from './util.js';
1
+ import { feasibleTree } from "./feasible-tree.js";
2
+ import { networkSimplex } from "./network-simplex.js";
3
+ import { longestPath } from "./util.js";
4
4
 
5
5
  export { rank };
6
6
 
@@ -25,13 +25,13 @@ export { rank };
25
25
  */
26
26
  function rank(g) {
27
27
  switch (g.graph().ranker) {
28
- case 'network-simplex':
28
+ case "network-simplex":
29
29
  networkSimplexRanker(g);
30
30
  break;
31
- case 'tight-tree':
31
+ case "tight-tree":
32
32
  tightTreeRanker(g);
33
33
  break;
34
- case 'longest-path':
34
+ case "longest-path":
35
35
  longestPathRanker(g);
36
36
  break;
37
37
  default:
@@ -13,4 +13,3 @@ declare function calcCutValue(t: any, g: any, child: any): number;
13
13
  declare function leaveEdge(tree: any): any;
14
14
  declare function enterEdge(t: any, g: any, edge: any): any;
15
15
  declare function exchangeEdges(t: any, g: any, e: any, f: any): void;
16
- export {};
@@ -1,8 +1,8 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import * as alg from '../../graphlib/alg/index.js';
3
- import { simplify } from '../util.js';
4
- import { feasibleTree } from './feasible-tree.js';
5
- import { longestPath, slack } from './util.js';
1
+ import * as alg from "../../graphlib/alg/index.js";
2
+ import { _ } from "../../lodash-es/index.ts";
3
+ import { simplify } from "../util.js";
4
+ import { feasibleTree } from "./feasible-tree.js";
5
+ import { longestPath, slack } from "./util.js";
6
6
 
7
7
  export { networkSimplex };
8
8
 
@@ -67,7 +67,7 @@ function networkSimplex(g) {
67
67
  function initCutValues(t, g) {
68
68
  var vs = alg.postorder(t, t.nodes());
69
69
  vs = vs.slice(0, vs.length - 1);
70
- _.forEach(vs, function (v) {
70
+ _.forEach(vs, (v) => {
71
71
  assignCutValue(t, g, v);
72
72
  });
73
73
  }
@@ -99,7 +99,7 @@ function calcCutValue(t, g, child) {
99
99
 
100
100
  cutValue = graphEdge.weight;
101
101
 
102
- _.forEach(g.nodeEdges(child), function (e) {
102
+ _.forEach(g.nodeEdges(child), (e) => {
103
103
  var isOutEdge = e.v === child,
104
104
  other = isOutEdge ? e.w : e.v;
105
105
 
@@ -130,7 +130,7 @@ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
130
130
  var label = tree.node(v);
131
131
 
132
132
  visited[v] = true;
133
- _.forEach(tree.neighbors(v), function (w) {
133
+ _.forEach(tree.neighbors(v), (w) => {
134
134
  if (!_.has(visited, w)) {
135
135
  nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);
136
136
  }
@@ -149,9 +149,7 @@ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
149
149
  }
150
150
 
151
151
  function leaveEdge(tree) {
152
- return _.find(tree.edges(), function (e) {
153
- return tree.edge(e).cutvalue < 0;
154
- });
152
+ return _.find(tree.edges(), (e) => tree.edge(e).cutvalue < 0);
155
153
  }
156
154
 
157
155
  function enterEdge(t, g, edge) {
@@ -178,16 +176,14 @@ function enterEdge(t, g, edge) {
178
176
  flip = true;
179
177
  }
180
178
 
181
- var candidates = _.filter(g.edges(), function (edge) {
182
- return (
179
+ var candidates = _.filter(
180
+ g.edges(),
181
+ (edge) =>
183
182
  flip === isDescendant(t, t.node(edge.v), tailLabel) &&
184
- flip !== isDescendant(t, t.node(edge.w), tailLabel)
185
- );
186
- });
183
+ flip !== isDescendant(t, t.node(edge.w), tailLabel),
184
+ );
187
185
 
188
- return _.minBy(candidates, function (edge) {
189
- return slack(g, edge);
190
- });
186
+ return _.minBy(candidates, (edge) => slack(g, edge));
191
187
  }
192
188
 
193
189
  function exchangeEdges(t, g, e, f) {
@@ -201,12 +197,10 @@ function exchangeEdges(t, g, e, f) {
201
197
  }
202
198
 
203
199
  function updateRanks(t, g) {
204
- var root = _.find(t.nodes(), function (v) {
205
- return !g.node(v).parent;
206
- });
200
+ var root = _.find(t.nodes(), (v) => !g.node(v).parent);
207
201
  var vs = alg.preorder(t, root);
208
202
  vs = vs.slice(1);
209
- _.forEach(vs, function (v) {
203
+ _.forEach(vs, (v) => {
210
204
  var parent = t.node(v).parent,
211
205
  edge = g.edge(v, parent),
212
206
  flipped = false;
@@ -216,7 +210,8 @@ function updateRanks(t, g) {
216
210
  flipped = true;
217
211
  }
218
212
 
219
- g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen);
213
+ g.node(v).rank =
214
+ g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen);
220
215
  });
221
216
  }
222
217
 
@@ -231,6 +226,6 @@ function isTreeEdge(tree, u, v) {
231
226
  * Returns true if the specified node is descendant of the root node per the
232
227
  * assigned low and lim attributes in the tree.
233
228
  */
234
- function isDescendant(tree, vLabel, rootLabel) {
229
+ function isDescendant(_tree, vLabel, rootLabel) {
235
230
  return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim;
236
231
  }
@@ -1,4 +1,4 @@
1
- import { _ } from '../../lodash-es/index.ts';
1
+ import { _ } from "../../lodash-es/index.ts";
2
2
 
3
3
  export { longestPath, slack };
4
4
 
@@ -33,11 +33,7 @@ function longestPath(g) {
33
33
  }
34
34
  visited[v] = true;
35
35
 
36
- var rank = _.min(
37
- _.map(g.outEdges(v), function (e) {
38
- return dfs(e.w) - g.edge(e).minlen;
39
- })
40
- );
36
+ var rank = _.min(_.map(g.outEdges(v), (e) => dfs(e.w) - g.edge(e).minlen));
41
37
 
42
38
  if (
43
39
  rank === Number.POSITIVE_INFINITY || // return value of _.map([]) for Lodash 3
@@ -1,11 +1,11 @@
1
1
  export function addDummyNode(g: any, type: any, attrs: any, name: any): string;
2
2
  export function simplify(g: any): Graph;
3
3
  export function asNonCompoundGraph(g: any): Graph;
4
- export function successorWeights(g: any): import('lodash').Dictionary<{}>;
5
- export function predecessorWeights(g: any): import('lodash').Dictionary<{}>;
4
+ export function successorWeights(g: any): import("lodash").Dictionary<{}>;
5
+ export function predecessorWeights(g: any): import("lodash").Dictionary<{}>;
6
6
  export function intersectRect(
7
7
  rect: any,
8
- point: any
8
+ point: any,
9
9
  ): {
10
10
  x: any;
11
11
  y: any;
@@ -13,15 +13,21 @@ export function intersectRect(
13
13
  export function buildLayerMatrix(g: any): any[][];
14
14
  export function normalizeRanks(g: any): void;
15
15
  export function removeEmptyRanks(g: any): void;
16
- export function addBorderNode(g: any, prefix: any, rank: any, order: any, ...args: any[]): string;
16
+ export function addBorderNode(
17
+ g: any,
18
+ prefix: any,
19
+ rank: any,
20
+ order: any,
21
+ ...args: any[]
22
+ ): string;
17
23
  export function maxRank(g: any): any;
18
24
  export function partition(
19
25
  collection: any,
20
- fn: any
26
+ fn: any,
21
27
  ): {
22
28
  lhs: any[];
23
29
  rhs: any[];
24
30
  };
25
31
  export function time(name: any, fn: any): any;
26
32
  export function notime(name: any, fn: any): any;
27
- import { Graph } from '../graphlib/index.js';
33
+ import { Graph } from "../graphlib/index.js";