@knowvah/dot-engine 2.12.1 → 2.12.3
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/api/builder.d.ts +7 -1
- package/dist/api/builder.d.ts.map +1 -1
- package/dist/api.js +14 -7
- package/dist/api.js.map +2 -2
- package/dist/common/compass-port.d.ts.map +1 -1
- package/dist/common/edge-label-init.d.ts +26 -1
- package/dist/common/edge-label-init.d.ts.map +1 -1
- package/dist/common/graph-init.d.ts.map +1 -1
- package/dist/common/htmltable-label.d.ts.map +1 -1
- package/dist/common/htmltable-lex.d.ts +3 -1
- package/dist/common/htmltable-lex.d.ts.map +1 -1
- package/dist/common/htmltable-parse-image.d.ts +23 -0
- package/dist/common/htmltable-parse-image.d.ts.map +1 -0
- package/dist/common/htmltable-parse-state.d.ts +4 -0
- package/dist/common/htmltable-parse-state.d.ts.map +1 -1
- package/dist/common/htmltable-parse.d.ts +33 -2
- package/dist/common/htmltable-parse.d.ts.map +1 -1
- package/dist/common/nodeinit.d.ts +16 -2
- package/dist/common/nodeinit.d.ts.map +1 -1
- package/dist/common/poly-inside.d.ts.map +1 -1
- package/dist/common/splines-geom.d.ts +2 -1
- package/dist/common/splines-geom.d.ts.map +1 -1
- package/dist/common/splines-path-begin.d.ts.map +1 -1
- package/dist/common/splines-path-end.d.ts.map +1 -1
- package/dist/common/splines-routespl.d.ts +3 -0
- package/dist/common/splines-routespl.d.ts.map +1 -1
- package/dist/gvc/context.d.ts +8 -0
- package/dist/gvc/context.d.ts.map +1 -1
- package/dist/gvc/emit-gates.d.ts +5 -10
- package/dist/gvc/emit-gates.d.ts.map +1 -1
- package/dist/gvc/emit-xdot.d.ts +7 -6
- package/dist/gvc/emit-xdot.d.ts.map +1 -1
- package/dist/gvc/job.d.ts +5 -2
- package/dist/gvc/job.d.ts.map +1 -1
- package/dist/gvc/viewport.d.ts +10 -5
- package/dist/gvc/viewport.d.ts.map +1 -1
- package/dist/index.js +21565 -21326
- package/dist/index.js.map +4 -4
- package/dist/layout/dot/classify.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
- package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
- package/dist/layout/dot/edge-route-chain.d.ts +20 -16
- package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
- package/dist/layout/dot/edge-route.d.ts +7 -3
- package/dist/layout/dot/edge-route.d.ts.map +1 -1
- package/dist/layout/dot/fastgr.d.ts +5 -3
- package/dist/layout/dot/fastgr.d.ts.map +1 -1
- package/dist/layout/dot/flat-adj-record.d.ts +22 -0
- package/dist/layout/dot/flat-adj-record.d.ts.map +1 -0
- package/dist/layout/dot/flat.d.ts +22 -7
- package/dist/layout/dot/flat.d.ts.map +1 -1
- package/dist/layout/dot/init.d.ts +49 -9
- package/dist/layout/dot/init.d.ts.map +1 -1
- package/dist/layout/dot/mincross-build.d.ts +6 -0
- package/dist/layout/dot/mincross-build.d.ts.map +1 -1
- package/dist/layout/dot/mincross-flat.d.ts +10 -1
- package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
- package/dist/layout/dot/mincross.d.ts +6 -1
- package/dist/layout/dot/mincross.d.ts.map +1 -1
- package/dist/layout/dot/ns-subtree.d.ts +9 -6
- package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
- package/dist/layout/dot/pack-components.d.ts +4 -3
- package/dist/layout/dot/pack-components.d.ts.map +1 -1
- package/dist/layout/dot/position-aux.d.ts +69 -21
- package/dist/layout/dot/position-aux.d.ts.map +1 -1
- package/dist/layout/dot/position-bbox.d.ts.map +1 -1
- package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
- package/dist/layout/dot/position.d.ts.map +1 -1
- package/dist/layout/dot/rank-dot2.d.ts +7 -25
- package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
- package/dist/layout/dot/self-loop.d.ts +11 -4
- package/dist/layout/dot/self-loop.d.ts.map +1 -1
- package/dist/layout/dot/splines-clone.d.ts +2 -1
- package/dist/layout/dot/splines-clone.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
- package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
- package/dist/layout/dot/splines-flat.d.ts +18 -0
- package/dist/layout/dot/splines-flat.d.ts.map +1 -1
- package/dist/layout/dot/splines-groups.d.ts.map +1 -1
- package/dist/layout/dot/splines-route.d.ts +6 -3
- package/dist/layout/dot/splines-route.d.ts.map +1 -1
- package/dist/layout/dot/straight-edges.d.ts.map +1 -1
- package/dist/layout/fdp/ports.d.ts.map +1 -1
- package/dist/layout/fdp/tlayout.d.ts +3 -0
- package/dist/layout/fdp/tlayout.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
- package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
- package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
- package/dist/layout/neato/conjgrad.d.ts +7 -6
- package/dist/layout/neato/conjgrad.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
- package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops.d.ts +0 -6
- package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
- package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -1
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/model/cgraph-ops.d.ts +10 -2
- package/dist/model/cgraph-ops.d.ts.map +1 -1
- package/dist/model/edge.d.ts +7 -2
- package/dist/model/edge.d.ts.map +1 -1
- package/dist/model/edgeInfo.d.ts +17 -2
- package/dist/model/edgeInfo.d.ts.map +1 -1
- package/dist/model/graph.d.ts +4 -3
- package/dist/model/graph.d.ts.map +1 -1
- package/dist/model/lazy-attrs.d.ts.map +1 -1
- package/dist/model/rankEntry.d.ts +3 -1
- package/dist/model/rankEntry.d.ts.map +1 -1
- package/dist/ortho/index.d.ts +0 -1
- package/dist/ortho/index.d.ts.map +1 -1
- package/dist/ortho/partition.d.ts +2 -4
- package/dist/ortho/partition.d.ts.map +1 -1
- package/dist/parser/builder.d.ts.map +1 -1
- package/dist/pathplan/route.d.ts +93 -0
- package/dist/pathplan/route.d.ts.map +1 -1
- package/dist/render/dot/agwrite.d.ts +26 -10
- package/dist/render/dot/agwrite.d.ts.map +1 -1
- package/dist/render/dot/attrs.d.ts +15 -4
- package/dist/render/dot/attrs.d.ts.map +1 -1
- package/dist/render/dot/types.d.ts +7 -2
- package/dist/render/dot/types.d.ts.map +1 -1
- package/dist/render/dot/write-back.d.ts +14 -0
- package/dist/render/dot/write-back.d.ts.map +1 -1
- package/dist/render/dot/xdot-ops.d.ts +20 -29
- package/dist/render/dot/xdot-ops.d.ts.map +1 -1
- package/dist/render/dot.d.ts +4 -2
- package/dist/render/dot.d.ts.map +1 -1
- package/dist/render/json-cluster-edge.d.ts +17 -4
- package/dist/render/json-cluster-edge.d.ts.map +1 -1
- package/dist/render/json-nonfinite.d.ts +17 -0
- package/dist/render/json-nonfinite.d.ts.map +1 -0
- package/dist/render/json.d.ts +4 -0
- package/dist/render/json.d.ts.map +1 -1
- package/dist/render/map.d.ts +3 -0
- package/dist/render/map.d.ts.map +1 -1
- package/dist/render/svg-graph.d.ts.map +1 -1
- package/dist/render/svg-id.d.ts +10 -1
- package/dist/render/svg-id.d.ts.map +1 -1
- package/dist/render/svg.d.ts +3 -1
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render.js +21517 -21278
- package/dist/render.js.map +4 -4
- package/dist/util/bsd-qsort.d.ts.map +1 -1
- package/dist/util/overflow.d.ts +37 -0
- package/dist/util/overflow.d.ts.map +1 -0
- package/dist/xdot/parse.d.ts.map +1 -1
- package/dist/xdot/strtod.d.ts +23 -0
- package/dist/xdot/strtod.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/api/builder.ts +8 -2
- package/src/common/compass-port.ts +36 -20
- package/src/common/edge-label-init.ts +43 -17
- package/src/common/graph-init.ts +11 -1
- package/src/common/htmltable-label.ts +9 -4
- package/src/common/htmltable-lex.ts +5 -2
- package/src/common/htmltable-parse-image.ts +69 -0
- package/src/common/htmltable-parse-state.ts +6 -0
- package/src/common/htmltable-parse.ts +34 -44
- package/src/common/nodeinit.ts +28 -8
- package/src/common/poly-inside.ts +11 -5
- package/src/common/splines-geom.ts +24 -6
- package/src/common/splines-path-begin.ts +4 -3
- package/src/common/splines-path-end.ts +4 -3
- package/src/common/splines-routespl.ts +32 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
- package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
- package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
- package/src/gvc/context.ts +8 -0
- package/src/gvc/device.ts +6 -6
- package/src/gvc/emit-gates.ts +6 -15
- package/src/gvc/emit-xdot.ts +10 -11
- package/src/gvc/job.ts +5 -2
- package/src/gvc/viewport.ts +13 -7
- package/src/layout/dot/__fixtures__/flat-adj-aux-syms.native-16.1.json +1210 -0
- package/src/layout/dot/classify.ts +5 -2
- package/src/layout/dot/edge-route-chain-views.ts +120 -0
- package/src/layout/dot/edge-route-chain.ts +103 -117
- package/src/layout/dot/edge-route-faithful.ts +20 -5
- package/src/layout/dot/edge-route.ts +44 -49
- package/src/layout/dot/fastgr.ts +9 -3
- package/src/layout/dot/flat-adj-record.ts +68 -0
- package/src/layout/dot/flat.ts +38 -17
- package/src/layout/dot/init.ts +59 -13
- package/src/layout/dot/mincross-build.ts +14 -1
- package/src/layout/dot/mincross-flat.ts +15 -5
- package/src/layout/dot/mincross.ts +6 -2
- package/src/layout/dot/ns-subtree.ts +11 -7
- package/src/layout/dot/pack-components.ts +6 -4
- package/src/layout/dot/position-aux.ts +122 -42
- package/src/layout/dot/position-bbox.ts +14 -1
- package/src/layout/dot/position-ycoords.ts +7 -1
- package/src/layout/dot/position.ts +4 -1
- package/src/layout/dot/rank-dot2.ts +13 -94
- package/src/layout/dot/self-loop.ts +29 -11
- package/src/layout/dot/splines-clone.ts +8 -2
- package/src/layout/dot/splines-flat-labeled.ts +3 -2
- package/src/layout/dot/splines-flat-multi.ts +12 -4
- package/src/layout/dot/splines-flat.ts +9 -19
- package/src/layout/dot/splines-groups.ts +5 -3
- package/src/layout/dot/splines-route.ts +10 -11
- package/src/layout/dot/straight-edges.ts +5 -3
- package/src/layout/fdp/ports.ts +6 -2
- package/src/layout/fdp/tlayout.ts +6 -5
- package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
- package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
- package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
- package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
- package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
- package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
- package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
- package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
- package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
- package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
- package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
- package/src/layout/neato/conjgrad-mkernel.ts +6 -2
- package/src/layout/neato/conjgrad.ts +38 -35
- package/src/layout/neato/matrix-ops-dense.ts +2 -20
- package/src/layout/neato/matrix-ops.ts +0 -20
- package/src/layout/neato/quad-prog-vpsc.ts +7 -5
- package/src/layout/neato/sgd.ts +2 -1
- package/src/layout/neato/smart-ini-x.ts +15 -15
- package/src/layout/neato/stress-subspace.ts +5 -5
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
- package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
- package/src/model/cgraph-ops.ts +4 -3
- package/src/model/edge.ts +11 -4
- package/src/model/edgeInfo.ts +18 -2
- package/src/model/graph.ts +4 -3
- package/src/model/lazy-attrs.ts +3 -1
- package/src/model/rankEntry.ts +3 -1
- package/src/ortho/index.ts +0 -1
- package/src/ortho/partition.ts +10 -22
- package/src/parser/builder.ts +12 -3
- package/src/pathplan/route.ts +14 -4
- package/src/render/dot/agwrite.ts +45 -18
- package/src/render/dot/attrs.ts +18 -7
- package/src/render/dot/types.ts +7 -2
- package/src/render/dot/write-back.ts +27 -3
- package/src/render/dot/xdot-ops.ts +25 -56
- package/src/render/dot.ts +7 -5
- package/src/render/json-cluster-edge.ts +42 -5
- package/src/render/json-nonfinite.ts +51 -0
- package/src/render/json.ts +23 -26
- package/src/render/map.ts +3 -0
- package/src/render/svg-graph.ts +3 -15
- package/src/render/svg-id.ts +11 -2
- package/src/render/svg.ts +4 -1
- package/src/util/bsd-qsort.ts +2 -1
- package/src/util/overflow.ts +74 -0
- package/src/xdot/parse.ts +9 -19
- package/src/xdot/strtod.ts +167 -0
|
@@ -216,9 +216,10 @@ export function initSubg(sg: Graph, root: Graph): void {
|
|
|
216
216
|
* ranking reads them. Node sizing in `dotPhaseInit` reads `sg.root.info.flip`
|
|
217
217
|
* (the real root), so it is correct regardless of this ordering.
|
|
218
218
|
*
|
|
219
|
-
* Returns the component's
|
|
220
|
-
*
|
|
221
|
-
*
|
|
219
|
+
* Returns the component's dot_position status when it is non-zero (16.1.1: an
|
|
220
|
+
* aux edge longer than INT_MAX, issue #162), else its dot_splines status. A
|
|
221
|
+
* non-zero status is C's dotLayout(sg) failing, which makes doDot return
|
|
222
|
+
* before packing. The mincross status is not consulted on this arm (#235).
|
|
222
223
|
* @see lib/dotgen/dotinit.c:dotLayout (static)
|
|
223
224
|
*/
|
|
224
225
|
export function dotLayoutComponent(sg: Graph, root: Graph): number {
|
|
@@ -248,7 +249,8 @@ export function dotLayoutComponent(sg: Graph, root: Graph): number {
|
|
|
248
249
|
sg.info.has_labels = 0;
|
|
249
250
|
dotRank(sg);
|
|
250
251
|
dotMincross(sg);
|
|
251
|
-
dotPosition(sg);
|
|
252
|
+
const posRc = dotPosition(sg);
|
|
253
|
+
if (posRc !== 0) return posRc;
|
|
252
254
|
return dotPhasePostNoFinish(sg);
|
|
253
255
|
}
|
|
254
256
|
|
|
@@ -15,10 +15,15 @@ import { SLACKNODE, EDGE_LABEL } from './rank.js';
|
|
|
15
15
|
import { selfRightSpace } from '../../common/splines-selfedge.js';
|
|
16
16
|
import { lateInt } from '../../common/nodeinit.js';
|
|
17
17
|
import { cround } from '../../common/arith.js';
|
|
18
|
+
import { agerrorf } from '../../common/agerr.js';
|
|
19
|
+
import { printfFixed } from '../../util/printf-round.js';
|
|
18
20
|
|
|
19
21
|
/** @see lib/common/const.h:CL_OFFSET */
|
|
20
22
|
export const CL_OFFSET = 8;
|
|
21
23
|
|
|
24
|
+
/** C `INT_MAX`: the longest aux edge `make_aux_edge` accepts. */
|
|
25
|
+
const INT_MAX = 2147483647;
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* Cluster margin = `late_int(g, G_margin, CL_OFFSET, 0)`. The `margin` attribute
|
|
24
29
|
* is resolved up the subgraph chain (matching `agxget` inheritance), so a
|
|
@@ -99,11 +104,32 @@ export function graphRanksep(g: Graph): number { return g.info.ranksep ?? 0; }
|
|
|
99
104
|
// make_aux_edge — @see lib/dotgen/position.c:make_aux_edge
|
|
100
105
|
// ---------------------------------------------------------------------------
|
|
101
106
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
/**
|
|
108
|
+
* The edge's two ports are the shared default port: C zeroes them inside the
|
|
109
|
+
* Agedgeinfo_t it allocates here and never writes them. Its attributes are the
|
|
110
|
+
* shared empty map: C binds no attribute record to an aux edge, only the
|
|
111
|
+
* Agedgeinfo_t (issue #145).
|
|
112
|
+
*
|
|
113
|
+
* A length above INT_MAX is refused: the error prints and the result is null,
|
|
114
|
+
* with no edge linked into the fast lists (graphviz 16.1.1, upstream
|
|
115
|
+
* f86899fcc; 16.1.0 clamped the length). make_LR_constraints and
|
|
116
|
+
* make_edge_pairs test the result and fail the layout; every other caller
|
|
117
|
+
* ignores it, as C does, and simply has no edge there. The `%f` is
|
|
118
|
+
* `printfFixed`: `toFixed` goes exponential at 1e21, and corpus 2781's length
|
|
119
|
+
* is 7.2e25.
|
|
120
|
+
* @see lib/dotgen/position.c:make_aux_edge
|
|
121
|
+
*/
|
|
122
|
+
export function makeAuxEdge(u: Node, v: Node, len: number, wt: number): Edge | null {
|
|
123
|
+
if (len > INT_MAX) {
|
|
124
|
+
agerrorf(
|
|
125
|
+
`Edge length ${printfFixed(len, 6)} larger than maximum ${INT_MAX} allowed.\n`
|
|
126
|
+
+ 'Check for overwide node(s).',
|
|
127
|
+
);
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const e = new EdgeClass(u, v, '', true, true);
|
|
105
131
|
// C ROUND() is half away from zero. @see lib/dotgen/position.c:195
|
|
106
|
-
e.info.minlen = cround(
|
|
132
|
+
e.info.minlen = cround(len);
|
|
107
133
|
e.info.weight = wt;
|
|
108
134
|
fastEdge(e);
|
|
109
135
|
return e;
|
|
@@ -148,8 +174,11 @@ export function lrSep(g: Graph, rankIdx: number): number {
|
|
|
148
174
|
return (rankIdx + (g.info.abomShift ?? 0)) & 1 ? 5 : nodesep;
|
|
149
175
|
}
|
|
150
176
|
|
|
151
|
-
/**
|
|
152
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Returns -1 when the aux edge is refused (16.1.1, upstream e62e35be5), else 0.
|
|
179
|
+
* @see lib/dotgen/position.c:make_LR_constraints (single flat-edge constraint)
|
|
180
|
+
*/
|
|
181
|
+
export function processFlatEdge(g: Graph, u: Node, e: Edge): number {
|
|
153
182
|
const nodesep = graphNodesep(g);
|
|
154
183
|
const isOrdered = nodeOrder(u) < nodeOrder(e.head);
|
|
155
184
|
const t0 = isOrdered ? e.tail : e.head;
|
|
@@ -169,43 +198,61 @@ export function processFlatEdge(g: Graph, u: Node, e: Edge): void {
|
|
|
169
198
|
ex.info.minlen = Math.max(ex.info.minlen ?? 1, m0);
|
|
170
199
|
ex.info.weight = Math.max(ex.info.weight ?? 0, edgeWeight(e));
|
|
171
200
|
} else if (!e.info.label) {
|
|
172
|
-
makeAuxEdge(t0, h0, m0, edgeWeight(e));
|
|
201
|
+
if (makeAuxEdge(t0, h0, m0, edgeWeight(e)) === null) return -1;
|
|
173
202
|
}
|
|
203
|
+
return 0;
|
|
174
204
|
}
|
|
175
205
|
|
|
176
|
-
/**
|
|
177
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Returns -1 at the first refused aux edge, else 0.
|
|
208
|
+
* @see lib/dotgen/position.c:make_LR_constraints (flat-edge endpoint loop)
|
|
209
|
+
*/
|
|
210
|
+
export function makeFlatEdgeConstraints(g: Graph, u: Node): number {
|
|
178
211
|
const flatOut = u.info.flat_out;
|
|
179
|
-
if (!flatOut) return;
|
|
212
|
+
if (!flatOut) return 0;
|
|
180
213
|
for (let k = 0; k < flatOut.size; k++) {
|
|
181
|
-
processFlatEdge(g, u, flatOut.list[k]);
|
|
214
|
+
if (processFlatEdge(g, u, flatOut.list[k]) !== 0) return -1;
|
|
182
215
|
}
|
|
216
|
+
return 0;
|
|
183
217
|
}
|
|
184
218
|
|
|
185
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Returns -1 when either aux edge is refused (16.1.1, upstream e62e35be5); the
|
|
221
|
+
* second is not tried after the first fails. Else 0.
|
|
222
|
+
* @see lib/dotgen/position.c:make_LR_constraints (flat-label constraint body)
|
|
223
|
+
*/
|
|
186
224
|
export function applyFlatLabel(
|
|
187
225
|
g: Graph,
|
|
188
226
|
e: Edge,
|
|
189
227
|
e0raw: Edge,
|
|
190
228
|
e1raw: Edge,
|
|
191
|
-
):
|
|
229
|
+
): number {
|
|
192
230
|
const nodesep = graphNodesep(g);
|
|
193
231
|
const e0 = nodeOrder(e0raw.head) <= nodeOrder(e1raw.head) ? e0raw : e1raw;
|
|
194
232
|
const e1 = e0 === e0raw ? e1raw : e0raw;
|
|
195
|
-
|
|
233
|
+
// C: int m0 (position.c:222,276), so the half truncates
|
|
234
|
+
const m0 = Math.trunc(edgeMinlen(e) * nodesep / 2);
|
|
196
235
|
const m1a = m0 + nodeRw(e0.head) + nodeLw(e0.tail);
|
|
197
|
-
if (!canReach(e0.tail, e0.head))
|
|
236
|
+
if (!canReach(e0.tail, e0.head)) {
|
|
237
|
+
if (makeAuxEdge(e0.head, e0.tail, m1a, edgeWeight(e)) === null) return -1;
|
|
238
|
+
}
|
|
198
239
|
const m1b = m0 + nodeRw(e1.tail) + nodeLw(e1.head);
|
|
199
|
-
if (!canReach(e1.head, e1.tail))
|
|
240
|
+
if (!canReach(e1.head, e1.tail)) {
|
|
241
|
+
if (makeAuxEdge(e1.tail, e1.head, m1b, edgeWeight(e)) === null) return -1;
|
|
242
|
+
}
|
|
243
|
+
return 0;
|
|
200
244
|
}
|
|
201
245
|
|
|
202
|
-
/**
|
|
203
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Returns -1 when a label aux edge is refused, else 0.
|
|
248
|
+
* @see lib/dotgen/position.c:make_LR_constraints (flat-label constraints via ND_alg)
|
|
249
|
+
*/
|
|
250
|
+
export function makeFlatLabelConstraints(g: Graph, u: Node): number {
|
|
204
251
|
const e = u.info.posAlg;
|
|
205
|
-
if (!e) return;
|
|
252
|
+
if (!e) return 0;
|
|
206
253
|
const so = u.info.save_out;
|
|
207
|
-
if (!so || so.size < 2) return;
|
|
208
|
-
applyFlatLabel(g, e, so.list[0], so.list[1]);
|
|
254
|
+
if (!so || so.size < 2) return 0;
|
|
255
|
+
return applyFlatLabel(g, e, so.list[0], so.list[1]);
|
|
209
256
|
}
|
|
210
257
|
|
|
211
258
|
/** @see lib/dotgen/position.c:go */
|
|
@@ -236,11 +283,16 @@ export function selfWidth(u: Node): number {
|
|
|
236
283
|
return sw;
|
|
237
284
|
}
|
|
238
285
|
|
|
239
|
-
/**
|
|
240
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Returns the next `last`, or null when the adjacent-pair aux edge is refused
|
|
288
|
+
* (16.1.1, upstream e62e35be5, 92ef8d508). C tests the edge before the
|
|
289
|
+
* `ND_rank(v)` assignment, so `v`'s rank is not written on failure.
|
|
290
|
+
* @see lib/dotgen/position.c:make_LR_constraints (per-rank inner loop, one node pair)
|
|
291
|
+
*/
|
|
292
|
+
export function lrRankPair(g: Graph, r: number, u: Node, v: Node, last: number): number | null {
|
|
241
293
|
const nodesep = lrSep(g, r);
|
|
242
294
|
const width = nodeRw(u) + nodeLw(v) + nodesep;
|
|
243
|
-
makeAuxEdge(u, v, width, 0);
|
|
295
|
+
if (makeAuxEdge(u, v, width, 0) === null) return null;
|
|
244
296
|
/* C: `last = (ND_rank(v) = last + width)`. ND_rank is an int, so the
|
|
245
297
|
* double `last + width` truncates toward zero on assignment, and the
|
|
246
298
|
* truncated *integer* flows back into `last` — positions accumulate as
|
|
@@ -254,10 +306,16 @@ export function lrRankPair(g: Graph, r: number, u: Node, v: Node, last: number):
|
|
|
254
306
|
return next;
|
|
255
307
|
}
|
|
256
308
|
|
|
257
|
-
/**
|
|
258
|
-
|
|
309
|
+
/**
|
|
310
|
+
* 16.1.1 skips a rank with no leader (`rank[i].v[0] == NULL` → `continue`).
|
|
311
|
+
* The per-rank body is its own function here, so C's `continue` is a `return`.
|
|
312
|
+
* @see lib/dotgen/position.c:make_LR_constraints (per-rank inner loop;
|
|
313
|
+
* 16.1.1 :240-243, d49e3a529 "anticipate empty ranks")
|
|
314
|
+
*/
|
|
315
|
+
export function makeLrRankConstraints(g: Graph, r: number): number {
|
|
259
316
|
const rank = g.info.rank!;
|
|
260
317
|
const rk = rank[r];
|
|
318
|
+
if (rk.v[0] == null) return 0;
|
|
261
319
|
let last = 0;
|
|
262
320
|
for (let j = 0; j < rk.n; j++) {
|
|
263
321
|
const u = rk.v[j];
|
|
@@ -265,26 +323,40 @@ export function makeLrRankConstraints(g: Graph, r: number): void {
|
|
|
265
323
|
u.info.rw = nodeRw(u) + selfWidth(u);
|
|
266
324
|
if (rk.v[0]) u.info.rank = last;
|
|
267
325
|
const v = rk.v[j + 1];
|
|
268
|
-
if (v)
|
|
269
|
-
|
|
270
|
-
|
|
326
|
+
if (v) {
|
|
327
|
+
const next = lrRankPair(g, r, u, v, last);
|
|
328
|
+
if (next === null) return -1;
|
|
329
|
+
last = next;
|
|
330
|
+
}
|
|
331
|
+
if (makeFlatLabelConstraints(g, u) !== 0) return -1;
|
|
332
|
+
if (makeFlatEdgeConstraints(g, u) !== 0) return -1;
|
|
271
333
|
}
|
|
272
334
|
if (rk.n > 0) rk.v[0].info.rank = 0;
|
|
335
|
+
return 0;
|
|
273
336
|
}
|
|
274
337
|
|
|
275
|
-
/**
|
|
276
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Returns -1 at the first refused aux edge (C's `return -1` from inside the
|
|
340
|
+
* rank loops), else 0.
|
|
341
|
+
* @see lib/dotgen/position.c:make_LR_constraints
|
|
342
|
+
*/
|
|
343
|
+
export function makeLrConstraints(g: Graph): number {
|
|
277
344
|
for (let i = (g.info.minrank ?? 0); i <= (g.info.maxrank ?? 0); i++) {
|
|
278
|
-
makeLrRankConstraints(g, i);
|
|
345
|
+
if (makeLrRankConstraints(g, i) !== 0) return -1;
|
|
279
346
|
}
|
|
347
|
+
return 0;
|
|
280
348
|
}
|
|
281
349
|
|
|
282
350
|
// ---------------------------------------------------------------------------
|
|
283
351
|
// make_edge_pairs — @see lib/dotgen/position.c:make_edge_pairs
|
|
284
352
|
// ---------------------------------------------------------------------------
|
|
285
353
|
|
|
286
|
-
/**
|
|
287
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Returns -1 when either aux edge is refused (16.1.1, upstream 73c1fd4d1,
|
|
356
|
+
* f0d837f19), leaving the slack node unranked. Else 0.
|
|
357
|
+
* @see lib/dotgen/position.c:make_edge_pairs (per-edge)
|
|
358
|
+
*/
|
|
359
|
+
export function addEdgePair(g: Graph, e: Edge): number {
|
|
288
360
|
const sn = makeSlackNode(g);
|
|
289
361
|
const hp = e.info.head_port.p;
|
|
290
362
|
const tp = e.info.tail_port.p;
|
|
@@ -296,20 +368,25 @@ export function addEdgePair(g: Graph, e: Edge): void {
|
|
|
296
368
|
const d = Math.trunc(hp.x - tp.x);
|
|
297
369
|
const m0 = Math.max(0, d);
|
|
298
370
|
const m1 = Math.max(0, -d);
|
|
299
|
-
makeAuxEdge(sn, e.tail, m0 + 1, edgeWeight(e));
|
|
300
|
-
makeAuxEdge(sn, e.head, m1 + 1, edgeWeight(e));
|
|
371
|
+
if (makeAuxEdge(sn, e.tail, m0 + 1, edgeWeight(e)) === null) return -1;
|
|
372
|
+
if (makeAuxEdge(sn, e.head, m1 + 1, edgeWeight(e)) === null) return -1;
|
|
301
373
|
sn.info.rank = Math.min(nodeRank(e.tail) - m0 - 1, nodeRank(e.head) - m1 - 1);
|
|
374
|
+
return 0;
|
|
302
375
|
}
|
|
303
376
|
|
|
304
|
-
/**
|
|
305
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Returns -1 at the first refused aux edge, else 0.
|
|
379
|
+
* @see lib/dotgen/position.c:make_edge_pairs
|
|
380
|
+
*/
|
|
381
|
+
export function makeEdgePairs(g: Graph): number {
|
|
306
382
|
for (let n = g.info.nlist; n !== undefined; n = n.info.next) {
|
|
307
383
|
const so = n.info.save_out;
|
|
308
384
|
if (!so) continue;
|
|
309
385
|
for (let i = 0; i < so.size; i++) {
|
|
310
|
-
addEdgePair(g, so.list[i]);
|
|
386
|
+
if (addEdgePair(g, so.list[i]) !== 0) return -1;
|
|
311
387
|
}
|
|
312
388
|
}
|
|
389
|
+
return 0;
|
|
313
390
|
}
|
|
314
391
|
|
|
315
392
|
/** Create a SLACKNODE virtual node and prepend to nlist. */
|
|
@@ -333,12 +410,15 @@ export function createAuxEdges(
|
|
|
333
410
|
g: Graph,
|
|
334
411
|
posClusters: (g: Graph) => void,
|
|
335
412
|
compressGraph: (g: Graph) => void,
|
|
336
|
-
):
|
|
413
|
+
): number {
|
|
337
414
|
allocateAuxEdges(g);
|
|
338
|
-
makeLrConstraints(g);
|
|
339
|
-
|
|
415
|
+
const lrRc = makeLrConstraints(g);
|
|
416
|
+
if (lrRc !== 0) return lrRc;
|
|
417
|
+
const pairRc = makeEdgePairs(g);
|
|
418
|
+
if (pairRc !== 0) return pairRc;
|
|
340
419
|
posClusters(g);
|
|
341
420
|
compressGraph(g);
|
|
421
|
+
return 0;
|
|
342
422
|
}
|
|
343
423
|
|
|
344
424
|
/** @see lib/dotgen/position.c:remove_aux_edges (SLACKNODE removal loop) */
|
|
@@ -82,7 +82,20 @@ export function dotComputeBb(g: Graph, root: Graph): void {
|
|
|
82
82
|
}
|
|
83
83
|
const rankArr = root.info.rank!;
|
|
84
84
|
const lly = rankArr[graphMaxrank(g)].v[0].info.coord.y - graphHt1(g);
|
|
85
|
-
|
|
85
|
+
// 16.1.1 takes UR.y from the first rank that is not empty, where 16.1.0 read
|
|
86
|
+
// the min rank's leader outright. C leaves UR.y uninitialised when no rank
|
|
87
|
+
// qualifies; that cannot be read here, because LL.y above has already
|
|
88
|
+
// dereferenced the max rank's leader, so at least the max rank qualifies
|
|
89
|
+
// whenever its `n` is nonzero. NaN marks the value as never meant to be used.
|
|
90
|
+
// @see lib/dotgen/position.c:dot_compute_bb (16.1.1 :885-894, 8e06a6261
|
|
91
|
+
// "anticipate min rank being empty")
|
|
92
|
+
let ury = Number.NaN;
|
|
93
|
+
for (let r = graphMinrank(g); r <= graphMaxrank(g); ++r) {
|
|
94
|
+
if (rankArr[r].n === 0) continue;
|
|
95
|
+
if (rankArr[r].v[0] == null) continue;
|
|
96
|
+
ury = rankArr[r].v[0].info.coord.y + graphHt2(g);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
86
99
|
g.info.bb = { ll: { x: llx, y: lly }, ur: { x: urx, y: ury } };
|
|
87
100
|
}
|
|
88
101
|
|
|
@@ -175,7 +175,13 @@ export function setYcoordsInitial(g: Graph, lbl: boolean): void {
|
|
|
175
175
|
const d1 = rankArr[r + 1].ht2 + rankArr[r].ht1 + CL_OFFSET;
|
|
176
176
|
const delta = Math.max(d0, d1);
|
|
177
177
|
if (rankArr[r].n > 0) {
|
|
178
|
-
|
|
178
|
+
// 16.1.1: assign only when the rank below has a leader (`!= NULL`; the
|
|
179
|
+
// port's empty ranks hold null or nothing at v[0], hence `!= null`).
|
|
180
|
+
// @see lib/dotgen/position.c:set_ycoords (16.1.1 :793-797, 9fca64d0f
|
|
181
|
+
// "anticipate empty ranks")
|
|
182
|
+
if (rankArr[r + 1].v[0] != null) {
|
|
183
|
+
rankArr[r].v[0].info.coord.y = rankArr[r + 1].v[0].info.coord.y + delta;
|
|
184
|
+
}
|
|
179
185
|
}
|
|
180
186
|
maxht = Math.max(maxht, delta);
|
|
181
187
|
}
|
|
@@ -188,7 +188,10 @@ export function dotPosition(g: Graph): number {
|
|
|
188
188
|
}
|
|
189
189
|
expandLeaves(g);
|
|
190
190
|
if (flatEdges(g)) setYcoords(g);
|
|
191
|
-
|
|
191
|
+
// 16.1.1 (upstream f444e5192): an aux edge longer than INT_MAX fails the
|
|
192
|
+
// layout here, ahead of the x-coordinate network simplex.
|
|
193
|
+
const auxRc = createAuxEdges(g, posClusters, compressGraph);
|
|
194
|
+
if (auxRc !== 0) return auxRc;
|
|
192
195
|
g.info.rankIsXCoord = true;
|
|
193
196
|
if (rank(g, 2, nsiter2(g))) {
|
|
194
197
|
connectGraph(g);
|
|
@@ -17,15 +17,11 @@ import { nodesInSeq } from './decomp.js';
|
|
|
17
17
|
// Constants @see lib/dotgen/rank.c
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
|
|
20
|
-
const BACKWARD_PENALTY = 1000;
|
|
21
|
-
const STRONG_CLUSTER_WEIGHT = 1000;
|
|
22
20
|
const NORANK = 6;
|
|
23
21
|
const ROOT_NAME = '\x7froot';
|
|
24
|
-
const TOPNODE_NAME = '\x7ftop';
|
|
25
|
-
const BOTNODE_NAME = '\x7fbot';
|
|
26
22
|
|
|
27
|
-
/** Mutable state replacing C
|
|
28
|
-
export interface XgState { lastNode: Node | undefined;
|
|
23
|
+
/** Mutable state replacing the C static Last_node. */
|
|
24
|
+
export interface XgState { lastNode: Node | undefined; }
|
|
29
25
|
|
|
30
26
|
// ---------------------------------------------------------------------------
|
|
31
27
|
// Accessor helpers — extract ?? and ?. so callers stay within CCN ≤ 10
|
|
@@ -79,17 +75,15 @@ export function d2unionAll(g: Graph): Node | undefined {
|
|
|
79
75
|
// could later widen a node's membership out of creation order (the exact
|
|
80
76
|
// precondition that makes `g.nodes.values()` diverge from AGSEQ elsewhere).
|
|
81
77
|
// Xg's node-creation order is itself already driven by `nodesInSeq(g)`
|
|
82
|
-
// (compileNodes
|
|
78
|
+
// (compileNodes, converted above; connectComponents adds ROOT last), so
|
|
83
79
|
// `Xg.nodes.values()` is provably already AGSEQ-equivalent order.
|
|
84
80
|
// ---------------------------------------------------------------------------
|
|
85
81
|
|
|
86
82
|
/** @see lib/dotgen/rank.c:makeXnode — C's `agnode(G, name, 1)` returns the
|
|
87
|
-
* existing node when one with `name` is present
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* constraint and derailing the rank solve. Real/weak node names are unique, so
|
|
92
|
-
* this dedup only affects TOP/BOT/ROOT — exactly as in C. */
|
|
83
|
+
* existing node when one with `name` is present. Since graphviz 16.1.1 removed
|
|
84
|
+
* compile_clusters and its shared TOP/BOT nodes, the callers are compile_nodes
|
|
85
|
+
* (one call per set leader, each name unique) and connect_components (ROOT, at
|
|
86
|
+
* most once per Xg), so the dedup matters only for ROOT. */
|
|
93
87
|
export function makeXnode(Xg: Graph, name: string, st: XgState): Node {
|
|
94
88
|
const existing = Xg.nodes.get(name);
|
|
95
89
|
if (existing) return existing;
|
|
@@ -212,30 +206,6 @@ export function xgStrong(Xg: Graph, t: Node, h: Node, orig: Edge): void {
|
|
|
212
206
|
xgMerge(e, eMinlen(orig), eWeight(orig));
|
|
213
207
|
}
|
|
214
208
|
|
|
215
|
-
/** @see lib/dotgen/rank.c:weak — find existing weak diamond v→t, v→h */
|
|
216
|
-
export function xgWeakExists(Xg: Graph, t: Node, h: Node): boolean {
|
|
217
|
-
for (const e of Xg.edges) {
|
|
218
|
-
if (e.head !== t) continue;
|
|
219
|
-
const v = e.tail;
|
|
220
|
-
for (const f of Xg.edges) { if (f.tail === v && f.head === h) return true; }
|
|
221
|
-
}
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export function xgWeakSetWeights(e: Edge, f: Edge, origW: number, origML: number): void {
|
|
226
|
-
e.info.minlen = Math.max(eMinlen(e), 0);
|
|
227
|
-
e.info.weight = eWeight(e) + origW * BACKWARD_PENALTY;
|
|
228
|
-
f.info.minlen = Math.max(eMinlen(f), origML);
|
|
229
|
-
f.info.weight = eWeight(f) + origW;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** @see lib/dotgen/rank.c:weak */
|
|
233
|
-
export function xgWeak(Xg: Graph, t: Node, h: Node, orig: Edge, st: XgState): void {
|
|
234
|
-
if (xgWeakExists(Xg, t, h)) return;
|
|
235
|
-
const v = makeXnode(Xg, `_weak_${st.weakId++}`, st);
|
|
236
|
-
xgWeakSetWeights(xgAddEdge(Xg, v, t), xgAddEdge(Xg, v, h), eWeight(orig), eMinlen(orig));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
209
|
/** @see lib/dotgen/rank.c:is_nonconstraint */
|
|
240
210
|
export function isNonConstraint(e: Edge): boolean {
|
|
241
211
|
const v = e.attrs.get('constraint');
|
|
@@ -243,11 +213,6 @@ export function isNonConstraint(e: Edge): boolean {
|
|
|
243
213
|
return !mapbool(v);
|
|
244
214
|
}
|
|
245
215
|
|
|
246
|
-
/** @see lib/dotgen/rank.c:is_a_strong_cluster */
|
|
247
|
-
export function isAStrongCluster(g: Graph): boolean {
|
|
248
|
-
return mapbool(g.attrs.get('compact') ?? '');
|
|
249
|
-
}
|
|
250
|
-
|
|
251
216
|
/** @see lib/dotgen/rank.c:dot_lca */
|
|
252
217
|
export function dotLca(c0: Graph, c1: Graph): Graph {
|
|
253
218
|
let a = c0; let b = c1;
|
|
@@ -283,66 +248,21 @@ export function ceInternal(Xg: Graph, e: Edge, Xt: Node, Xh: Node): void {
|
|
|
283
248
|
}
|
|
284
249
|
|
|
285
250
|
/** @see lib/dotgen/rank.c:compile_edges inner body */
|
|
286
|
-
export function compileEdgeItem(Xg: Graph, e: Edge, Xt: Node
|
|
251
|
+
export function compileEdgeItem(Xg: Graph, e: Edge, Xt: Node): void {
|
|
287
252
|
if (isNonConstraint(e)) return;
|
|
288
253
|
const Xh = d2find(e.head).info.rep;
|
|
289
254
|
if (!Xh || Xt === Xh) return;
|
|
290
255
|
if (isInternalToCluster(e)) { ceInternal(Xg, e, Xt, Xh); return; }
|
|
291
|
-
|
|
292
|
-
if ((tc && isAStrongCluster(tc)) || (hc && isAStrongCluster(hc))) xgWeak(Xg, Xt, Xh, e, st);
|
|
293
|
-
else xgStrong(Xg, Xt, Xh, e);
|
|
256
|
+
xgStrong(Xg, Xt, Xh, e);
|
|
294
257
|
}
|
|
295
258
|
|
|
296
259
|
/** @see lib/dotgen/rank.c:compile_edges */
|
|
297
|
-
export function compileEdges(g: Graph, Xg: Graph
|
|
260
|
+
export function compileEdges(g: Graph, Xg: Graph): void {
|
|
298
261
|
for (const n of nodesInSeq(g)) {
|
|
299
262
|
const Xt = n.info.rep;
|
|
300
263
|
if (!Xt) continue;
|
|
301
|
-
for (const e of n.outEdges(g)) compileEdgeItem(Xg, e, Xt
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// ---------------------------------------------------------------------------
|
|
306
|
-
// compile_clusters helpers
|
|
307
|
-
// ---------------------------------------------------------------------------
|
|
308
|
-
|
|
309
|
-
interface ClusterBounds { top: Node | undefined; bot: Node | undefined; }
|
|
310
|
-
|
|
311
|
-
export function ccProcessNode(g: Graph, Xg: Graph, st: XgState, n: Node, b: ClusterBounds): void {
|
|
312
|
-
const rep = d2find(n).info.rep;
|
|
313
|
-
if (!rep) return;
|
|
314
|
-
if (n.inEdges(g).length === 0) {
|
|
315
|
-
if (!b.top) b.top = makeXnode(Xg, TOPNODE_NAME, st);
|
|
316
|
-
xgAddEdge(Xg, b.top, rep);
|
|
317
|
-
}
|
|
318
|
-
if (n.outEdges(g).length === 0) {
|
|
319
|
-
if (!b.bot) b.bot = makeXnode(Xg, BOTNODE_NAME, st);
|
|
320
|
-
xgAddEdge(Xg, rep, b.bot);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export function ccStrongCluster(
|
|
325
|
-
g: Graph, Xg: Graph, st: XgState, top: Node | undefined, bot: Node | undefined
|
|
326
|
-
): ClusterBounds {
|
|
327
|
-
const b: ClusterBounds = { top, bot };
|
|
328
|
-
for (const n of nodesInSeq(g)) ccProcessNode(g, Xg, st, n, b);
|
|
329
|
-
// Xg is Agstrictdirected, so C's `agedge(Xg, top, bot)` returns the one shared
|
|
330
|
-
// TOP->BOT edge (TOP/BOT dedup in makeXnode) and merge() accumulates onto it.
|
|
331
|
-
// Mirror strict agedge with find-or-add so the weight sums instead of forking.
|
|
332
|
-
if (b.top && b.bot) xgMerge(xgFindEdge(Xg, b.top, b.bot) ?? xgAddEdge(Xg, b.top, b.bot), 0, STRONG_CLUSTER_WEIGHT);
|
|
333
|
-
return b;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/** @see lib/dotgen/rank.c:compile_clusters */
|
|
337
|
-
export function compileClusters(
|
|
338
|
-
g: Graph, Xg: Graph, st: XgState, top: Node | undefined, bot: Node | undefined
|
|
339
|
-
): void {
|
|
340
|
-
let t = top; let b = bot;
|
|
341
|
-
if (isACluster(g) && isAStrongCluster(g)) {
|
|
342
|
-
const bounds = ccStrongCluster(g, Xg, st, t, b);
|
|
343
|
-
t = bounds.top; b = bounds.bot;
|
|
264
|
+
for (const e of n.outEdges(g)) compileEdgeItem(Xg, e, Xt);
|
|
344
265
|
}
|
|
345
|
-
for (const sub of g.subgraphs.values()) compileClusters(sub, Xg, st, t, b);
|
|
346
266
|
}
|
|
347
267
|
|
|
348
268
|
// ---------------------------------------------------------------------------
|
|
@@ -507,7 +427,7 @@ export function readoutLevels(g: Graph, Xg: Graph, ncc: number): void {
|
|
|
507
427
|
|
|
508
428
|
/** @see lib/dotgen/rank.c:dot2_rank */
|
|
509
429
|
export function dot2Rank(g: Graph): void {
|
|
510
|
-
const st: XgState = { lastNode: undefined
|
|
430
|
+
const st: XgState = { lastNode: undefined };
|
|
511
431
|
const Xg = new Graph('level assignment constraints', 'strict-directed');
|
|
512
432
|
edgelabelRanks(g);
|
|
513
433
|
const nslimit1 = g.attrs.get('nslimit1');
|
|
@@ -518,8 +438,7 @@ export function dot2Rank(g: Graph): void {
|
|
|
518
438
|
const ssize = ssStr ? parseInt(ssStr, 10) : -1;
|
|
519
439
|
compileSamerank(g, undefined);
|
|
520
440
|
compileNodes(g, Xg, st);
|
|
521
|
-
compileEdges(g, Xg
|
|
522
|
-
compileClusters(g, Xg, st, undefined, undefined);
|
|
441
|
+
compileEdges(g, Xg);
|
|
523
442
|
breakCycles(Xg);
|
|
524
443
|
const ncc = connectComponents(Xg, st);
|
|
525
444
|
addFastEdges(Xg);
|
|
@@ -71,19 +71,30 @@ export function collectOtherEdges(n: Node, edges: Edge[]): void {
|
|
|
71
71
|
|
|
72
72
|
// ---------------------------------------------------------------------------
|
|
73
73
|
// computeSizey — rank-gap geometry for self-loop sizing
|
|
74
|
-
// @see lib/dotgen/dotsplines.c:
|
|
74
|
+
// @see lib/dotgen/dotsplines.c:dot_splines_ (16.1.1 :396-411)
|
|
75
75
|
// ---------------------------------------------------------------------------
|
|
76
76
|
|
|
77
|
+
/** C's `GD_rank(g)[r].v[0] != NULL`: rank r is not empty. The port's empty
|
|
78
|
+
* ranks carry `v[0]` as null or as absent (`v` is `[]`), so the test is loose.
|
|
79
|
+
* @see lib/dotgen/dotsplines.c:dot_splines_ (16.1.1, ca3353d80, 1a77ac9df) */
|
|
80
|
+
function rankHasLeader(g: Graph, r: number): boolean {
|
|
81
|
+
return g.info.rank![r].v[0] != null;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
/** y-coord of first node in rank r. @see lib/dotgen/dotsplines.c:394 */
|
|
78
85
|
function rankY(g: Graph, r: number): number {
|
|
79
86
|
return g.info.rank![r].v[0].info.coord?.y ?? 0;
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
/** sizey when n is at the maximum rank
|
|
83
|
-
*
|
|
84
|
-
* index -1).
|
|
89
|
+
/** sizey when n is at the maximum rank, or the rank below it is empty. C's
|
|
90
|
+
* `r > 0` is a literal index test; after abomination C's rank is
|
|
91
|
+
* r - abomShift (AD-2 renumbers +1 where C uses index -1). 16.1.1 also wants
|
|
92
|
+
* a leader on the rank above: `r > 0 && GD_rank(g)[r - 1].v[0] != NULL`.
|
|
93
|
+
* @see lib/dotgen/dotsplines.c:dot_splines_ (16.1.1 :400-404, 1a77ac9df) */
|
|
85
94
|
function sizeyAtMaxrank(g: Graph, n: Node, r: number): number {
|
|
86
|
-
if (r - (g.info.abomShift ?? 0) > 0
|
|
95
|
+
if (r - (g.info.abomShift ?? 0) > 0 && rankHasLeader(g, r - 1)) {
|
|
96
|
+
return rankY(g, r - 1) - (n.info.coord?.y ?? 0);
|
|
97
|
+
}
|
|
87
98
|
return n.info.ht ?? 0;
|
|
88
99
|
}
|
|
89
100
|
|
|
@@ -103,19 +114,26 @@ function sizeyAtMidrank(g: Graph, n: Node, r: number): number {
|
|
|
103
114
|
/**
|
|
104
115
|
* Compute the vertical sizing parameter for self-loops on node n.
|
|
105
116
|
*
|
|
106
|
-
* Mirrors the C branch exactly:
|
|
107
|
-
* if r == maxrank
|
|
108
|
-
*
|
|
117
|
+
* Mirrors the C branch exactly (16.1.1 guards an empty neighbouring rank):
|
|
118
|
+
* if r == maxrank || rank[r+1].v[0] == NULL:
|
|
119
|
+
* sizey = rank[r-1].v[0].y - n.y (or ht if r==0 or rank[r-1] is empty)
|
|
120
|
+
* elif r == minrank || rank[r-1].v[0] == NULL:
|
|
121
|
+
* sizey = n.y - rank[r+1].v[0].y
|
|
109
122
|
* else: sizey = min(rank[r-1].v[0].y - n.y, n.y - rank[r+1].v[0].y)
|
|
110
123
|
*
|
|
111
|
-
*
|
|
124
|
+
* The `||` order is C's: the rank table has no entry past either end, so the
|
|
125
|
+
* neighbour is read only once `r` is known not to be that end.
|
|
126
|
+
*
|
|
127
|
+
* @see lib/dotgen/dotsplines.c:dot_splines_ (16.1.1 :396-411; ca3353d80
|
|
128
|
+
* "anticipate an empty rank above", 1a77ac9df "anticipate an empty rank
|
|
129
|
+
* below")
|
|
112
130
|
*/
|
|
113
131
|
export function computeSizey(g: Graph, n: Node): number {
|
|
114
132
|
const r = n.info.rank ?? 0;
|
|
115
133
|
const minrank = g.info.minrank ?? 0;
|
|
116
134
|
const maxrank = g.info.maxrank ?? 0;
|
|
117
|
-
if (r === maxrank) return sizeyAtMaxrank(g, n, r);
|
|
118
|
-
if (r === minrank) return sizeyAtMinrank(g, n, r);
|
|
135
|
+
if (r === maxrank || !rankHasLeader(g, r + 1)) return sizeyAtMaxrank(g, n, r);
|
|
136
|
+
if (r === minrank || !rankHasLeader(g, r - 1)) return sizeyAtMinrank(g, n, r);
|
|
119
137
|
return sizeyAtMidrank(g, n, r);
|
|
120
138
|
}
|
|
121
139
|
|
|
@@ -12,7 +12,7 @@ import type { Edge } from '../../model/edge.js';
|
|
|
12
12
|
import type { Point } from '../../model/geom.js';
|
|
13
13
|
import { Edge as EdgeClass } from '../../model/edge.js';
|
|
14
14
|
import { makePort } from '../../model/edgeInfo.js';
|
|
15
|
-
import { agnode } from '../../model/cgraph-ops.js';
|
|
15
|
+
import { agnode, agsubnode } from '../../model/cgraph-ops.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Map a point from the flat-adj auxiliary frame back to the original frame:
|
|
@@ -30,7 +30,8 @@ export function transformf(p: Point, del: Point, flip: boolean): Point {
|
|
|
30
30
|
// ---------------------------------------------------------------------------
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Create a copy of orign in graph g, carrying geometry from NodeInfo.
|
|
33
|
+
* Create a copy of orign in graph g, carrying geometry from NodeInfo. When g
|
|
34
|
+
* is a subgraph the copy is a member of g and of every graph above it.
|
|
34
35
|
* @see lib/dotgen/dotsplines.c:cloneNode
|
|
35
36
|
*/
|
|
36
37
|
export function cloneNode(g: Graph, orign: Node): Node {
|
|
@@ -42,6 +43,11 @@ export function cloneNode(g: Graph, orign: Node): Node {
|
|
|
42
43
|
// the aux graph's own auxt/auxh creation order.
|
|
43
44
|
// @see lib/dotgen/dotsplines.c:cloneNode (agnode(g,...,1))
|
|
44
45
|
const n = agnode(g, orign.name, true)!;
|
|
46
|
+
// C's agnode(g, name, 1) on a subgraph installs the node into g and every
|
|
47
|
+
// graph above it (installnodetoroot); the port's agnode installs into the
|
|
48
|
+
// root only, so do the subgraph half here.
|
|
49
|
+
// @see lib/cgraph/node.c:agnode
|
|
50
|
+
if (g !== g.root) agsubnode(g, n, true);
|
|
45
51
|
n.info.coord = { x: orign.info.coord.x, y: orign.info.coord.y };
|
|
46
52
|
n.info.lw = orign.info.lw;
|
|
47
53
|
n.info.rw = orign.info.rw;
|
|
@@ -150,8 +150,9 @@ export function makeFlatLabeledEdge(g: Graph, e: Edge): boolean {
|
|
|
150
150
|
// Degenerate route (routesplines pn=0): label set, no spline installed — C's
|
|
151
151
|
// make_flat_labeled_edge returns the same way; emit's edge_in_box then decides
|
|
152
152
|
// whether the (untranslated) label overlaps the clip. Still HANDLED → true.
|
|
153
|
-
// C's dot_splines_ visits the edge once, so mark it lost: the
|
|
154
|
-
//
|
|
153
|
+
// C's dot_splines_ visits the edge once, so mark it lost: the flat group loop
|
|
154
|
+
// calls routeLoneEdge per member, and its `lost` skip keeps a later call from
|
|
155
|
+
// routing (and reporting the failure) a second time.
|
|
155
156
|
if (ps === null || ps.length === 0) { e.info.lost = true; return true; }
|
|
156
157
|
if (!tailIsLeft) ps.reverse();
|
|
157
158
|
clipAndInstall(e, e.head, ps, ps.length, { ...buildDotSinfo(), ignoreSwap: true });
|