@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
|
@@ -27,7 +27,7 @@ import { linearBezier } from './edge-route-poly.js';
|
|
|
27
27
|
import { rankEdgeInfoOf, routedThisPass } from './edge-route-rank.js';
|
|
28
28
|
import { routeRegularEdgeFaithful } from './edge-route-faithful.js';
|
|
29
29
|
import { isFlatAdjacent, makeFlatAdjEdges } from './splines-flat.js';
|
|
30
|
-
import {
|
|
30
|
+
import { lostFlatAdjRecordEdge } from './flat-adj-record.js';
|
|
31
31
|
import {
|
|
32
32
|
collectNonAdjacentFlatGroup, routeFlatEdgeGroupFaithful,
|
|
33
33
|
} from './splines-flat-multi.js';
|
|
@@ -174,7 +174,7 @@ function dispatchMultiRankNonForward(
|
|
|
174
174
|
* adjacent regular via make_regular_edge. clipAndInstall gates head/tail arrows
|
|
175
175
|
* by the dir attribute. @see lib/dotgen/dotsplines.c:make_regular_edge
|
|
176
176
|
*/
|
|
177
|
-
function routeEdgeNonForward(e: GraphEdge, g: Graph): void {
|
|
177
|
+
function routeEdgeNonForward(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): void {
|
|
178
178
|
if (routeFaithfulAdjacentBack(e, g)) return; // T1 (AD-1): faithful adjacent back edge
|
|
179
179
|
const tailBox = nodeBoxOf(e.tail, g);
|
|
180
180
|
const headBox = nodeBoxOf(e.head, g);
|
|
@@ -183,7 +183,7 @@ function routeEdgeNonForward(e: GraphEdge, g: Graph): void {
|
|
|
183
183
|
// routers otherwise live only in the forward path, so reach them here too —
|
|
184
184
|
// e.g. a dir=both flat adjacent side-port edge (2437: AA3:se -> AA4:sw).
|
|
185
185
|
if (e.tail.info.rank !== undefined && e.tail.info.rank === e.head.info.rank
|
|
186
|
-
&& routeFlatEdge(e, g)) return;
|
|
186
|
+
&& routeFlatEdge(e, g, run)) return;
|
|
187
187
|
routeFaithfulRegularPlain(e, g);
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -247,12 +247,12 @@ function routeFaithfulAdjacentBack(e: GraphEdge, g: Graph): boolean {
|
|
|
247
247
|
return true;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
/** Route and install spline + arrowhead(s) for a single edge.
|
|
251
|
-
|
|
250
|
+
/** Route and install spline + arrowhead(s) for a single edge. `run` is the
|
|
251
|
+
* edgecmp run the dispatch loop found `e` in ({@link routeLoneEdge}). */
|
|
252
|
+
export function routeOneEdge(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): void {
|
|
252
253
|
const dirAttr = e.attrs.get('dir') ?? defaultEdgeDir(g);
|
|
253
|
-
const pw = edgeRenderPenwidth(e);
|
|
254
254
|
if (dirAttr !== 'forward') {
|
|
255
|
-
routeEdgeNonForward(e, g);
|
|
255
|
+
routeEdgeNonForward(e, g, run);
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
258
258
|
if (routeFaithfulAdjacentBack(e, g)) return; // T1 (AD-1): faithful adjacent back edge
|
|
@@ -266,7 +266,7 @@ export function routeOneEdge(e: GraphEdge, g: Graph): void {
|
|
|
266
266
|
routeFaithfulMultiRank(e, g); // T3 (AD-2): faithful chain pipeline
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
|
-
routeForwardEdge(e, g, tailBox, headBox,
|
|
269
|
+
routeForwardEdge(e, g, tailBox, headBox, run);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
@@ -319,35 +319,39 @@ function isGroupableFlat(x: GraphEdge, g: Graph): boolean {
|
|
|
319
319
|
|
|
320
320
|
/** True when a port-less adjacent flat edge shares its group with a ported one:
|
|
321
321
|
* C's `ports` flag covers the whole group, so it routes via the aux graph. */
|
|
322
|
-
function joinsPortedFlatGroup(e: GraphEdge, g: Graph): boolean {
|
|
322
|
+
function joinsPortedFlatGroup(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): boolean {
|
|
323
323
|
return isAdjFlatCandidate(e) && isGroupableFlat(e, g)
|
|
324
|
-
&& collectAdjacentFlatGroup(e, g).some(hasDefinedPort);
|
|
324
|
+
&& collectAdjacentFlatGroup(e, g, run).some(hasDefinedPort);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
/**
|
|
328
|
-
*
|
|
329
|
-
* endpoints (either direction),
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
328
|
+
* The unrouted adjacent same-rank flat edges of `run` between e's two
|
|
329
|
+
* endpoints (either direction), in the run's order. C's dispatch loop sorts
|
|
330
|
+
* edges by edgecmp (equivalent edges contiguous), groups a run while
|
|
331
|
+
* `getmainedge(e0) === getmainedge(e1)` (dotsplines.c:343-356) and hands
|
|
332
|
+
* make_flat_edge that slice of the sorted list; it does NOT re-derive the
|
|
333
|
+
* group from a node-pair scan, and make_flat_adj_edges clones the aux edges
|
|
334
|
+
* in the slice's order (`e = edges[i]`). That order is the aux edges' AGSEQ,
|
|
335
|
+
* which the aux mincross reads (do_ordering_node, the install order), so the
|
|
336
|
+
* group must not be re-sorted here. Gate on getMainEdge equality (not just the
|
|
337
|
+
* unordered node pair) so two independent parallel edges that merely share
|
|
338
|
+
* endpoints, but resolve to different main edges (e.g. one is itself the main
|
|
339
|
+
* edge of a virtual chain, the other belongs to a different original edge),
|
|
340
|
+
* are NOT folded into one shared aux solve. C makes one make_flat_adj_edges
|
|
341
|
+
* call PER getmainedge run.
|
|
338
342
|
* @see lib/dotgen/dotsplines.c:343-378 (esp. line 356 `if (le0 != le1) break;`)
|
|
339
343
|
* @see lib/dotgen/dotsplines.c:make_flat_edge (makefwdedge of *edges), dot_splines_
|
|
344
|
+
* @see lib/dotgen/dotsplines.c:make_flat_adj_edges (clone loop over edges[i])
|
|
340
345
|
*/
|
|
341
|
-
function collectAdjacentFlatGroup(
|
|
346
|
+
function collectAdjacentFlatGroup(
|
|
347
|
+
e: GraphEdge, g: Graph, run: readonly GraphEdge[],
|
|
348
|
+
): GraphEdge[] {
|
|
342
349
|
const u = e.tail, v = e.head;
|
|
343
|
-
const lo = (u.info.order ?? 0) <= (v.info.order ?? 0) ? u : v;
|
|
344
350
|
const me = getMainEdge(e);
|
|
345
351
|
const sharesPair = (x: GraphEdge): boolean =>
|
|
346
352
|
(x.tail === u && x.head === v) || (x.tail === v && x.head === u);
|
|
347
|
-
|
|
353
|
+
return run.filter(x =>
|
|
348
354
|
sharesPair(x) && isGroupableFlat(x, g) && getMainEdge(x) === me);
|
|
349
|
-
group.sort((a, b) => Number(b.tail === lo) - Number(a.tail === lo) || a.seq - b.seq);
|
|
350
|
-
return group;
|
|
351
355
|
}
|
|
352
356
|
|
|
353
357
|
/**
|
|
@@ -360,7 +364,7 @@ function collectAdjacentFlatGroup(e: GraphEdge, g: Graph): GraphEdge[] {
|
|
|
360
364
|
* installEdgeSpline/arrowheadPolygon here.
|
|
361
365
|
* @see lib/dotgen/dotsplines.c:make_flat_edge, make_regular_edge
|
|
362
366
|
*/
|
|
363
|
-
function routeFaithfulSidePort(e: GraphEdge, g: Graph): boolean {
|
|
367
|
+
function routeFaithfulSidePort(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): boolean {
|
|
364
368
|
const sameRank = e.tail.info.rank !== undefined && e.tail.info.rank === e.head.info.rank;
|
|
365
369
|
// Adjacent flat endpoints route via the rotated-aux pipeline (make_flat_adj_edges),
|
|
366
370
|
// which installs the spline directly; the box channel handles non-adjacent flats.
|
|
@@ -368,7 +372,7 @@ function routeFaithfulSidePort(e: GraphEdge, g: Graph): boolean {
|
|
|
368
372
|
// route the whole group so the reversed back edge clones auxh->auxt and curls.
|
|
369
373
|
// @see lib/dotgen/dotsplines.c:dot_splines_ (ED_adjacent edge-group loop)
|
|
370
374
|
if (sameRank && isFlatAdjacent(g, e)) {
|
|
371
|
-
const group = collectAdjacentFlatGroup(e, g);
|
|
375
|
+
const group = collectAdjacentFlatGroup(e, g, run);
|
|
372
376
|
return makeFlatAdjEdges(g, group, group.length, edgeType(g)) === 0
|
|
373
377
|
&& routedThisPass(e);
|
|
374
378
|
}
|
|
@@ -388,19 +392,6 @@ function routeFaithfulSidePort(e: GraphEdge, g: Graph): boolean {
|
|
|
388
392
|
return true;
|
|
389
393
|
}
|
|
390
394
|
|
|
391
|
-
/** graphviz #1323: C make_flat_adj_edges bails on a flat edge between ADJACENT
|
|
392
|
-
* nodes with a record-shape endpoint — no spline is built, map_edge "lost"s it,
|
|
393
|
-
* and it is never drawn. Detect that case so the router leaves e.info.spl
|
|
394
|
-
* undefined (edgeHasDrawableContent then skips it), matching the oracle.
|
|
395
|
-
* @see lib/dotgen/dotsplines.c:make_flat_adj_edges */
|
|
396
|
-
function isLostFlatAdjRecordEdge(g: Graph, e: GraphEdge): boolean {
|
|
397
|
-
const tr = e.tail.info.rank;
|
|
398
|
-
if (tr === undefined || tr !== e.head.info.rank) return false;
|
|
399
|
-
if (!isFlatAdjacent(g, e)) return false;
|
|
400
|
-
const rec = (s: unknown): boolean => (s as ShapeDesc | undefined)?.kind === ShapeKind.SH_RECORD;
|
|
401
|
-
return rec(e.tail.info.shape) || rec(e.head.info.shape);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
395
|
/**
|
|
405
396
|
* Dispatch a same-rank (flat) edge to its faithful router. C routes flat edges
|
|
406
397
|
* by topology in `dot_splines_` independent of ED_dir (only the arrowheads
|
|
@@ -410,16 +401,16 @@ function isLostFlatAdjRecordEdge(g: Graph, e: GraphEdge): boolean {
|
|
|
410
401
|
* caller fall through to the regular/fitter path.
|
|
411
402
|
* @see lib/dotgen/dotsplines.c:dot_splines_ (flat edge group dispatch)
|
|
412
403
|
*/
|
|
413
|
-
function routeFlatEdge(e: GraphEdge, g: Graph): boolean {
|
|
414
|
-
if (
|
|
404
|
+
function routeFlatEdge(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): boolean {
|
|
405
|
+
if (lostFlatAdjRecordEdge(g, e)) return true; // #1323: lost edge, leave unrouted
|
|
415
406
|
// Labeled same-rank edges: non-adjacent routes around the flat label vnode
|
|
416
407
|
// (make_flat_labeled_edge); adjacent no-port routes straight with the label
|
|
417
408
|
// above (make_flat_adj_edges → makeSimpleFlatLabels). Both decline for every
|
|
418
409
|
// other edge, so only labeled flats are diverted. @see dotsplines.c:1527-1533
|
|
419
410
|
if (makeFlatLabeledEdge(g, e)) return true;
|
|
420
|
-
if (joinsPortedFlatGroup(e, g) && routeFaithfulSidePort(e, g)) return true;
|
|
411
|
+
if (joinsPortedFlatGroup(e, g, run) && routeFaithfulSidePort(e, g, run)) return true;
|
|
421
412
|
if (makeAdjFlatNoPortEdge(g, e)) return true;
|
|
422
|
-
if ((hasSidePort(e) || isAdjacentPortFlat(e, g)) && routeFaithfulSidePort(e, g)) return true;
|
|
413
|
+
if ((hasSidePort(e) || isAdjacentPortFlat(e, g)) && routeFaithfulSidePort(e, g, run)) return true;
|
|
423
414
|
// Non-adjacent unlabeled flat with no side port (e.g. a same-rank cross-cluster
|
|
424
415
|
// edge with an intervening node): C make_flat_edge routes it UP through the box
|
|
425
416
|
// corridor, not straight through. @see lib/dotgen/dotsplines.c:make_flat_edge
|
|
@@ -435,9 +426,9 @@ function routeFlatEdge(e: GraphEdge, g: Graph): boolean {
|
|
|
435
426
|
|
|
436
427
|
/** Route + install a plain forward edge, attaching declared ports if any. */
|
|
437
428
|
function routeForwardEdge(
|
|
438
|
-
e: GraphEdge, g: Graph, tailBox: NodeBox, headBox: NodeBox,
|
|
429
|
+
e: GraphEdge, g: Graph, tailBox: NodeBox, headBox: NodeBox, run: readonly GraphEdge[],
|
|
439
430
|
): void {
|
|
440
|
-
if (routeFlatEdge(e, g)) return;
|
|
431
|
+
if (routeFlatEdge(e, g, run)) return;
|
|
441
432
|
// T2 (AD-1/AD-2): plain adjacent-rank forward edges route through the faithful
|
|
442
433
|
// pathplan path (make_regular_edge). routeRegularEdgeFaithful declines (null)
|
|
443
434
|
// for anything not adjacent-rank, so the fitter below only handles declines.
|
|
@@ -447,7 +438,8 @@ function routeForwardEdge(
|
|
|
447
438
|
tailBox, headBox, rankInfo, edgePenwidthAttr(e), portRouteOf(e),
|
|
448
439
|
);
|
|
449
440
|
installEdgeSpline(e, result.bezierPts, result.arrowTip);
|
|
450
|
-
e.info.headArrowOps = arrowDrawOpsForEnd(
|
|
441
|
+
e.info.headArrowOps = arrowDrawOpsForEnd(
|
|
442
|
+
e, 'head', result.arrowTip, result.arrowDir, edgeRenderPenwidth(e));
|
|
451
443
|
}
|
|
452
444
|
|
|
453
445
|
/**
|
|
@@ -456,9 +448,12 @@ function routeForwardEdge(
|
|
|
456
448
|
* lacking valid coords). The `dotSplines_` group loop calls it for the edges it
|
|
457
449
|
* collected from the rank arrays, at their `edgecmp` position, as C does; an
|
|
458
450
|
* edge it did not collect keeps the route it had, as `ED_spl` does in C.
|
|
451
|
+
* `run` is the edgecmp run `e` belongs to, in list order: what C passes
|
|
452
|
+
* make_flat_edge as `edges + ind`, `cnt`. A flat-adjacent group is taken from
|
|
453
|
+
* it, so the aux edges are cloned in C's order.
|
|
459
454
|
* @see lib/dotgen/dotsplines.c:dot_splines_ (per-edge dispatch + 295 skip)
|
|
460
455
|
*/
|
|
461
|
-
export function routeLoneEdge(e: GraphEdge, g: Graph): void {
|
|
456
|
+
export function routeLoneEdge(e: GraphEdge, g: Graph, run: readonly GraphEdge[]): void {
|
|
462
457
|
// A lost edge (routesplines failure, C semantics) is consumed: C routes each
|
|
463
458
|
// edge exactly once, so a later group must not re-attempt it.
|
|
464
459
|
if (routedThisPass(e) || e.info.lost === true) return;
|
|
@@ -480,5 +475,5 @@ export function routeLoneEdge(e: GraphEdge, g: Graph): void {
|
|
|
480
475
|
// @see lib/dotgen/dotsplines.c:make_flat_labeled_edge, lib/common/emit.c:edge_in_box
|
|
481
476
|
if (e.tail === e.head) return;
|
|
482
477
|
if (!hasValidCoords(e)) return;
|
|
483
|
-
routeOneEdge(e, g);
|
|
478
|
+
routeOneEdge(e, g, run);
|
|
484
479
|
}
|
package/src/layout/dot/fastgr.ts
CHANGED
|
@@ -236,15 +236,21 @@ export function deleteFlatEdge(e: Edge): void {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
* Add `e` to the flat graph (tail.flat_out and head.flat_in) and mark
|
|
240
|
-
*
|
|
239
|
+
* Add `e` to the flat graph (tail.flat_out and head.flat_in) and mark `g` and
|
|
240
|
+
* its dot root as having flat edges. flat_reorder reads the flag of the graph
|
|
241
|
+
* it runs on, so an edge added through a subgraph (ordered_edges recursing
|
|
242
|
+
* into a rank subgraph, e.g. make_flat_adj_edges' `xxx`) must flag the root.
|
|
241
243
|
* @see lib/dotgen/fastgr.c:flat_edge
|
|
242
244
|
*/
|
|
243
|
-
export function flatEdge(g:
|
|
245
|
+
export function flatEdge(g: Graph, e: Edge): void {
|
|
244
246
|
if (!e.tail.info.flat_out) e.tail.info.flat_out = { list: [], size: 0 };
|
|
245
247
|
if (!e.head.info.flat_in) e.head.info.flat_in = { list: [], size: 0 };
|
|
246
248
|
elistAppend(e.tail.info.flat_out, e);
|
|
247
249
|
elistAppend(e.head.info.flat_in, e);
|
|
250
|
+
// C: GD_has_flat_edges(dot_root(g)) = GD_has_flat_edges(g) = true. dot_root
|
|
251
|
+
// is inlined (mincross-utils.ts:dotRoot imports this module).
|
|
252
|
+
// @see lib/dotgen/dotinit.c:dot_root
|
|
253
|
+
(g.info.dotroot ?? g.root).info.has_flat_edges = true;
|
|
248
254
|
g.info.has_flat_edges = true;
|
|
249
255
|
}
|
|
250
256
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The record exit of C `make_flat_adj_edges`: a flat edge between adjacent
|
|
5
|
+
* nodes one of which has a record shape gets no spline (graphviz #1323), and
|
|
6
|
+
* the first such edge of a process is reported.
|
|
7
|
+
*
|
|
8
|
+
* @see lib/dotgen/dotsplines.c:make_flat_adj_edges (1143-1152)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Graph } from '../../model/graph.js';
|
|
12
|
+
import type { Edge } from '../../model/edge.js';
|
|
13
|
+
import type { Node } from '../../model/node.js';
|
|
14
|
+
import { ShapeKind, type ShapeDesc } from '../../common/types.js';
|
|
15
|
+
import { agerr, agwarningf } from '../../common/agerr.js';
|
|
16
|
+
import { registerRenderState } from '../../common/render-state.js';
|
|
17
|
+
import { isFlatAdjacent, flatLeadPair } from './splines-flat.js';
|
|
18
|
+
|
|
19
|
+
/** @see lib/dotgen/dotsplines.c:1145 */
|
|
20
|
+
export const MSG_FLAT_ADJ_RECORD =
|
|
21
|
+
'flat edge between adjacent nodes one of which has a record shape - replace records with HTML-like labels';
|
|
22
|
+
|
|
23
|
+
const EDGEOP_DIRECTED = '->';
|
|
24
|
+
const EDGEOP_UNDIRECTED = '--';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* C's `static atomic_flag warned`: one warning per process, so one per render
|
|
28
|
+
* here (reset at render entry, AD-4).
|
|
29
|
+
* @see lib/dotgen/dotsplines.c:1141
|
|
30
|
+
*/
|
|
31
|
+
const flatAdjRecord = { warned: false };
|
|
32
|
+
registerRenderState(() => {
|
|
33
|
+
flatAdjRecord.warned = false;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** `shapeOf(n) == SH_RECORD`. @see lib/common/shapes.c:shapeOf */
|
|
37
|
+
function isRecord(n: Node): boolean {
|
|
38
|
+
return (n.info.shape as ShapeDesc | undefined)?.kind === ShapeKind.SH_RECORD;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** `agisdirected(g) ? "->" : "--"`. */
|
|
42
|
+
function edgeOp(g: Graph): string {
|
|
43
|
+
const kind = g.root.kind;
|
|
44
|
+
return kind === 'directed' || kind === 'strict-directed' ? EDGEOP_DIRECTED : EDGEOP_UNDIRECTED;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* True when `e` takes the record exit, in which case the caller leaves it
|
|
49
|
+
* unrouted (`map_edge` then reports it lost and it is never drawn). The first
|
|
50
|
+
* call that takes the exit warns, naming C's `e0`: the group's lead edge after
|
|
51
|
+
* `make_flat_edge`'s makefwdedge, i.e. the ends in rank order, by their raw
|
|
52
|
+
* `agnameof` names.
|
|
53
|
+
* @see lib/dotgen/dotsplines.c:make_flat_adj_edges (1143-1152)
|
|
54
|
+
* @see lib/dotgen/dotsplines.c:make_flat_edge (makefwdedge of *edges)
|
|
55
|
+
*/
|
|
56
|
+
export function lostFlatAdjRecordEdge(g: Graph, e: Edge): boolean {
|
|
57
|
+
const tr = e.tail.info.rank;
|
|
58
|
+
if (tr === undefined || tr !== e.head.info.rank) return false;
|
|
59
|
+
if (!isFlatAdjacent(g, e)) return false;
|
|
60
|
+
const { tn, hn } = flatLeadPair([e]);
|
|
61
|
+
if (!isRecord(tn) && !isRecord(hn)) return false;
|
|
62
|
+
if (!flatAdjRecord.warned) {
|
|
63
|
+
flatAdjRecord.warned = true;
|
|
64
|
+
agwarningf(MSG_FLAT_ADJ_RECORD);
|
|
65
|
+
agerr('prev', ` Edge ${tn.name} ${edgeOp(g)} ${hn.name}`);
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
package/src/layout/dot/flat.ts
CHANGED
|
@@ -356,18 +356,21 @@ export function hasInterveningNode(rk: RankEntry, lo: number, hi: number): boole
|
|
|
356
356
|
* `g` is the graph being laid out — C's `dot_root(tn)`, NOT `agroot(tn)`. See
|
|
357
357
|
* `flatNode` above for why these differ under `pack`.
|
|
358
358
|
*
|
|
359
|
+
* A self-loop is never adjacent: C's `for (i = lo + 1; i < hi; i++)` leaves
|
|
360
|
+
* `i == lo + 1` when `lo == hi`, so its `if (i == hi)` is false. dot_splines_'
|
|
361
|
+
* group loop reads the flag on loops too (dotsplines.c:366), so marking one
|
|
362
|
+
* would merge a node's loops across portcmp breaks.
|
|
363
|
+
*
|
|
359
364
|
* @see lib/dotgen/flat.c:checkFlatAdjacent (rank = &GD_rank(dot_root(tn))[...])
|
|
365
|
+
* @see lib/dotgen/flat.c:checkFlatAdjacent (16.1.1) 224-236
|
|
360
366
|
*/
|
|
361
367
|
export function checkFlatAdjacent(g: Graph, e: Edge): void {
|
|
362
368
|
const tOrd = nodeOrder(e.tail);
|
|
363
369
|
const hOrd = nodeOrder(e.head);
|
|
364
370
|
const lo = Math.min(tOrd, hOrd);
|
|
365
371
|
const hi = Math.max(tOrd, hOrd);
|
|
366
|
-
|
|
367
|
-
if (!
|
|
368
|
-
adjacent = !hasInterveningNode(g.info.rank![nodeRank(e.tail)], lo, hi);
|
|
369
|
-
}
|
|
370
|
-
if (!adjacent) return;
|
|
372
|
+
if (hi <= lo) return;
|
|
373
|
+
if (hasInterveningNode(g.info.rank![nodeRank(e.tail)], lo, hi)) return;
|
|
371
374
|
for (let le: Edge | undefined = e; le; le = le.info.to_virt) le.info.adjacent = 1;
|
|
372
375
|
}
|
|
373
376
|
|
|
@@ -401,30 +404,48 @@ export function markAdjacent(g: Graph): void {
|
|
|
401
404
|
}
|
|
402
405
|
}
|
|
403
406
|
|
|
407
|
+
/** True when `edges` holds a labeled edge that is not flat-adjacent.
|
|
408
|
+
* @see lib/dotgen/flat.c:flat_edges (16.1.1, 4e50c9abd) 277-289 */
|
|
409
|
+
function hasNonAdjacentLabel(edges: EdgeList | undefined): boolean {
|
|
410
|
+
if (!edges) return false;
|
|
411
|
+
for (let j = 0; j < edges.size; j++) {
|
|
412
|
+
if (isLabeledFlat(edges.list[j]) && !edges.list[j].info.adjacent) return true;
|
|
413
|
+
}
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Per node of the rank, C scans `ND_flat_in` and then `ND_other` (the scan
|
|
419
|
+
* upstream 4e50c9abd added for gitlab #2756) for a labeled non-adjacent edge.
|
|
420
|
+
* The `ND_other` scan has no rank filter and no loop filter, so a labeled
|
|
421
|
+
* self-loop counts: checkFlatAdjacent never marks one.
|
|
422
|
+
* @see lib/dotgen/flat.c:flat_edges (16.1.1, 4e50c9abd) 276-290
|
|
423
|
+
*/
|
|
404
424
|
export function rankHasNonAdjacentLabel(rk: RankEntry): boolean {
|
|
405
425
|
for (let i = 0; i < rk.n; i++) {
|
|
406
|
-
const
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
if (isLabeledFlat(fo.list[j]) && !fo.list[j].info.adjacent) return true;
|
|
410
|
-
}
|
|
426
|
+
const n = rk.v[i];
|
|
427
|
+
if (hasNonAdjacentLabel(n.info.flat_in)) return true;
|
|
428
|
+
if (hasNonAdjacentLabel(n.info.other)) return true;
|
|
411
429
|
}
|
|
412
430
|
return false;
|
|
413
431
|
}
|
|
414
432
|
|
|
415
433
|
/**
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* `
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
434
|
+
* C's gate, `GD_rank(g)[0].flat || GD_n_cluster(g) > 0`, then the scan of the
|
|
435
|
+
* lowest rank. The matrix field is read as a flag: cleanup2 calls
|
|
436
|
+
* `free_matrix(GD_rank(g)[r].flat)` (mincross.c:864) and free_matrix
|
|
437
|
+
* (mincross.c:415-420) frees without nulling it, so here it is non-null
|
|
438
|
+
* exactly when some flat_breakcycles run on the root saw a node of the rank
|
|
439
|
+
* with a flat out-edge (FLATORDER edges included). `cleanup2Ranks` keeps the
|
|
440
|
+
* field for this read. Without the gate the `ND_other` scan would add a rank
|
|
441
|
+
* for a labeled rank-0 self-loop in a graph where C adds none.
|
|
442
|
+
* @see lib/dotgen/flat.c:flat_edges (16.1.1, 4e50c9abd) 274-291
|
|
423
443
|
*/
|
|
424
444
|
export function needsAbomination(g: Graph): boolean {
|
|
425
445
|
const mn = graphMinrank(g);
|
|
426
446
|
const rank = g.info.rank;
|
|
427
447
|
if (!rank || rank[mn] === undefined) return false;
|
|
448
|
+
if (rank[mn].flat === undefined && (g.info.n_cluster ?? 0) <= 0) return false;
|
|
428
449
|
return rankHasNonAdjacentLabel(rank[mn]);
|
|
429
450
|
}
|
|
430
451
|
|
package/src/layout/dot/init.ts
CHANGED
|
@@ -119,26 +119,72 @@ export function dotInitNode(n: Node): void {
|
|
|
119
119
|
// ---------------------------------------------------------------------------
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* Which of
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
122
|
+
* Which of the attribute symbols make_flat_adj_edges' setState nulls are bound.
|
|
123
|
+
* C reads each attribute through a global (bound per graph by graph_init).
|
|
124
|
+
* setState nulls thirteen of them for the aux layout and cleanupCloneGraph
|
|
125
|
+
* restores them. Seven are modelled here, because a bound read changes what
|
|
126
|
+
* the aux graph holds:
|
|
127
|
+
*
|
|
128
|
+
* - E_constr, E_minlen, N_group (dot_init_edge): an aux edge's copied
|
|
129
|
+
* `constraint=false` or `minlen`, and its clones' `group`, are never read:
|
|
130
|
+
* late_int(e, NULL, 1, 0) is 1 and late_string(n, NULL, "") "".
|
|
131
|
+
* - E_headlabel, E_taillabel, E_xlabel (common_init_edge, utils.c:525-545) and
|
|
132
|
+
* N_xlabel (common_init_node, utils.c:443): the `sym && ...` guards fail, so
|
|
133
|
+
* the aux makes no head, tail or external label and sets none of their
|
|
134
|
+
* GD_has_labels bits. A bound read made each label a second time: a
|
|
135
|
+
* malformed HTML value was reported twice where native reports it once, and
|
|
136
|
+
* the aux postprocess (addXLabels, the aux bounding box) saw labels C never
|
|
137
|
+
* makes.
|
|
138
|
+
*
|
|
139
|
+
* The other six set a field on an aux object that no aux pass reads and that
|
|
140
|
+
* cleanupCloneGraph discards, so they have no gate. Each was probed against
|
|
141
|
+
* native 16.1.0 on flat-adjacent inputs that set it (issue #131: dot, xdot,
|
|
142
|
+
* svg and stderr equal on every input that equals native without it):
|
|
143
|
+
*
|
|
144
|
+
* - E_fontcolor (initFontEdgeAttr, utils.c:460), E_labelfontcolor
|
|
145
|
+
* (initFontLabelEdgeAttr, utils.c:470) and N_fontcolor (common_init_node,
|
|
146
|
+
* utils.c:440): the colour of an aux label. Only the aux edge label's
|
|
147
|
+
* position is copied back.
|
|
148
|
+
* - N_nojustify (poly_init, shapes.c:2133): the aux node label's space.x.
|
|
149
|
+
* - N_showboxes (common_init_node, utils.c:450): not read by the port's init.
|
|
150
|
+
* - N_style (stylenode, shapes.c:471): render only, and the aux is never
|
|
151
|
+
* rendered.
|
|
152
|
+
*
|
|
153
|
+
* _dot_splines' port-label pass tests `E_headlabel || E_taillabel`
|
|
154
|
+
* (dotsplines.c:447). The port's placePortLabels tests whether the attributes
|
|
155
|
+
* are declared, which is true on the aux graph. With no head or tail label on
|
|
156
|
+
* any aux edge its loops do nothing, which is C's result.
|
|
157
|
+
* @see lib/common/input.c:graph_init (E_constr, E_minlen, N_group, ...)
|
|
129
158
|
* @see lib/dotgen/dotsplines.c:setState, cleanupCloneGraph
|
|
130
159
|
*/
|
|
131
160
|
export interface InitEdgeSyms {
|
|
161
|
+
/** E_constr. */
|
|
132
162
|
readonly constr: boolean;
|
|
163
|
+
/** E_minlen. */
|
|
133
164
|
readonly minlen: boolean;
|
|
165
|
+
/** N_group. */
|
|
134
166
|
readonly group: boolean;
|
|
167
|
+
/** E_headlabel. */
|
|
168
|
+
readonly headlabel: boolean;
|
|
169
|
+
/** E_taillabel. */
|
|
170
|
+
readonly taillabel: boolean;
|
|
171
|
+
/** E_xlabel. */
|
|
172
|
+
readonly xlabel: boolean;
|
|
173
|
+
/** N_xlabel. */
|
|
174
|
+
readonly nodeXlabel: boolean;
|
|
135
175
|
}
|
|
136
176
|
|
|
137
177
|
/** The main graph's symbols, as graph_init binds them. */
|
|
138
|
-
export const DOT_INIT_SYMS: InitEdgeSyms = {
|
|
178
|
+
export const DOT_INIT_SYMS: InitEdgeSyms = {
|
|
179
|
+
constr: true, minlen: true, group: true,
|
|
180
|
+
headlabel: true, taillabel: true, xlabel: true, nodeXlabel: true,
|
|
181
|
+
};
|
|
139
182
|
|
|
140
183
|
/** The flat-adj aux graph's symbols. @see lib/dotgen/dotsplines.c:setState */
|
|
141
|
-
export const AUX_INIT_SYMS: InitEdgeSyms = {
|
|
184
|
+
export const AUX_INIT_SYMS: InitEdgeSyms = {
|
|
185
|
+
constr: false, minlen: false, group: false,
|
|
186
|
+
headlabel: false, taillabel: false, xlabel: false, nodeXlabel: false,
|
|
187
|
+
};
|
|
142
188
|
|
|
143
189
|
/**
|
|
144
190
|
* True when tail and head carry the same non-empty `group` attribute.
|
|
@@ -257,21 +303,21 @@ function clearFastGraphLists(n: Node): void {
|
|
|
257
303
|
/**
|
|
258
304
|
* Calls commonInitNode (shape-aware, label-driven sizing) then
|
|
259
305
|
* dotInitNode for every node, then dotInitEdge for every edge. `syms` stands
|
|
260
|
-
* for the global symbol state C's dot_init_edge
|
|
261
|
-
* make_flat_adj_edges).
|
|
306
|
+
* for the global symbol state C's dot_init_edge, common_init_node and
|
|
307
|
+
* common_init_edge read (AUX_INIT_SYMS inside make_flat_adj_edges).
|
|
262
308
|
*
|
|
263
309
|
* @see lib/dotgen/dotinit.c:dot_init_node_edge
|
|
264
310
|
* @see lib/dotgen/dotinit.c:dot_init_node (common_init_node + gv_nodesize)
|
|
265
311
|
*/
|
|
266
312
|
export function dotInitNodeEdge(g: Graph, syms: InitEdgeSyms = DOT_INIT_SYMS): void {
|
|
267
313
|
for (const n of nodesInSeq(g)) {
|
|
268
|
-
commonInitNode(n, g);
|
|
314
|
+
commonInitNode(n, g, syms);
|
|
269
315
|
dotInitNode(n);
|
|
270
316
|
}
|
|
271
317
|
const measurer = g.root.info.gvc?.textMeasurer;
|
|
272
318
|
for (const e of g.edges) {
|
|
273
319
|
dotInitEdge(e, syms);
|
|
274
|
-
if (measurer) initEdgeLabels(e, g, measurer);
|
|
320
|
+
if (measurer) initEdgeLabels(e, g, measurer, syms);
|
|
275
321
|
}
|
|
276
322
|
}
|
|
277
323
|
|
|
@@ -23,6 +23,8 @@ import { CLUSTER, isACluster } from './rank.js';
|
|
|
23
23
|
import { installCluster, expandCluster, markLowclusters } from './cluster.js';
|
|
24
24
|
import { agnode, agsubg, agsubnode, agGraphAttr } from '../../model/cgraph-ops.js';
|
|
25
25
|
import { nodesInSeq } from './decomp.js';
|
|
26
|
+
import { nodeAttr } from '../../common/attr-get.js';
|
|
27
|
+
import { agerrorf } from '../../common/agerr.js';
|
|
26
28
|
|
|
27
29
|
// betweenclust — @see lib/dotgen/mincross.c:betweenclust
|
|
28
30
|
export function betweenclust(e: Edge): boolean {
|
|
@@ -338,11 +340,20 @@ export function doOrderingNode(ctx: MincrossContext, g: Graph, n: Node, outflag:
|
|
|
338
340
|
doOrderingAddFlatEdges(g, sortlist, outflag);
|
|
339
341
|
}
|
|
340
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Order the nodes that carry `ordering`. C reads
|
|
345
|
+
* `late_string(n, N_ordering, NULL)`, which is agxget: the node's own value,
|
|
346
|
+
* else the `node [...]` default the node was created under ({@link nodeAttr}).
|
|
347
|
+
* @see lib/dotgen/mincross.c:do_ordering_for_nodes (489)
|
|
348
|
+
*/
|
|
341
349
|
export function doOrderingForNodes(ctx: MincrossContext, g: Graph): void {
|
|
342
350
|
for (const n of nodesInSeq(g)) {
|
|
343
|
-
const ordering = n
|
|
351
|
+
const ordering = nodeAttr(n, g, 'ordering');
|
|
344
352
|
if (ordering === 'out') doOrderingNode(ctx, g, n, true);
|
|
345
353
|
else if (ordering === 'in') doOrderingNode(ctx, g, n, false);
|
|
354
|
+
else if (ordering !== undefined && ordering !== '') {
|
|
355
|
+
agerrorf(`ordering '${ordering}' not recognized for node '${n.name}'.`);
|
|
356
|
+
}
|
|
346
357
|
}
|
|
347
358
|
}
|
|
348
359
|
|
|
@@ -359,10 +370,12 @@ export function orderedEdges(ctx: MincrossContext, g: Graph): void {
|
|
|
359
370
|
// does NOT recurse into subgraphs. So C silently ignores subgraph-scoped
|
|
360
371
|
// ordering; only a root-level (or cluster's own) "out"/"in" is applied.
|
|
361
372
|
// agGraphAttr reproduces the load-bearing "" vs undefined distinction.
|
|
373
|
+
// Any other non-empty value is an error (525), and still does not recurse.
|
|
362
374
|
const ordering = agGraphAttr(g, 'ordering');
|
|
363
375
|
if (ordering !== undefined) {
|
|
364
376
|
if (ordering === 'out') doOrdering(ctx, g, true);
|
|
365
377
|
else if (ordering === 'in') doOrdering(ctx, g, false);
|
|
378
|
+
else if (ordering !== '') agerrorf(`ordering '${ordering}' not recognized.`);
|
|
366
379
|
return;
|
|
367
380
|
}
|
|
368
381
|
for (const subg of g.subgraphs.values()) {
|
|
@@ -150,15 +150,25 @@ export function postorder(g: Graph, v: Node, list: Node[], r: number): void {
|
|
|
150
150
|
list.push(v);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Builds the reverse topological sort order of one rank in `temprank` and
|
|
155
|
+
* returns C's `valid_rank`: false as soon as the walk meets a node that is
|
|
156
|
+
* neither free of constraining flat edges nor an unmarked source (C's
|
|
157
|
+
* `break`), which tells the caller to leave the rank as mincross ordered it.
|
|
158
|
+
* Graphviz 16.1.1, upstream 9fb21f570.
|
|
159
|
+
*
|
|
160
|
+
* @see lib/dotgen/mincross.c:flat_reorder
|
|
161
|
+
*/
|
|
162
|
+
export function flatReorderBuildTemprank(g: Graph, rk: RankEntry, temprank: Node[], flip: boolean): boolean {
|
|
155
163
|
for (let i = 0; i < rk.n; i++) {
|
|
156
164
|
const v = flip ? rankGet(rk, i) : rankGet(rk, rk.n - i - 1);
|
|
157
165
|
const inCnt = v.info.flat_in !== undefined ? countConstraining(g, v.info.flat_in) : 0;
|
|
158
166
|
const outCnt = v.info.flat_out !== undefined ? countConstraining(g, v.info.flat_out) : 0;
|
|
159
167
|
if (inCnt === 0 && outCnt === 0) { temprank.push(v); continue; }
|
|
160
|
-
if (!v.info.mark && inCnt === 0) postorder(g, v, temprank, v.info.rank !== undefined ? v.info.rank! : 0);
|
|
168
|
+
if (!v.info.mark && inCnt === 0) { postorder(g, v, temprank, v.info.rank !== undefined ? v.info.rank! : 0); continue; }
|
|
169
|
+
return false;
|
|
161
170
|
}
|
|
171
|
+
return true;
|
|
162
172
|
}
|
|
163
173
|
|
|
164
174
|
export function flatReorderFixEdges(g: Graph, rk: RankEntry, flip: boolean): void {
|
|
@@ -188,8 +198,8 @@ export function flatReorderRank(g: Graph, rk: RankEntry, rootRank: RankEntry[],
|
|
|
188
198
|
const baseOrder = rankGet(rk, 0).info.order !== undefined ? rankGet(rk, 0).info.order! : 0;
|
|
189
199
|
for (let i = 0; i < rk.n; i++) rankGet(rk, i).info.mark = 0;
|
|
190
200
|
const temprank: Node[] = [];
|
|
191
|
-
flatReorderBuildTemprank(g, rk, temprank, flip);
|
|
192
|
-
if (temprank.length > 0) {
|
|
201
|
+
const validRank = flatReorderBuildTemprank(g, rk, temprank, flip);
|
|
202
|
+
if (validRank && temprank.length > 0) {
|
|
193
203
|
if (!flip) temprank.reverse();
|
|
194
204
|
for (let i = 0; i < rk.n; i++) {
|
|
195
205
|
rankSet(rk, i, temprank[i]!);
|
|
@@ -237,7 +237,12 @@ export function cleanup2(ctx: MincrossContext, g: Graph): void {
|
|
|
237
237
|
cleanup2Ranks(g);
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* `rank[r].flat` is left set: C's `free_matrix(GD_rank(g)[r].flat)` frees the
|
|
242
|
+
* matrix without nulling the field (mincross.c:415-420), and flat_edges then
|
|
243
|
+
* reads `GD_rank(g)[0].flat` as a flag (flat.c:274, `needsAbomination`).
|
|
244
|
+
* @see lib/dotgen/mincross.c:cleanup2 (rank loop; 16.1.1 853-865)
|
|
245
|
+
*/
|
|
241
246
|
export function cleanup2Ranks(g: Graph): void {
|
|
242
247
|
const rank = g.info.rank;
|
|
243
248
|
if (!rank) return;
|
|
@@ -248,7 +253,6 @@ export function cleanup2Ranks(g: Graph): void {
|
|
|
248
253
|
rank[r].v[i].info.order = i;
|
|
249
254
|
removeFlatorderEdges(rank[r].v[i]);
|
|
250
255
|
}
|
|
251
|
-
rank[r].flat = undefined;
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
258
|
|
|
@@ -5,6 +5,7 @@ import type { Edge } from '../../model/edge.js';
|
|
|
5
5
|
import { addTreeEdge, isTreeEdge, nsSlack } from './ns-core.js';
|
|
6
6
|
import type { NsCtx } from './ns-core.js';
|
|
7
7
|
import { initCutvalues } from './ns-range.js';
|
|
8
|
+
import { saddSaturate } from '../../util/overflow.js';
|
|
8
9
|
|
|
9
10
|
// ---------------------------------------------------------------------------
|
|
10
11
|
// Types
|
|
@@ -262,19 +263,22 @@ export function stExtractMin(heap: STheap): Subtree {
|
|
|
262
263
|
|
|
263
264
|
/**
|
|
264
265
|
* Add `delta` to ND_rank of every node in the tight tree reachable from `v`
|
|
265
|
-
* (the parent back-edge to `from` excluded)
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
266
|
+
* (the parent back-edge to `from` excluded), clamping each sum to
|
|
267
|
+
* [INT_MIN, INT_MAX] as C's `sadd_saturate` does (graphviz 16.1.1, upstream
|
|
268
|
+
* issue 2758). C's `tree_adjust` is a DFS; the tight tree is acyclic, so each
|
|
269
|
+
* node is visited exactly once and the mutation
|
|
270
|
+
* (`rank = sadd_saturate(rank, delta)`) depends only on the node's own rank,
|
|
271
|
+
* which makes it order-independent. Ported with an explicit stack instead of
|
|
272
|
+
* recursion: deep trees (e.g. corpus 2646, a 7-deep quadtree with thousands of
|
|
273
|
+
* nodes) overflow the JS call stack where C's larger native stack does not.
|
|
274
|
+
* Outcome is identical to the recursive form.
|
|
271
275
|
* @see lib/common/ns.c:tree_adjust
|
|
272
276
|
*/
|
|
273
277
|
export function treeAdjust(v: Node, from: Node | undefined, delta: number): void {
|
|
274
278
|
const stack: Array<[Node, Node | undefined]> = [[v, from]];
|
|
275
279
|
while (stack.length > 0) {
|
|
276
280
|
const [n, f] = stack.pop()!;
|
|
277
|
-
n.info.rank = (n.info.rank ?? 0
|
|
281
|
+
n.info.rank = saddSaturate(n.info.rank ?? 0, delta);
|
|
278
282
|
const ti = n.info.tree_in;
|
|
279
283
|
if (ti) for (let i = 0; i < ti.size; i++) {
|
|
280
284
|
const w = ti.list[i].tail;
|