@knowvah/dot-engine 2.10.2 → 2.11.0
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/gvc/context.d.ts.map +1 -1
- package/dist/gvc/emit-xdot.d.ts.map +1 -1
- package/dist/gvc/layout-reset.d.ts +38 -1
- package/dist/gvc/layout-reset.d.ts.map +1 -1
- package/dist/index.js +1191 -423
- package/dist/index.js.map +4 -4
- package/dist/layout/circo/circular.d.ts.map +1 -1
- package/dist/layout/circo/index.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-helpers.d.ts +6 -1
- package/dist/layout/dot/edge-route-helpers.d.ts.map +1 -1
- package/dist/layout/dot/edge-route-rank.d.ts +4 -1
- package/dist/layout/dot/edge-route-rank.d.ts.map +1 -1
- package/dist/layout/dot/index.d.ts.map +1 -1
- package/dist/layout/dot/init.d.ts +0 -10
- package/dist/layout/dot/init.d.ts.map +1 -1
- package/dist/layout/fdp/cluster-edges.d.ts +11 -0
- package/dist/layout/fdp/cluster-edges.d.ts.map +1 -1
- package/dist/layout/fdp/init.d.ts.map +1 -1
- package/dist/layout/neato/closest.d.ts +20 -0
- package/dist/layout/neato/closest.d.ts.map +1 -0
- package/dist/layout/neato/constrained-majorization.d.ts +13 -0
- package/dist/layout/neato/constrained-majorization.d.ts.map +1 -1
- package/dist/layout/neato/embed-graph.d.ts +20 -0
- package/dist/layout/neato/embed-graph.d.ts.map +1 -0
- package/dist/layout/neato/fdp-adjust.d.ts.map +1 -1
- package/dist/layout/neato/index.d.ts.map +1 -1
- package/dist/layout/neato/init-dim.d.ts +54 -0
- package/dist/layout/neato/init-dim.d.ts.map +1 -0
- package/dist/layout/neato/init.d.ts +1 -11
- package/dist/layout/neato/init.d.ts.map +1 -1
- package/dist/layout/neato/kk.d.ts +4 -2
- package/dist/layout/neato/kk.d.ts.map +1 -1
- package/dist/layout/neato/matrix-ops-dense.d.ts +34 -0
- package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -0
- package/dist/layout/neato/pca.d.ts +14 -0
- package/dist/layout/neato/pca.d.ts.map +1 -0
- package/dist/layout/neato/sgd.d.ts +2 -3
- package/dist/layout/neato/sgd.d.ts.map +1 -1
- package/dist/layout/neato/start.d.ts +5 -5
- package/dist/layout/neato/start.d.ts.map +1 -1
- package/dist/layout/neato/stress-kernel.d.ts +10 -2
- package/dist/layout/neato/stress-kernel.d.ts.map +1 -1
- package/dist/layout/neato/stress-subspace.d.ts +39 -0
- package/dist/layout/neato/stress-subspace.d.ts.map +1 -0
- package/dist/layout/neato/vpsc-adjust.d.ts.map +1 -1
- package/dist/layout/osage/index.d.ts +1 -4
- package/dist/layout/osage/index.d.ts.map +1 -1
- package/dist/layout/pack/ccomps.d.ts +4 -2
- package/dist/layout/pack/ccomps.d.ts.map +1 -1
- package/dist/layout/patchwork/index.d.ts.map +1 -1
- package/dist/layout/sfdp/index.d.ts.map +1 -1
- package/dist/layout/sfdp/init.d.ts +6 -7
- package/dist/layout/sfdp/init.d.ts.map +1 -1
- package/dist/layout/twopi/circle.d.ts.map +1 -1
- package/dist/layout/twopi/index.d.ts.map +1 -1
- package/dist/layout/twopi/init.d.ts.map +1 -1
- package/dist/render/dot/attrs.d.ts +7 -0
- package/dist/render/dot/attrs.d.ts.map +1 -1
- package/dist/render.js +1574 -806
- package/dist/render.js.map +4 -4
- package/package.json +4 -4
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +20 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +20 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +20 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-pack.gv +1 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.1 +22 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +22 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +22 -0
- package/src/gvc/__fixtures__/rerender/abom-shift-parity.gv +1 -0
- package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.1 +13 -0
- package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.2 +13 -0
- package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.3 +13 -0
- package/src/gvc/__fixtures__/rerender/abom-shift.gv +1 -0
- package/src/gvc/__fixtures__/rerender/cluster-edge-splines.fdp.plain.1 +10 -0
- package/src/gvc/__fixtures__/rerender/cluster-edge-splines.fdp.plain.2 +11 -0
- package/src/gvc/__fixtures__/rerender/cluster-edge-splines.gv +9 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.dot.1 +40 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.dot.2 +40 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.plain.noaddr.1 +15 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.plain.noaddr.2 +17 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-plain.1 +40 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-plain.2 +15 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-svg.1 +40 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-svg.2 +99 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-json-json.1 +489 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-json-json.2 +503 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-nofree-dot-svg.1 +40 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-nofree-dot-svg.2 +109 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.xdot.1 +69 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.xdot.2 +70 -0
- package/src/gvc/__fixtures__/rerender/cluster-edges.gv +15 -0
- package/src/gvc/__fixtures__/rerender/fdp-1581.fdp.dot.1 +104 -0
- package/src/gvc/__fixtures__/rerender/fdp-1581.fdp.dot.2 +104 -0
- package/src/gvc/__fixtures__/rerender/fdp-1581.gv +26 -0
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +34 -0
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +34 -0
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +34 -0
- package/src/gvc/__fixtures__/rerender/flat-rev-stale.gv +33 -0
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +181 -0
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +218 -0
- package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +255 -0
- package/src/gvc/__fixtures__/rerender/regen.sh +25 -0
- package/src/gvc/context.ts +7 -2
- package/src/gvc/emit-xdot.ts +37 -7
- package/src/gvc/layout-reset.ts +68 -2
- package/src/layout/circo/circular.ts +3 -1
- package/src/layout/circo/index.ts +1 -3
- package/src/layout/dot/edge-route-helpers.ts +8 -2
- package/src/layout/dot/edge-route-rank.ts +20 -2
- package/src/layout/dot/index.ts +17 -2
- package/src/layout/dot/init.ts +11 -49
- package/src/layout/dot/splines-flat.ts +12 -12
- package/src/layout/fdp/cluster-edges.ts +0 -0
- package/src/layout/fdp/init.ts +2 -17
- package/src/layout/neato/__fixtures__/dim/circuit-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/circuit-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/circuit-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/circuit-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/dim11-dimen11.dot +32 -0
- package/src/layout/neato/__fixtures__/dim/dim11-dimen11.gv +11 -0
- package/src/layout/neato/__fixtures__/dim/dim11-dimen11.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/dim11-dimen11.xdot +53 -0
- package/src/layout/neato/__fixtures__/dim/dim3-dimen3.dot +32 -0
- package/src/layout/neato/__fixtures__/dim/dim3-dimen3.gv +11 -0
- package/src/layout/neato/__fixtures__/dim/dim3-dimen3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/dim3-dimen3.xdot +53 -0
- package/src/layout/neato/__fixtures__/dim/dim3.dot +31 -0
- package/src/layout/neato/__fixtures__/dim/dim3.gv +10 -0
- package/src/layout/neato/__fixtures__/dim/dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/dim3.xdot +52 -0
- package/src/layout/neato/__fixtures__/dim/dim4-dimen4.dot +32 -0
- package/src/layout/neato/__fixtures__/dim/dim4-dimen4.gv +11 -0
- package/src/layout/neato/__fixtures__/dim/dim4-dimen4.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/dim4-dimen4.xdot +53 -0
- package/src/layout/neato/__fixtures__/dim/dimen3.dot +31 -0
- package/src/layout/neato/__fixtures__/dim/dimen3.gv +10 -0
- package/src/layout/neato/__fixtures__/dim/dimen3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/dimen3.xdot +52 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +267 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.gv +84 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +468 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +267 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.gv +84 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +468 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +268 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.gv +85 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +469 -0
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +484 -0
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.gv +151 -0
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +852 -0
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +34 -0
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.gv +13 -0
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +55 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim4.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim4.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.dot +32 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.gv +11 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.xdot +53 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.dot +34 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.gv +13 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.xdot +55 -0
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +37 -0
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +58 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +141 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.gv +48 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.stderr +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +233 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.dot +21 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.gv +8 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.stderr +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.xdot +33 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.dot +23 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.gv +10 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.stderr +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.xdot +35 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.dot +23 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.gv +10 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.stderr +1 -0
- package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.xdot +35 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.dot +26 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.gv +7 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.xdot +44 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.dot +28 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.gv +9 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.xdot +46 -0
- package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.dot +48 -0
- package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.gv +15 -0
- package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.xdot +79 -0
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +56 -0
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.gv +17 -0
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +94 -0
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +47 -0
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.gv +14 -0
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +78 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.dot +34 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.gv +13 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.xdot +55 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +34 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.gv +13 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +55 -0
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +34 -0
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.gv +13 -0
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +55 -0
- package/src/layout/neato/__fixtures__/dim/hier-two-dim3.dot +15 -0
- package/src/layout/neato/__fixtures__/dim/hier-two-dim3.gv +6 -0
- package/src/layout/neato/__fixtures__/dim/hier-two-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/hier-two-dim3.xdot +22 -0
- package/src/layout/neato/__fixtures__/dim/ipsep-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/ipsep-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/ipsep-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/ipsep-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.dot +39 -0
- package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.gv +15 -0
- package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.xdot +60 -0
- package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/pack-dim3.dot +47 -0
- package/src/layout/neato/__fixtures__/dim/pack-dim3.gv +14 -0
- package/src/layout/neato/__fixtures__/dim/pack-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/pack-dim3.xdot +78 -0
- package/src/layout/neato/__fixtures__/dim/pins-dim3.dot +38 -0
- package/src/layout/neato/__fixtures__/dim/pins-dim3.gv +14 -0
- package/src/layout/neato/__fixtures__/dim/pins-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/pins-dim3.xdot +59 -0
- package/src/layout/neato/__fixtures__/dim/regen.sh +24 -0
- package/src/layout/neato/__fixtures__/dim/regular-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/regular-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/regular-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/regular-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/sgd-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/sgd-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/sgd-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/sgd-dim3.xdot +54 -0
- package/src/layout/neato/__fixtures__/dim/smart-units.json +16 -0
- package/src/layout/neato/__fixtures__/dim/subset-dim3.dot +33 -0
- package/src/layout/neato/__fixtures__/dim/subset-dim3.gv +12 -0
- package/src/layout/neato/__fixtures__/dim/subset-dim3.stderr +0 -0
- package/src/layout/neato/__fixtures__/dim/subset-dim3.xdot +54 -0
- package/src/layout/neato/closest.ts +206 -0
- package/src/layout/neato/constrained-majorization.ts +4 -23
- package/src/layout/neato/embed-graph.ts +81 -0
- package/src/layout/neato/fdp-adjust.ts +22 -8
- package/src/layout/neato/index.ts +26 -17
- package/src/layout/neato/init-dim.ts +165 -0
- package/src/layout/neato/init.ts +10 -38
- package/src/layout/neato/kk.ts +47 -41
- package/src/layout/neato/matrix-ops-dense.ts +232 -0
- package/src/layout/neato/pca.ts +60 -0
- package/src/layout/neato/sgd.ts +11 -4
- package/src/layout/neato/start.ts +8 -5
- package/src/layout/neato/stress-kernel.ts +65 -5
- package/src/layout/neato/stress-subspace.ts +371 -0
- package/src/layout/neato/vpsc-adjust.ts +3 -1
- package/src/layout/osage/index.ts +3 -22
- package/src/layout/pack/__fixtures__/cc-reuse/circo.dot +23 -0
- package/src/layout/pack/__fixtures__/cc-reuse/circo.gv +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/circo.stderr +0 -0
- package/src/layout/pack/__fixtures__/cc-reuse/circo.xdot +38 -0
- package/src/layout/pack/__fixtures__/cc-reuse/neato.dot +23 -0
- package/src/layout/pack/__fixtures__/cc-reuse/neato.gv +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/neato.stderr +0 -0
- package/src/layout/pack/__fixtures__/cc-reuse/neato.xdot +38 -0
- package/src/layout/pack/__fixtures__/cc-reuse/osage.dot +23 -0
- package/src/layout/pack/__fixtures__/cc-reuse/osage.gv +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/osage.stderr +0 -0
- package/src/layout/pack/__fixtures__/cc-reuse/osage.xdot +38 -0
- package/src/layout/pack/__fixtures__/cc-reuse/regen.sh +24 -0
- package/src/layout/pack/__fixtures__/cc-reuse/sfdp.dot +21 -0
- package/src/layout/pack/__fixtures__/cc-reuse/sfdp.gv +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/sfdp.stderr +0 -0
- package/src/layout/pack/__fixtures__/cc-reuse/sfdp.xdot +36 -0
- package/src/layout/pack/__fixtures__/cc-reuse/twopi.dot +21 -0
- package/src/layout/pack/__fixtures__/cc-reuse/twopi.gv +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/twopi.stderr +1 -0
- package/src/layout/pack/__fixtures__/cc-reuse/twopi.xdot +36 -0
- package/src/layout/pack/ccomps.ts +34 -6
- package/src/layout/patchwork/index.ts +1 -3
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +32 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.gv +11 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.stderr +0 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.xdot +53 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3.dot +31 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3.gv +10 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3.stderr +0 -0
- package/src/layout/sfdp/__fixtures__/dim/dim3.xdot +52 -0
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +32 -0
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.gv +11 -0
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.stderr +0 -0
- package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.xdot +53 -0
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +33 -0
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.gv +12 -0
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.stderr +0 -0
- package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.xdot +54 -0
- package/src/layout/sfdp/__fixtures__/dim/regen.sh +24 -0
- package/src/layout/sfdp/index.ts +15 -10
- package/src/layout/sfdp/init.ts +27 -14
- package/src/layout/twopi/circle.ts +5 -1
- package/src/layout/twopi/index.ts +3 -0
- package/src/layout/twopi/init.ts +1 -3
- package/src/render/dot/agwrite.ts +2 -2
- package/src/render/dot/attrs.ts +16 -0
- package/src/render/dot/write-back.ts +2 -2
package/dist/render.js
CHANGED
|
@@ -121,6 +121,24 @@ function rethrowAtBoundary(err) {
|
|
|
121
121
|
throw new InternalError(messageOf(err), { cause: err });
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// src/model/lazy-attrs.ts
|
|
125
|
+
var SharedEmptyAttrs = class extends Map {
|
|
126
|
+
set(key, _value) {
|
|
127
|
+
throw new Error(`attrs.set("${key}") on a shared empty map; use ownAttrs()`);
|
|
128
|
+
}
|
|
129
|
+
delete(key) {
|
|
130
|
+
throw new Error(`attrs.delete("${key}") on a shared empty map; use ownAttrs()`);
|
|
131
|
+
}
|
|
132
|
+
clear() {
|
|
133
|
+
throw new Error("attrs.clear() on a shared empty map; use ownAttrs()");
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var EMPTY_ATTRS = new SharedEmptyAttrs();
|
|
137
|
+
function ownAttrs(o) {
|
|
138
|
+
if (o.attrs === EMPTY_ATTRS) o.attrs = /* @__PURE__ */ new Map();
|
|
139
|
+
return o.attrs;
|
|
140
|
+
}
|
|
141
|
+
|
|
124
142
|
// src/model/edgeInfo.ts
|
|
125
143
|
function makePort() {
|
|
126
144
|
return {
|
|
@@ -181,6 +199,70 @@ function makeEdgeInfo(tailPort, headPort) {
|
|
|
181
199
|
};
|
|
182
200
|
}
|
|
183
201
|
|
|
202
|
+
// src/model/edge.ts
|
|
203
|
+
var Edge = class _Edge {
|
|
204
|
+
// Code review: process-wide static seq counter, never reset between renders
|
|
205
|
+
// (C's AGSEQ lives in a per-agopen Agclos_t). Safe today — every reader only
|
|
206
|
+
// compares .seq values within one graph's own edges for relative ordering —
|
|
207
|
+
// and it evades the module-globals fitness scan (a private static field, not
|
|
208
|
+
// a module-scope `let`). Revisit if any consumer serializes an absolute .seq
|
|
209
|
+
// or relies on the counter resetting per parse/createGraph.
|
|
210
|
+
/** @see lib/cgraph/cgraph.h:AGSEQ */
|
|
211
|
+
static _nextSeq = 0;
|
|
212
|
+
/**
|
|
213
|
+
* Monotone sequence number — equivalent to AGSEQ(e) in C.
|
|
214
|
+
* Used by edgeidcmpf for stable sort ordering.
|
|
215
|
+
*
|
|
216
|
+
* Mutable because C's new_virtual_edge overwrites a virtual edge's AGSEQ
|
|
217
|
+
* with AGSEQ(orig) after allocation; copyVirtualEdgeInfo mirrors that.
|
|
218
|
+
* @see lib/cgraph/cgraph.h:AGSEQ, lib/dotgen/fastgr.c:new_virtual_edge
|
|
219
|
+
*/
|
|
220
|
+
seq;
|
|
221
|
+
/**
|
|
222
|
+
* Per-graph creation-order index (1-based).
|
|
223
|
+
* Set by the parser after root.edges.push(). Used as the SVG edge id,
|
|
224
|
+
* matching C's AGSEQ-based edge id assignment.
|
|
225
|
+
*/
|
|
226
|
+
graphSeq = 0;
|
|
227
|
+
/**
|
|
228
|
+
* Source node (arrow origin).
|
|
229
|
+
* C: AGTAIL(e) = AGMKIN(e)->node = in.node
|
|
230
|
+
* @see lib/cgraph/cgraph.h:AGTAIL
|
|
231
|
+
*/
|
|
232
|
+
tail;
|
|
233
|
+
/**
|
|
234
|
+
* Destination node (arrow target).
|
|
235
|
+
* C: AGHEAD(e) = AGMKOUT(e)->node = out.node
|
|
236
|
+
* @see lib/cgraph/cgraph.h:AGHEAD
|
|
237
|
+
*/
|
|
238
|
+
head;
|
|
239
|
+
/**
|
|
240
|
+
* Edge key; empty string for anonymous edges.
|
|
241
|
+
* Corresponds to the `name` argument of agedge().
|
|
242
|
+
* @see lib/cgraph/cgraph.h:agedge
|
|
243
|
+
*/
|
|
244
|
+
name;
|
|
245
|
+
/**
|
|
246
|
+
* String attributes (agget/agset equivalents).
|
|
247
|
+
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
248
|
+
*/
|
|
249
|
+
attrs;
|
|
250
|
+
/**
|
|
251
|
+
* Layout-engine info; replaces ED_* macros via agbindrec (AD-1).
|
|
252
|
+
* @see lib/cgraph/cgraph.h:agbindrec
|
|
253
|
+
*/
|
|
254
|
+
info;
|
|
255
|
+
/** @see lib/cgraph/edge.c:agedge */
|
|
256
|
+
constructor(tail, head, name, lazyAttrs = false) {
|
|
257
|
+
this.seq = _Edge._nextSeq++;
|
|
258
|
+
this.tail = tail;
|
|
259
|
+
this.head = head;
|
|
260
|
+
this.name = name;
|
|
261
|
+
this.attrs = lazyAttrs ? EMPTY_ATTRS : /* @__PURE__ */ new Map();
|
|
262
|
+
this.info = makeEdgeInfo(makePort(), makePort());
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
184
266
|
// src/model/layoutParams.ts
|
|
185
267
|
var FontnameKind = {
|
|
186
268
|
NativeFonts: 0,
|
|
@@ -220,6 +302,146 @@ function makeGraphInfo() {
|
|
|
220
302
|
};
|
|
221
303
|
}
|
|
222
304
|
|
|
305
|
+
// src/model/graph.ts
|
|
306
|
+
var Graph = class {
|
|
307
|
+
/** Graph name; agnameof equivalent. @see lib/cgraph/cgraph.h:agnameof */
|
|
308
|
+
name;
|
|
309
|
+
/**
|
|
310
|
+
* True when the graph was declared with NO name (`digraph {`), as opposed to
|
|
311
|
+
* an explicit empty name (`digraph "" {`). Both store `name === ''`, but
|
|
312
|
+
* cgraph gives the truly-anonymous root the internal id `%1` (agnameof) while
|
|
313
|
+
* the empty-named one keeps `""`. Only the imagemap `<map id/name>` reads this
|
|
314
|
+
* (map.ts:mapGraphName); dot/xdot re-serialization keeps `name` so an
|
|
315
|
+
* anonymous root round-trips as `digraph {`, not `digraph %1 {`.
|
|
316
|
+
* @see lib/cgraph/id.c:idmap (anon → `%1`) ; lib/cgraph/agraph.c:agnameof
|
|
317
|
+
*/
|
|
318
|
+
anonymous;
|
|
319
|
+
/**
|
|
320
|
+
* Directed/strict classification; mirrors Agdesc_t.directed and
|
|
321
|
+
* Agdesc_t.strict. @see lib/cgraph/cgraph.h:Agdesc_s
|
|
322
|
+
*/
|
|
323
|
+
kind;
|
|
324
|
+
/**
|
|
325
|
+
* Node set in insertion order, keyed by name.
|
|
326
|
+
* Mirrors Agraph_t.n_seq (sequence dict) merged with n_id access.
|
|
327
|
+
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
328
|
+
*/
|
|
329
|
+
nodes;
|
|
330
|
+
/**
|
|
331
|
+
* All edges owned by this graph (root graph only for ownership; subgraphs
|
|
332
|
+
* reference a subset). Mirrors Agraph_t.e_seq.
|
|
333
|
+
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
334
|
+
*/
|
|
335
|
+
edges;
|
|
336
|
+
/**
|
|
337
|
+
* Named subgraphs, keyed by name. Mirrors Agraph_t.g_seq/g_id.
|
|
338
|
+
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
339
|
+
*/
|
|
340
|
+
subgraphs;
|
|
341
|
+
/**
|
|
342
|
+
* String attributes (agget/agset equivalents).
|
|
343
|
+
* Replaces the Agattr_t / Agsym_t machinery for simple key-value access.
|
|
344
|
+
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
345
|
+
*/
|
|
346
|
+
attrs;
|
|
347
|
+
/** Default attributes applied to all nodes in this graph scope. */
|
|
348
|
+
nodeDefaults;
|
|
349
|
+
/** Default attributes applied to all edges in this graph scope. */
|
|
350
|
+
edgeDefaults;
|
|
351
|
+
/**
|
|
352
|
+
* Snapshot of the enclosing graphs' graph-attribute defaults (this graph ->
|
|
353
|
+
* root, inner wins) captured when this subgraph was OPENED during parsing.
|
|
354
|
+
* Graph attributes set on an ancestor AFTER this subgraph was created are not
|
|
355
|
+
* included — mirroring cgraph's parse-time agsubg defval copy. Used for
|
|
356
|
+
* order-correct label/font inheritance (e.g. a root `label=` declared after a
|
|
357
|
+
* cluster must NOT apply to that cluster). Undefined on the root graph.
|
|
358
|
+
* @see lib/cgraph/graph.c:agsubg (attr defval copy)
|
|
359
|
+
*/
|
|
360
|
+
graphDefaultsSnapshot;
|
|
361
|
+
/**
|
|
362
|
+
* Keys in `attrs` the BUILDER seeded from `graphDefaultsSnapshot` rather than
|
|
363
|
+
* the input declaring them in this scope (see builder.ts GRAPH_LABEL_INHERIT_
|
|
364
|
+
* KEYS). cgraph distinguishes these structurally — a seeded value is inherited
|
|
365
|
+
* through the dict view and has no local symbol, while a local declaration
|
|
366
|
+
* creates one even when its value equals the inherited value — so the
|
|
367
|
+
* serializer needs the provenance to decide what write_dict would print.
|
|
368
|
+
* Undefined on the root graph and on any scope that seeded nothing.
|
|
369
|
+
* @see lib/cgraph/write.c:262 write_dict
|
|
370
|
+
*/
|
|
371
|
+
seededAttrs;
|
|
372
|
+
/**
|
|
373
|
+
* Graph-attribute keys whose declaration in THIS scope was the first anywhere
|
|
374
|
+
* in the graph. cgraph's `setattr` splits on exactly this: a key with no
|
|
375
|
+
* existing symbol takes the global-declaration branch, which ends up seeding
|
|
376
|
+
* every direct subgraph that already exists with a local empty value (see
|
|
377
|
+
* `eagerEmptyParts`); a key some earlier scope already declared takes the
|
|
378
|
+
* "new local definition" branch and touches no subgraph at all. So an
|
|
379
|
+
* identical `graph [fill=x]` statement makes a child print `fill=""` or print
|
|
380
|
+
* nothing purely according to whether a SIBLING declared `fill` first.
|
|
381
|
+
* Undefined on any scope that declared nothing new.
|
|
382
|
+
* @see lib/cgraph/attr.c:257 setattr (lsym / psym / global branches)
|
|
383
|
+
*/
|
|
384
|
+
firstGraphDecl;
|
|
385
|
+
/**
|
|
386
|
+
* Layout-engine info; replaces GD_* macros via agbindrec (AD-1).
|
|
387
|
+
* @see lib/cgraph/cgraph.h:agbindrec
|
|
388
|
+
*/
|
|
389
|
+
info;
|
|
390
|
+
/**
|
|
391
|
+
* Immediate parent graph. null for root graphs.
|
|
392
|
+
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
393
|
+
*/
|
|
394
|
+
parent;
|
|
395
|
+
/**
|
|
396
|
+
* Root (main) graph. Self-referential for root graphs;
|
|
397
|
+
* points up for subgraphs.
|
|
398
|
+
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
399
|
+
*/
|
|
400
|
+
root;
|
|
401
|
+
/**
|
|
402
|
+
* Subgraph sequence number (AGSEQ). A global counter on the root, assigned
|
|
403
|
+
* at creation in source order, counting anonymous subgraphs. The root keeps
|
|
404
|
+
* the default 0 (par == NULL never calls agnextseq). Consumed by getObjId to
|
|
405
|
+
* emit cluster ids `clust<seq>`.
|
|
406
|
+
* @see lib/cgraph/cgraph.h:AGSEQ
|
|
407
|
+
* @see lib/cgraph/graph.c:agopen (AGSEQ(g) = agnextseq(par, AGRAPH))
|
|
408
|
+
*/
|
|
409
|
+
seq = 0;
|
|
410
|
+
/**
|
|
411
|
+
* Root-only counter mirroring `clos->seq[AGRAPH]`: the running maximum AGSEQ
|
|
412
|
+
* handed out to subgraphs. Meaningful only on the root graph; `assignSubgSeq`
|
|
413
|
+
* pre-increments it. Other graphs leave it at 0.
|
|
414
|
+
* @see lib/cgraph/graph.c:agnextseq (++clos->seq[AGRAPH])
|
|
415
|
+
*/
|
|
416
|
+
subgSeqCounter = 0;
|
|
417
|
+
/**
|
|
418
|
+
* Names of graph attributes (AGRAPH) declared anywhere in this hierarchy —
|
|
419
|
+
* the port's stand-in for cgraph's `Agsym_t` symbol table. Populated on the
|
|
420
|
+
* ROOT only, at parse time, whenever a graph attribute is assigned on any
|
|
421
|
+
* (sub)graph: setting `ordering=out` on a subgraph declares "ordering"
|
|
422
|
+
* graph-wide with an empty default, so `agGraphAttr(root, "ordering")` returns
|
|
423
|
+
* `""` (not undefined) — mirroring `agfindgraphattr`/`late_string`. Read via
|
|
424
|
+
* `agGraphAttr` (model/cgraph-ops.ts); empty on non-root graphs.
|
|
425
|
+
* @see lib/cgraph/attr.c:agattr (graph-wide declaration, "" default)
|
|
426
|
+
*/
|
|
427
|
+
declaredGraphAttrs = /* @__PURE__ */ new Set();
|
|
428
|
+
/** @see lib/cgraph/graph.c:agopen */
|
|
429
|
+
constructor(name, kind, anonymous = false) {
|
|
430
|
+
this.name = name;
|
|
431
|
+
this.anonymous = anonymous;
|
|
432
|
+
this.kind = kind;
|
|
433
|
+
this.nodes = /* @__PURE__ */ new Map();
|
|
434
|
+
this.edges = [];
|
|
435
|
+
this.subgraphs = /* @__PURE__ */ new Map();
|
|
436
|
+
this.attrs = /* @__PURE__ */ new Map();
|
|
437
|
+
this.nodeDefaults = /* @__PURE__ */ new Map();
|
|
438
|
+
this.edgeDefaults = /* @__PURE__ */ new Map();
|
|
439
|
+
this.info = makeGraphInfo();
|
|
440
|
+
this.parent = null;
|
|
441
|
+
this.root = this;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
223
445
|
// src/model/algData.ts
|
|
224
446
|
var THETA_UNSET = 10;
|
|
225
447
|
|
|
@@ -287,12 +509,348 @@ function makeNodeInfo() {
|
|
|
287
509
|
};
|
|
288
510
|
}
|
|
289
511
|
|
|
512
|
+
// src/model/node.ts
|
|
513
|
+
var Node = class {
|
|
514
|
+
/**
|
|
515
|
+
* Unique integer ID per root graph; maps to AGID in the C implementation.
|
|
516
|
+
* @see lib/cgraph/cgraph.h:AGID
|
|
517
|
+
*/
|
|
518
|
+
id;
|
|
519
|
+
/** Node name; agnameof equivalent. @see lib/cgraph/cgraph.h:agnameof */
|
|
520
|
+
name;
|
|
521
|
+
/**
|
|
522
|
+
* String attributes (agget/agset equivalents).
|
|
523
|
+
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
524
|
+
*/
|
|
525
|
+
attrs;
|
|
526
|
+
/**
|
|
527
|
+
* Layout-engine info; replaces ND_* macros via agbindrec (AD-1).
|
|
528
|
+
* @see lib/cgraph/cgraph.h:agbindrec
|
|
529
|
+
*/
|
|
530
|
+
info;
|
|
531
|
+
/**
|
|
532
|
+
* Root graph that owns this node.
|
|
533
|
+
* @see lib/cgraph/cgraph.h:Agnode_s
|
|
534
|
+
*/
|
|
535
|
+
root;
|
|
536
|
+
/**
|
|
537
|
+
* Frozen snapshot of the node-attribute defaults (`node [...]`) in effect —
|
|
538
|
+
* from the declaring subgraph up through its ancestors — at the moment this
|
|
539
|
+
* node was first created. Captured at creation (not read live at render) so
|
|
540
|
+
* that a `node [...]` declared *after* this node in the same or an ancestor
|
|
541
|
+
* scope does not retroactively apply, matching DOT semantics. Present on
|
|
542
|
+
* parser-built nodes (even when empty); undefined on programmatically created
|
|
543
|
+
* nodes, which fall back to live graph defaults in `nodeAttr`.
|
|
544
|
+
*/
|
|
545
|
+
nodeDefaultsSnapshot;
|
|
546
|
+
/** @see lib/cgraph/node.c:agnode */
|
|
547
|
+
constructor(id, name, root, lazyAttrs = false) {
|
|
548
|
+
this.id = id;
|
|
549
|
+
this.name = name;
|
|
550
|
+
this.attrs = lazyAttrs ? EMPTY_ATTRS : /* @__PURE__ */ new Map();
|
|
551
|
+
this.info = makeNodeInfo();
|
|
552
|
+
this.root = root;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Returns out-edges of this node in graph g (where this node is the tail).
|
|
556
|
+
*
|
|
557
|
+
* ORDER: cgraph's per-node out-edge dict sorts by the SEQ of the edge's
|
|
558
|
+
* out-half node — the HEAD — then by edge seq (edge.c:agedgeseqcmpf,
|
|
559
|
+
* Ag_mainedge_seq_disc). Iteration is therefore by (head creation order,
|
|
560
|
+
* edge creation order), NOT by plain edge insertion order. This ordering
|
|
561
|
+
* is load-bearing for emission order and for force-accumulation order in
|
|
562
|
+
* the iterative engines.
|
|
563
|
+
*
|
|
564
|
+
* INVARIANT: In the C cgraph library, the adjacency list for a node begins
|
|
565
|
+
* with the node's own self-loop (index 0), and neighbor traversal MUST start
|
|
566
|
+
* at index 1. This convention originates from lib/cgraph/edge.c and
|
|
567
|
+
* agfstedge/agnxtedge. In this TypeScript implementation, self-loops are
|
|
568
|
+
* included in outEdges() but are excluded from inEdges() — matching the
|
|
569
|
+
* agnxtedge behavior that skips self-loops as in-edges. Callers iterating
|
|
570
|
+
* over neighbors must account for self-loop edges appearing in outEdges().
|
|
571
|
+
*
|
|
572
|
+
* @see lib/cgraph/edge.c:agfstout
|
|
573
|
+
* @see lib/cgraph/edge.c:agnxtout
|
|
574
|
+
* @see lib/cgraph/edge.c:agedgeseqcmpf
|
|
575
|
+
*/
|
|
576
|
+
outEdges(g) {
|
|
577
|
+
return g.edges.filter((e) => e.tail === this).sort((a, b) => a.head.id - b.head.id || a.seq - b.seq);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Returns in-edges of this node in graph g (where this node is the head).
|
|
581
|
+
* Self-loops are excluded per C agnxtedge semantics. Ordered by the SEQ
|
|
582
|
+
* of the in-half node — the TAIL — then edge seq (agedgeseqcmpf).
|
|
583
|
+
*
|
|
584
|
+
* @see lib/cgraph/edge.c:agfstin
|
|
585
|
+
* @see lib/cgraph/edge.c:agnxtin
|
|
586
|
+
* @see lib/cgraph/edge.c:agnxtedge (skips self-loops as in-edges)
|
|
587
|
+
* @see lib/cgraph/edge.c:agedgeseqcmpf
|
|
588
|
+
*/
|
|
589
|
+
inEdges(g) {
|
|
590
|
+
return g.edges.filter((e) => e.head === this && e.tail !== this).sort((a, b) => a.tail.id - b.tail.id || a.seq - b.seq);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
function buildOutEdgeIndex(g) {
|
|
594
|
+
const m = /* @__PURE__ */ new Map();
|
|
595
|
+
for (const e of g.edges) {
|
|
596
|
+
const l = m.get(e.tail);
|
|
597
|
+
if (l !== void 0) l.push(e);
|
|
598
|
+
else m.set(e.tail, [e]);
|
|
599
|
+
}
|
|
600
|
+
for (const l of m.values()) {
|
|
601
|
+
l.sort((a, b) => a.head.id - b.head.id || a.seq - b.seq);
|
|
602
|
+
}
|
|
603
|
+
return m;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// src/model/cgraph-ops.ts
|
|
607
|
+
var LOCALNAMEPREFIX = "%";
|
|
608
|
+
var ANONYMOUS_ROOT_ID = 1;
|
|
609
|
+
function agNameOf(g) {
|
|
610
|
+
return g.anonymous ? `${LOCALNAMEPREFIX}${ANONYMOUS_ROOT_ID}` : g.name;
|
|
611
|
+
}
|
|
612
|
+
function freshNodeId(root) {
|
|
613
|
+
let max = -1;
|
|
614
|
+
for (const n of root.nodes.values()) {
|
|
615
|
+
if (n.id > max) max = n.id;
|
|
616
|
+
}
|
|
617
|
+
return max + 1;
|
|
618
|
+
}
|
|
619
|
+
function agnode(g, name, create) {
|
|
620
|
+
const root = g.root;
|
|
621
|
+
if (name !== null && name !== "") {
|
|
622
|
+
const existing = root.nodes.get(name);
|
|
623
|
+
if (existing !== void 0) return existing;
|
|
624
|
+
if (!create) return null;
|
|
625
|
+
const node2 = new Node(freshNodeId(root), name, root);
|
|
626
|
+
root.nodes.set(name, node2);
|
|
627
|
+
return node2;
|
|
628
|
+
}
|
|
629
|
+
if (!create) return null;
|
|
630
|
+
const id = freshNodeId(root);
|
|
631
|
+
const anonName = LOCALNAMEPREFIX + String(id);
|
|
632
|
+
const node = new Node(id, anonName, root);
|
|
633
|
+
root.nodes.set(anonName, node);
|
|
634
|
+
return node;
|
|
635
|
+
}
|
|
636
|
+
function assignSubgSeq(parent2, sg) {
|
|
637
|
+
sg.seq = ++parent2.root.subgSeqCounter;
|
|
638
|
+
}
|
|
639
|
+
function agsubg(parent2, name, create) {
|
|
640
|
+
const existing = parent2.subgraphs.get(name);
|
|
641
|
+
if (existing !== void 0) return existing;
|
|
642
|
+
if (!create) return null;
|
|
643
|
+
const subg = new Graph(name, parent2.kind);
|
|
644
|
+
subg.parent = parent2;
|
|
645
|
+
subg.root = parent2.root;
|
|
646
|
+
assignSubgSeq(parent2, subg);
|
|
647
|
+
parent2.subgraphs.set(name, subg);
|
|
648
|
+
return subg;
|
|
649
|
+
}
|
|
650
|
+
function agsubnode(g, n, create) {
|
|
651
|
+
if (g.root !== n.root) return null;
|
|
652
|
+
const existing = g.nodes.get(n.name);
|
|
653
|
+
if (existing !== void 0) return existing;
|
|
654
|
+
if (!create) return null;
|
|
655
|
+
const par = g.parent;
|
|
656
|
+
if (par !== null) {
|
|
657
|
+
agsubnode(par, n, create);
|
|
658
|
+
}
|
|
659
|
+
g.nodes.set(n.name, n);
|
|
660
|
+
return n;
|
|
661
|
+
}
|
|
662
|
+
function agdelnode(g, n) {
|
|
663
|
+
for (let cur = g; cur !== null; cur = cur.parent) {
|
|
664
|
+
cur.nodes.delete(n.name);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
function agdelsubg(parent2, sg) {
|
|
668
|
+
parent2.subgraphs.delete(sg.name);
|
|
669
|
+
}
|
|
670
|
+
function agGraphAttr(g, name) {
|
|
671
|
+
const own = g.attrs.get(name);
|
|
672
|
+
if (own !== void 0) return own;
|
|
673
|
+
return g.root.declaredGraphAttrs.has(name) ? "" : void 0;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// src/layout/fdp/cluster-edges.ts
|
|
677
|
+
function fillMap(g, map) {
|
|
678
|
+
const n = g.info.n_cluster ?? 0;
|
|
679
|
+
for (let c = 0; c < n; c++) {
|
|
680
|
+
const cl = g.info.clust[c];
|
|
681
|
+
const s = cl.name;
|
|
682
|
+
if (!map.has(s)) map.set(s, cl);
|
|
683
|
+
fillMap(cl, map);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function mkClustMap(g) {
|
|
687
|
+
const map = /* @__PURE__ */ new Map();
|
|
688
|
+
fillMap(g, map);
|
|
689
|
+
return map;
|
|
690
|
+
}
|
|
691
|
+
function mapc(cmap, n) {
|
|
692
|
+
if (n.name.startsWith("cluster")) return cmap.get(n.name) ?? null;
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
function edgeKey(t, h) {
|
|
696
|
+
return `${t.name}\0${h.name}`;
|
|
697
|
+
}
|
|
698
|
+
function mapEdge(map, t, h) {
|
|
699
|
+
return map.get(edgeKey(t, h));
|
|
700
|
+
}
|
|
701
|
+
function insertEdge(map, t, h, ce) {
|
|
702
|
+
map.set(edgeKey(t, h), { t: ce.tail, h: ce.head });
|
|
703
|
+
map.set(edgeKey(h, t), { t: ce.head, h: ce.tail });
|
|
704
|
+
}
|
|
705
|
+
function clustNode(n, cg, root, delSet, idx) {
|
|
706
|
+
const name = `__${idx.v}:${cg.name}`;
|
|
707
|
+
const cn = agnode(root, name, true);
|
|
708
|
+
cn.info.clustnode = true;
|
|
709
|
+
agsubnode(cg, cn, true);
|
|
710
|
+
delSet.add(n);
|
|
711
|
+
cn.attrs.set("label", "");
|
|
712
|
+
cn.attrs.set("style", "invis");
|
|
713
|
+
cn.attrs.set("shape", "box");
|
|
714
|
+
return cn;
|
|
715
|
+
}
|
|
716
|
+
function nextEdgeSeq(root) {
|
|
717
|
+
let max = 0;
|
|
718
|
+
for (const e of root.edges) max = Math.max(max, e.graphSeq);
|
|
719
|
+
return max + 1;
|
|
720
|
+
}
|
|
721
|
+
function cloneEdge(root, e, ct, ch) {
|
|
722
|
+
const ce = new Edge(ct, ch, "");
|
|
723
|
+
for (const [k, v] of e.attrs) ce.attrs.set(k, v);
|
|
724
|
+
ce.info.compound = 1;
|
|
725
|
+
ce.graphSeq = nextEdgeSeq(root);
|
|
726
|
+
root.edges.push(ce);
|
|
727
|
+
return ce;
|
|
728
|
+
}
|
|
729
|
+
function checkCompound(e, root, cmap, map, delSet, idx) {
|
|
730
|
+
const t = e.tail;
|
|
731
|
+
const h = e.head;
|
|
732
|
+
if (h.info.clustnode) return 0;
|
|
733
|
+
const tg = mapc(cmap, t);
|
|
734
|
+
const hg = mapc(cmap, h);
|
|
735
|
+
if (!tg && !hg) return 0;
|
|
736
|
+
if (tg === hg) return 0;
|
|
737
|
+
const ip = mapEdge(map, t, h);
|
|
738
|
+
if (ip) {
|
|
739
|
+
cloneEdge(root, e, ip.t, ip.h);
|
|
740
|
+
return 1;
|
|
741
|
+
}
|
|
742
|
+
let cn;
|
|
743
|
+
let ce;
|
|
744
|
+
if (hg) {
|
|
745
|
+
if (tg) {
|
|
746
|
+
if (agContains(hg, tg) || agContains(tg, hg)) return 0;
|
|
747
|
+
cn = clustNode(t, tg, root, delSet, idx);
|
|
748
|
+
const cn1 = clustNode(h, hg, root, delSet, idx);
|
|
749
|
+
ce = cloneEdge(root, e, cn, cn1);
|
|
750
|
+
insertEdge(map, t, h, ce);
|
|
751
|
+
} else {
|
|
752
|
+
if (agContainsNode(hg, t)) return 0;
|
|
753
|
+
cn = clustNode(h, hg, root, delSet, idx);
|
|
754
|
+
ce = cloneEdge(root, e, t, cn);
|
|
755
|
+
insertEdge(map, t, h, ce);
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
if (agContainsNode(tg, h)) return 0;
|
|
759
|
+
cn = clustNode(t, tg, root, delSet, idx);
|
|
760
|
+
ce = cloneEdge(root, e, cn, h);
|
|
761
|
+
insertEdge(map, t, h, ce);
|
|
762
|
+
}
|
|
763
|
+
return 1;
|
|
764
|
+
}
|
|
765
|
+
function agContains(a, b) {
|
|
766
|
+
for (let g = b; g !== null; g = g.parent) {
|
|
767
|
+
if (g === a) return true;
|
|
768
|
+
}
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
function agContainsNode(cg, n) {
|
|
772
|
+
return cg.nodes.has(n.name);
|
|
773
|
+
}
|
|
774
|
+
function deleteNodeAndEdges(root, n) {
|
|
775
|
+
const purge = (gr) => {
|
|
776
|
+
if (gr.edges.length > 0) {
|
|
777
|
+
gr.edges = gr.edges.filter((e) => e.tail !== n && e.head !== n);
|
|
778
|
+
}
|
|
779
|
+
gr.nodes.delete(n.name);
|
|
780
|
+
for (const sg of gr.subgraphs.values()) purge(sg);
|
|
781
|
+
};
|
|
782
|
+
purge(root);
|
|
783
|
+
}
|
|
784
|
+
function processClusterEdges(g) {
|
|
785
|
+
const root = g.root;
|
|
786
|
+
const cmap = mkClustMap(g);
|
|
787
|
+
if (cmap.size === 0) return;
|
|
788
|
+
const map = /* @__PURE__ */ new Map();
|
|
789
|
+
const delSet = /* @__PURE__ */ new Set();
|
|
790
|
+
const idx = { v: 0 };
|
|
791
|
+
let numClEdges = 0;
|
|
792
|
+
for (const n of [...g.nodes.values()]) {
|
|
793
|
+
if (n.info.clustnode) continue;
|
|
794
|
+
for (const e of n.outEdges(g)) {
|
|
795
|
+
numClEdges += checkCompound(e, root, cmap, map, delSet, idx);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
for (const n of delSet) deleteNodeAndEdges(root, n);
|
|
799
|
+
if (numClEdges > 0) g.info.n_cluster_edges = numClEdges;
|
|
800
|
+
}
|
|
801
|
+
function mapN(n, delSet) {
|
|
802
|
+
if (!n.info.clustnode) return n;
|
|
803
|
+
delSet.add(n);
|
|
804
|
+
const name = n.name.slice(n.name.indexOf(":") + 1);
|
|
805
|
+
const existing = agnode(n.root, name, false);
|
|
806
|
+
if (existing !== null) return existing;
|
|
807
|
+
const nn = agnode(n.root, name, true);
|
|
808
|
+
nn.info.clustnode = true;
|
|
809
|
+
return nn;
|
|
810
|
+
}
|
|
811
|
+
function undoCompound(root, e, delSet) {
|
|
812
|
+
const ntail = mapN(e.tail, delSet);
|
|
813
|
+
const nhead = mapN(e.head, delSet);
|
|
814
|
+
const ce = cloneEdge(root, e, ntail, nhead);
|
|
815
|
+
ce.info.spl = e.info.spl;
|
|
816
|
+
e.info.spl = void 0;
|
|
817
|
+
ce.info.label = e.info.label;
|
|
818
|
+
e.info.label = void 0;
|
|
819
|
+
ce.info.xlabel = e.info.xlabel;
|
|
820
|
+
e.info.xlabel = void 0;
|
|
821
|
+
ce.info.head_label = e.info.head_label;
|
|
822
|
+
e.info.head_label = void 0;
|
|
823
|
+
ce.info.tail_label = e.info.tail_label;
|
|
824
|
+
e.info.tail_label = void 0;
|
|
825
|
+
}
|
|
826
|
+
function undoClusterEdges(g) {
|
|
827
|
+
if (!g.info.n_cluster_edges) return;
|
|
828
|
+
const root = g.root;
|
|
829
|
+
const delSet = /* @__PURE__ */ new Set();
|
|
830
|
+
const edgelist = [];
|
|
831
|
+
for (const n of g.nodes.values()) {
|
|
832
|
+
for (const e of n.outEdges(g)) {
|
|
833
|
+
if (e.info.compound && isProxyEdge(e)) edgelist.push(e);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
for (const e of edgelist) undoCompound(root, e, delSet);
|
|
837
|
+
for (const n of delSet) deleteNodeAndEdges(root, n);
|
|
838
|
+
}
|
|
839
|
+
function isProxyEdge(e) {
|
|
840
|
+
return e.tail.info.clustnode && e.tail.name.includes(":") || e.head.info.clustnode && e.head.name.includes(":");
|
|
841
|
+
}
|
|
842
|
+
|
|
290
843
|
// src/gvc/layout-reset.ts
|
|
291
844
|
function layoutWasFreed(g) {
|
|
292
845
|
return g.info?.laidOut === true && g.info.cleanup === void 0;
|
|
293
846
|
}
|
|
847
|
+
function undoRenderedClusterEdges(g) {
|
|
848
|
+
if (g.info?.n_cluster_edges && g.attrs.get("bb")?.includes(",")) undoClusterEdges(g);
|
|
849
|
+
}
|
|
294
850
|
function resetGraphRecords(g) {
|
|
851
|
+
const clusterEdges = g.info.n_cluster_edges;
|
|
295
852
|
g.info = makeGraphInfo();
|
|
853
|
+
if (clusterEdges !== void 0) g.info.n_cluster_edges = clusterEdges;
|
|
296
854
|
for (const subg of g.subgraphs.values()) resetGraphRecords(subg);
|
|
297
855
|
}
|
|
298
856
|
function resetLayoutRecords(g) {
|
|
@@ -300,6 +858,21 @@ function resetLayoutRecords(g) {
|
|
|
300
858
|
for (const e of g.edges) e.info = makeEdgeInfo(makePort(), makePort());
|
|
301
859
|
resetGraphRecords(g);
|
|
302
860
|
}
|
|
861
|
+
function resetFreedLayouts(g) {
|
|
862
|
+
const visit = (h) => {
|
|
863
|
+
if (layoutWasFreed(h)) resetLayoutRecords(h);
|
|
864
|
+
else for (const subg of h.subgraphs.values()) visit(subg);
|
|
865
|
+
};
|
|
866
|
+
visit(g.root);
|
|
867
|
+
}
|
|
868
|
+
function bindDotRoot(g) {
|
|
869
|
+
const droot = g === g.root ? void 0 : g;
|
|
870
|
+
const visit = (h) => {
|
|
871
|
+
h.info.dotroot = droot;
|
|
872
|
+
for (const subg of h.subgraphs.values()) visit(subg);
|
|
873
|
+
};
|
|
874
|
+
visit(g);
|
|
875
|
+
}
|
|
303
876
|
|
|
304
877
|
// src/common/agerr.ts
|
|
305
878
|
var PREFIX_ERROR = "Error";
|
|
@@ -1039,7 +1612,12 @@ var GvcContext = class {
|
|
|
1039
1612
|
}
|
|
1040
1613
|
engine = override2;
|
|
1041
1614
|
}
|
|
1042
|
-
|
|
1615
|
+
undoRenderedClusterEdges(g);
|
|
1616
|
+
if (g.root) {
|
|
1617
|
+
resetFreedLayouts(g);
|
|
1618
|
+
bindDotRoot(g);
|
|
1619
|
+
g.root.info.gvc = this;
|
|
1620
|
+
}
|
|
1043
1621
|
if (g.info) g.info.gvc = this;
|
|
1044
1622
|
initXdot(g);
|
|
1045
1623
|
engine.layout(g);
|
|
@@ -9116,182 +9694,6 @@ function htmlTextLabel(text, finfo, placed, dim) {
|
|
|
9116
9694
|
};
|
|
9117
9695
|
}
|
|
9118
9696
|
|
|
9119
|
-
// src/model/lazy-attrs.ts
|
|
9120
|
-
var SharedEmptyAttrs = class extends Map {
|
|
9121
|
-
set(key, _value) {
|
|
9122
|
-
throw new Error(`attrs.set("${key}") on a shared empty map; use ownAttrs()`);
|
|
9123
|
-
}
|
|
9124
|
-
delete(key) {
|
|
9125
|
-
throw new Error(`attrs.delete("${key}") on a shared empty map; use ownAttrs()`);
|
|
9126
|
-
}
|
|
9127
|
-
clear() {
|
|
9128
|
-
throw new Error("attrs.clear() on a shared empty map; use ownAttrs()");
|
|
9129
|
-
}
|
|
9130
|
-
};
|
|
9131
|
-
var EMPTY_ATTRS = new SharedEmptyAttrs();
|
|
9132
|
-
function ownAttrs(o) {
|
|
9133
|
-
if (o.attrs === EMPTY_ATTRS) o.attrs = /* @__PURE__ */ new Map();
|
|
9134
|
-
return o.attrs;
|
|
9135
|
-
}
|
|
9136
|
-
|
|
9137
|
-
// src/model/node.ts
|
|
9138
|
-
var Node = class {
|
|
9139
|
-
/**
|
|
9140
|
-
* Unique integer ID per root graph; maps to AGID in the C implementation.
|
|
9141
|
-
* @see lib/cgraph/cgraph.h:AGID
|
|
9142
|
-
*/
|
|
9143
|
-
id;
|
|
9144
|
-
/** Node name; agnameof equivalent. @see lib/cgraph/cgraph.h:agnameof */
|
|
9145
|
-
name;
|
|
9146
|
-
/**
|
|
9147
|
-
* String attributes (agget/agset equivalents).
|
|
9148
|
-
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
9149
|
-
*/
|
|
9150
|
-
attrs;
|
|
9151
|
-
/**
|
|
9152
|
-
* Layout-engine info; replaces ND_* macros via agbindrec (AD-1).
|
|
9153
|
-
* @see lib/cgraph/cgraph.h:agbindrec
|
|
9154
|
-
*/
|
|
9155
|
-
info;
|
|
9156
|
-
/**
|
|
9157
|
-
* Root graph that owns this node.
|
|
9158
|
-
* @see lib/cgraph/cgraph.h:Agnode_s
|
|
9159
|
-
*/
|
|
9160
|
-
root;
|
|
9161
|
-
/**
|
|
9162
|
-
* Frozen snapshot of the node-attribute defaults (`node [...]`) in effect —
|
|
9163
|
-
* from the declaring subgraph up through its ancestors — at the moment this
|
|
9164
|
-
* node was first created. Captured at creation (not read live at render) so
|
|
9165
|
-
* that a `node [...]` declared *after* this node in the same or an ancestor
|
|
9166
|
-
* scope does not retroactively apply, matching DOT semantics. Present on
|
|
9167
|
-
* parser-built nodes (even when empty); undefined on programmatically created
|
|
9168
|
-
* nodes, which fall back to live graph defaults in `nodeAttr`.
|
|
9169
|
-
*/
|
|
9170
|
-
nodeDefaultsSnapshot;
|
|
9171
|
-
/** @see lib/cgraph/node.c:agnode */
|
|
9172
|
-
constructor(id, name, root, lazyAttrs = false) {
|
|
9173
|
-
this.id = id;
|
|
9174
|
-
this.name = name;
|
|
9175
|
-
this.attrs = lazyAttrs ? EMPTY_ATTRS : /* @__PURE__ */ new Map();
|
|
9176
|
-
this.info = makeNodeInfo();
|
|
9177
|
-
this.root = root;
|
|
9178
|
-
}
|
|
9179
|
-
/**
|
|
9180
|
-
* Returns out-edges of this node in graph g (where this node is the tail).
|
|
9181
|
-
*
|
|
9182
|
-
* ORDER: cgraph's per-node out-edge dict sorts by the SEQ of the edge's
|
|
9183
|
-
* out-half node — the HEAD — then by edge seq (edge.c:agedgeseqcmpf,
|
|
9184
|
-
* Ag_mainedge_seq_disc). Iteration is therefore by (head creation order,
|
|
9185
|
-
* edge creation order), NOT by plain edge insertion order. This ordering
|
|
9186
|
-
* is load-bearing for emission order and for force-accumulation order in
|
|
9187
|
-
* the iterative engines.
|
|
9188
|
-
*
|
|
9189
|
-
* INVARIANT: In the C cgraph library, the adjacency list for a node begins
|
|
9190
|
-
* with the node's own self-loop (index 0), and neighbor traversal MUST start
|
|
9191
|
-
* at index 1. This convention originates from lib/cgraph/edge.c and
|
|
9192
|
-
* agfstedge/agnxtedge. In this TypeScript implementation, self-loops are
|
|
9193
|
-
* included in outEdges() but are excluded from inEdges() — matching the
|
|
9194
|
-
* agnxtedge behavior that skips self-loops as in-edges. Callers iterating
|
|
9195
|
-
* over neighbors must account for self-loop edges appearing in outEdges().
|
|
9196
|
-
*
|
|
9197
|
-
* @see lib/cgraph/edge.c:agfstout
|
|
9198
|
-
* @see lib/cgraph/edge.c:agnxtout
|
|
9199
|
-
* @see lib/cgraph/edge.c:agedgeseqcmpf
|
|
9200
|
-
*/
|
|
9201
|
-
outEdges(g) {
|
|
9202
|
-
return g.edges.filter((e) => e.tail === this).sort((a, b) => a.head.id - b.head.id || a.seq - b.seq);
|
|
9203
|
-
}
|
|
9204
|
-
/**
|
|
9205
|
-
* Returns in-edges of this node in graph g (where this node is the head).
|
|
9206
|
-
* Self-loops are excluded per C agnxtedge semantics. Ordered by the SEQ
|
|
9207
|
-
* of the in-half node — the TAIL — then edge seq (agedgeseqcmpf).
|
|
9208
|
-
*
|
|
9209
|
-
* @see lib/cgraph/edge.c:agfstin
|
|
9210
|
-
* @see lib/cgraph/edge.c:agnxtin
|
|
9211
|
-
* @see lib/cgraph/edge.c:agnxtedge (skips self-loops as in-edges)
|
|
9212
|
-
* @see lib/cgraph/edge.c:agedgeseqcmpf
|
|
9213
|
-
*/
|
|
9214
|
-
inEdges(g) {
|
|
9215
|
-
return g.edges.filter((e) => e.head === this && e.tail !== this).sort((a, b) => a.tail.id - b.tail.id || a.seq - b.seq);
|
|
9216
|
-
}
|
|
9217
|
-
};
|
|
9218
|
-
function buildOutEdgeIndex(g) {
|
|
9219
|
-
const m = /* @__PURE__ */ new Map();
|
|
9220
|
-
for (const e of g.edges) {
|
|
9221
|
-
const l = m.get(e.tail);
|
|
9222
|
-
if (l !== void 0) l.push(e);
|
|
9223
|
-
else m.set(e.tail, [e]);
|
|
9224
|
-
}
|
|
9225
|
-
for (const l of m.values()) {
|
|
9226
|
-
l.sort((a, b) => a.head.id - b.head.id || a.seq - b.seq);
|
|
9227
|
-
}
|
|
9228
|
-
return m;
|
|
9229
|
-
}
|
|
9230
|
-
|
|
9231
|
-
// src/model/edge.ts
|
|
9232
|
-
var Edge = class _Edge {
|
|
9233
|
-
// Code review: process-wide static seq counter, never reset between renders
|
|
9234
|
-
// (C's AGSEQ lives in a per-agopen Agclos_t). Safe today — every reader only
|
|
9235
|
-
// compares .seq values within one graph's own edges for relative ordering —
|
|
9236
|
-
// and it evades the module-globals fitness scan (a private static field, not
|
|
9237
|
-
// a module-scope `let`). Revisit if any consumer serializes an absolute .seq
|
|
9238
|
-
// or relies on the counter resetting per parse/createGraph.
|
|
9239
|
-
/** @see lib/cgraph/cgraph.h:AGSEQ */
|
|
9240
|
-
static _nextSeq = 0;
|
|
9241
|
-
/**
|
|
9242
|
-
* Monotone sequence number — equivalent to AGSEQ(e) in C.
|
|
9243
|
-
* Used by edgeidcmpf for stable sort ordering.
|
|
9244
|
-
*
|
|
9245
|
-
* Mutable because C's new_virtual_edge overwrites a virtual edge's AGSEQ
|
|
9246
|
-
* with AGSEQ(orig) after allocation; copyVirtualEdgeInfo mirrors that.
|
|
9247
|
-
* @see lib/cgraph/cgraph.h:AGSEQ, lib/dotgen/fastgr.c:new_virtual_edge
|
|
9248
|
-
*/
|
|
9249
|
-
seq;
|
|
9250
|
-
/**
|
|
9251
|
-
* Per-graph creation-order index (1-based).
|
|
9252
|
-
* Set by the parser after root.edges.push(). Used as the SVG edge id,
|
|
9253
|
-
* matching C's AGSEQ-based edge id assignment.
|
|
9254
|
-
*/
|
|
9255
|
-
graphSeq = 0;
|
|
9256
|
-
/**
|
|
9257
|
-
* Source node (arrow origin).
|
|
9258
|
-
* C: AGTAIL(e) = AGMKIN(e)->node = in.node
|
|
9259
|
-
* @see lib/cgraph/cgraph.h:AGTAIL
|
|
9260
|
-
*/
|
|
9261
|
-
tail;
|
|
9262
|
-
/**
|
|
9263
|
-
* Destination node (arrow target).
|
|
9264
|
-
* C: AGHEAD(e) = AGMKOUT(e)->node = out.node
|
|
9265
|
-
* @see lib/cgraph/cgraph.h:AGHEAD
|
|
9266
|
-
*/
|
|
9267
|
-
head;
|
|
9268
|
-
/**
|
|
9269
|
-
* Edge key; empty string for anonymous edges.
|
|
9270
|
-
* Corresponds to the `name` argument of agedge().
|
|
9271
|
-
* @see lib/cgraph/cgraph.h:agedge
|
|
9272
|
-
*/
|
|
9273
|
-
name;
|
|
9274
|
-
/**
|
|
9275
|
-
* String attributes (agget/agset equivalents).
|
|
9276
|
-
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
9277
|
-
*/
|
|
9278
|
-
attrs;
|
|
9279
|
-
/**
|
|
9280
|
-
* Layout-engine info; replaces ED_* macros via agbindrec (AD-1).
|
|
9281
|
-
* @see lib/cgraph/cgraph.h:agbindrec
|
|
9282
|
-
*/
|
|
9283
|
-
info;
|
|
9284
|
-
/** @see lib/cgraph/edge.c:agedge */
|
|
9285
|
-
constructor(tail, head, name, lazyAttrs = false) {
|
|
9286
|
-
this.seq = _Edge._nextSeq++;
|
|
9287
|
-
this.tail = tail;
|
|
9288
|
-
this.head = head;
|
|
9289
|
-
this.name = name;
|
|
9290
|
-
this.attrs = lazyAttrs ? EMPTY_ATTRS : /* @__PURE__ */ new Map();
|
|
9291
|
-
this.info = makeEdgeInfo(makePort(), makePort());
|
|
9292
|
-
}
|
|
9293
|
-
};
|
|
9294
|
-
|
|
9295
9697
|
// src/common/subst.ts
|
|
9296
9698
|
function labelTextOf(info) {
|
|
9297
9699
|
const lp = info.label;
|
|
@@ -9380,146 +9782,6 @@ function preprocessTooltip(s) {
|
|
|
9380
9782
|
return interpretCRNL(htmlEntityUTF8(s));
|
|
9381
9783
|
}
|
|
9382
9784
|
|
|
9383
|
-
// src/model/graph.ts
|
|
9384
|
-
var Graph = class {
|
|
9385
|
-
/** Graph name; agnameof equivalent. @see lib/cgraph/cgraph.h:agnameof */
|
|
9386
|
-
name;
|
|
9387
|
-
/**
|
|
9388
|
-
* True when the graph was declared with NO name (`digraph {`), as opposed to
|
|
9389
|
-
* an explicit empty name (`digraph "" {`). Both store `name === ''`, but
|
|
9390
|
-
* cgraph gives the truly-anonymous root the internal id `%1` (agnameof) while
|
|
9391
|
-
* the empty-named one keeps `""`. Only the imagemap `<map id/name>` reads this
|
|
9392
|
-
* (map.ts:mapGraphName); dot/xdot re-serialization keeps `name` so an
|
|
9393
|
-
* anonymous root round-trips as `digraph {`, not `digraph %1 {`.
|
|
9394
|
-
* @see lib/cgraph/id.c:idmap (anon → `%1`) ; lib/cgraph/agraph.c:agnameof
|
|
9395
|
-
*/
|
|
9396
|
-
anonymous;
|
|
9397
|
-
/**
|
|
9398
|
-
* Directed/strict classification; mirrors Agdesc_t.directed and
|
|
9399
|
-
* Agdesc_t.strict. @see lib/cgraph/cgraph.h:Agdesc_s
|
|
9400
|
-
*/
|
|
9401
|
-
kind;
|
|
9402
|
-
/**
|
|
9403
|
-
* Node set in insertion order, keyed by name.
|
|
9404
|
-
* Mirrors Agraph_t.n_seq (sequence dict) merged with n_id access.
|
|
9405
|
-
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
9406
|
-
*/
|
|
9407
|
-
nodes;
|
|
9408
|
-
/**
|
|
9409
|
-
* All edges owned by this graph (root graph only for ownership; subgraphs
|
|
9410
|
-
* reference a subset). Mirrors Agraph_t.e_seq.
|
|
9411
|
-
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
9412
|
-
*/
|
|
9413
|
-
edges;
|
|
9414
|
-
/**
|
|
9415
|
-
* Named subgraphs, keyed by name. Mirrors Agraph_t.g_seq/g_id.
|
|
9416
|
-
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
9417
|
-
*/
|
|
9418
|
-
subgraphs;
|
|
9419
|
-
/**
|
|
9420
|
-
* String attributes (agget/agset equivalents).
|
|
9421
|
-
* Replaces the Agattr_t / Agsym_t machinery for simple key-value access.
|
|
9422
|
-
* @see lib/cgraph/cgraph.h:Agattr_s
|
|
9423
|
-
*/
|
|
9424
|
-
attrs;
|
|
9425
|
-
/** Default attributes applied to all nodes in this graph scope. */
|
|
9426
|
-
nodeDefaults;
|
|
9427
|
-
/** Default attributes applied to all edges in this graph scope. */
|
|
9428
|
-
edgeDefaults;
|
|
9429
|
-
/**
|
|
9430
|
-
* Snapshot of the enclosing graphs' graph-attribute defaults (this graph ->
|
|
9431
|
-
* root, inner wins) captured when this subgraph was OPENED during parsing.
|
|
9432
|
-
* Graph attributes set on an ancestor AFTER this subgraph was created are not
|
|
9433
|
-
* included — mirroring cgraph's parse-time agsubg defval copy. Used for
|
|
9434
|
-
* order-correct label/font inheritance (e.g. a root `label=` declared after a
|
|
9435
|
-
* cluster must NOT apply to that cluster). Undefined on the root graph.
|
|
9436
|
-
* @see lib/cgraph/graph.c:agsubg (attr defval copy)
|
|
9437
|
-
*/
|
|
9438
|
-
graphDefaultsSnapshot;
|
|
9439
|
-
/**
|
|
9440
|
-
* Keys in `attrs` the BUILDER seeded from `graphDefaultsSnapshot` rather than
|
|
9441
|
-
* the input declaring them in this scope (see builder.ts GRAPH_LABEL_INHERIT_
|
|
9442
|
-
* KEYS). cgraph distinguishes these structurally — a seeded value is inherited
|
|
9443
|
-
* through the dict view and has no local symbol, while a local declaration
|
|
9444
|
-
* creates one even when its value equals the inherited value — so the
|
|
9445
|
-
* serializer needs the provenance to decide what write_dict would print.
|
|
9446
|
-
* Undefined on the root graph and on any scope that seeded nothing.
|
|
9447
|
-
* @see lib/cgraph/write.c:262 write_dict
|
|
9448
|
-
*/
|
|
9449
|
-
seededAttrs;
|
|
9450
|
-
/**
|
|
9451
|
-
* Graph-attribute keys whose declaration in THIS scope was the first anywhere
|
|
9452
|
-
* in the graph. cgraph's `setattr` splits on exactly this: a key with no
|
|
9453
|
-
* existing symbol takes the global-declaration branch, which ends up seeding
|
|
9454
|
-
* every direct subgraph that already exists with a local empty value (see
|
|
9455
|
-
* `eagerEmptyParts`); a key some earlier scope already declared takes the
|
|
9456
|
-
* "new local definition" branch and touches no subgraph at all. So an
|
|
9457
|
-
* identical `graph [fill=x]` statement makes a child print `fill=""` or print
|
|
9458
|
-
* nothing purely according to whether a SIBLING declared `fill` first.
|
|
9459
|
-
* Undefined on any scope that declared nothing new.
|
|
9460
|
-
* @see lib/cgraph/attr.c:257 setattr (lsym / psym / global branches)
|
|
9461
|
-
*/
|
|
9462
|
-
firstGraphDecl;
|
|
9463
|
-
/**
|
|
9464
|
-
* Layout-engine info; replaces GD_* macros via agbindrec (AD-1).
|
|
9465
|
-
* @see lib/cgraph/cgraph.h:agbindrec
|
|
9466
|
-
*/
|
|
9467
|
-
info;
|
|
9468
|
-
/**
|
|
9469
|
-
* Immediate parent graph. null for root graphs.
|
|
9470
|
-
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
9471
|
-
*/
|
|
9472
|
-
parent;
|
|
9473
|
-
/**
|
|
9474
|
-
* Root (main) graph. Self-referential for root graphs;
|
|
9475
|
-
* points up for subgraphs.
|
|
9476
|
-
* @see lib/cgraph/cgraph.h:Agraph_s
|
|
9477
|
-
*/
|
|
9478
|
-
root;
|
|
9479
|
-
/**
|
|
9480
|
-
* Subgraph sequence number (AGSEQ). A global counter on the root, assigned
|
|
9481
|
-
* at creation in source order, counting anonymous subgraphs. The root keeps
|
|
9482
|
-
* the default 0 (par == NULL never calls agnextseq). Consumed by getObjId to
|
|
9483
|
-
* emit cluster ids `clust<seq>`.
|
|
9484
|
-
* @see lib/cgraph/cgraph.h:AGSEQ
|
|
9485
|
-
* @see lib/cgraph/graph.c:agopen (AGSEQ(g) = agnextseq(par, AGRAPH))
|
|
9486
|
-
*/
|
|
9487
|
-
seq = 0;
|
|
9488
|
-
/**
|
|
9489
|
-
* Root-only counter mirroring `clos->seq[AGRAPH]`: the running maximum AGSEQ
|
|
9490
|
-
* handed out to subgraphs. Meaningful only on the root graph; `assignSubgSeq`
|
|
9491
|
-
* pre-increments it. Other graphs leave it at 0.
|
|
9492
|
-
* @see lib/cgraph/graph.c:agnextseq (++clos->seq[AGRAPH])
|
|
9493
|
-
*/
|
|
9494
|
-
subgSeqCounter = 0;
|
|
9495
|
-
/**
|
|
9496
|
-
* Names of graph attributes (AGRAPH) declared anywhere in this hierarchy —
|
|
9497
|
-
* the port's stand-in for cgraph's `Agsym_t` symbol table. Populated on the
|
|
9498
|
-
* ROOT only, at parse time, whenever a graph attribute is assigned on any
|
|
9499
|
-
* (sub)graph: setting `ordering=out` on a subgraph declares "ordering"
|
|
9500
|
-
* graph-wide with an empty default, so `agGraphAttr(root, "ordering")` returns
|
|
9501
|
-
* `""` (not undefined) — mirroring `agfindgraphattr`/`late_string`. Read via
|
|
9502
|
-
* `agGraphAttr` (model/cgraph-ops.ts); empty on non-root graphs.
|
|
9503
|
-
* @see lib/cgraph/attr.c:agattr (graph-wide declaration, "" default)
|
|
9504
|
-
*/
|
|
9505
|
-
declaredGraphAttrs = /* @__PURE__ */ new Set();
|
|
9506
|
-
/** @see lib/cgraph/graph.c:agopen */
|
|
9507
|
-
constructor(name, kind, anonymous = false) {
|
|
9508
|
-
this.name = name;
|
|
9509
|
-
this.anonymous = anonymous;
|
|
9510
|
-
this.kind = kind;
|
|
9511
|
-
this.nodes = /* @__PURE__ */ new Map();
|
|
9512
|
-
this.edges = [];
|
|
9513
|
-
this.subgraphs = /* @__PURE__ */ new Map();
|
|
9514
|
-
this.attrs = /* @__PURE__ */ new Map();
|
|
9515
|
-
this.nodeDefaults = /* @__PURE__ */ new Map();
|
|
9516
|
-
this.edgeDefaults = /* @__PURE__ */ new Map();
|
|
9517
|
-
this.info = makeGraphInfo();
|
|
9518
|
-
this.parent = null;
|
|
9519
|
-
this.root = this;
|
|
9520
|
-
}
|
|
9521
|
-
};
|
|
9522
|
-
|
|
9523
9785
|
// src/common/make-label.ts
|
|
9524
9786
|
var DEFAULT_FONTSIZE2 = 14;
|
|
9525
9787
|
var DEFAULT_FONTNAME = "Times-Roman";
|
|
@@ -17801,7 +18063,7 @@ function newMatrix(rows, cols) {
|
|
|
17801
18063
|
function dotRoot(g) {
|
|
17802
18064
|
return g.info.dotroot ?? g.root;
|
|
17803
18065
|
}
|
|
17804
|
-
function
|
|
18066
|
+
function agContainsNode2(g, n) {
|
|
17805
18067
|
return g.nodes.get(n.name) === n;
|
|
17806
18068
|
}
|
|
17807
18069
|
function agContainsEdge(g, e) {
|
|
@@ -17814,7 +18076,7 @@ function rankSet(rank3, i, n) {
|
|
|
17814
18076
|
rank3.v[(rank3.vStart ?? 0) + i] = n;
|
|
17815
18077
|
}
|
|
17816
18078
|
function isNormalNodeOf(g, v) {
|
|
17817
|
-
return v.info.node_type === NORMAL &&
|
|
18079
|
+
return v.info.node_type === NORMAL && agContainsNode2(g, v);
|
|
17818
18080
|
}
|
|
17819
18081
|
function isVnodeOfEdgeOf(g, v) {
|
|
17820
18082
|
if (v.info.node_type !== VIRTUAL) return false;
|
|
@@ -18211,76 +18473,6 @@ function ncross(ctx) {
|
|
|
18211
18473
|
return total;
|
|
18212
18474
|
}
|
|
18213
18475
|
|
|
18214
|
-
// src/model/cgraph-ops.ts
|
|
18215
|
-
var LOCALNAMEPREFIX = "%";
|
|
18216
|
-
var ANONYMOUS_ROOT_ID = 1;
|
|
18217
|
-
function agNameOf(g) {
|
|
18218
|
-
return g.anonymous ? `${LOCALNAMEPREFIX}${ANONYMOUS_ROOT_ID}` : g.name;
|
|
18219
|
-
}
|
|
18220
|
-
function freshNodeId(root) {
|
|
18221
|
-
let max = -1;
|
|
18222
|
-
for (const n of root.nodes.values()) {
|
|
18223
|
-
if (n.id > max) max = n.id;
|
|
18224
|
-
}
|
|
18225
|
-
return max + 1;
|
|
18226
|
-
}
|
|
18227
|
-
function agnode(g, name, create) {
|
|
18228
|
-
const root = g.root;
|
|
18229
|
-
if (name !== null && name !== "") {
|
|
18230
|
-
const existing = root.nodes.get(name);
|
|
18231
|
-
if (existing !== void 0) return existing;
|
|
18232
|
-
if (!create) return null;
|
|
18233
|
-
const node2 = new Node(freshNodeId(root), name, root);
|
|
18234
|
-
root.nodes.set(name, node2);
|
|
18235
|
-
return node2;
|
|
18236
|
-
}
|
|
18237
|
-
if (!create) return null;
|
|
18238
|
-
const id = freshNodeId(root);
|
|
18239
|
-
const anonName = LOCALNAMEPREFIX + String(id);
|
|
18240
|
-
const node = new Node(id, anonName, root);
|
|
18241
|
-
root.nodes.set(anonName, node);
|
|
18242
|
-
return node;
|
|
18243
|
-
}
|
|
18244
|
-
function assignSubgSeq(parent2, sg) {
|
|
18245
|
-
sg.seq = ++parent2.root.subgSeqCounter;
|
|
18246
|
-
}
|
|
18247
|
-
function agsubg(parent2, name, create) {
|
|
18248
|
-
const existing = parent2.subgraphs.get(name);
|
|
18249
|
-
if (existing !== void 0) return existing;
|
|
18250
|
-
if (!create) return null;
|
|
18251
|
-
const subg = new Graph(name, parent2.kind);
|
|
18252
|
-
subg.parent = parent2;
|
|
18253
|
-
subg.root = parent2.root;
|
|
18254
|
-
assignSubgSeq(parent2, subg);
|
|
18255
|
-
parent2.subgraphs.set(name, subg);
|
|
18256
|
-
return subg;
|
|
18257
|
-
}
|
|
18258
|
-
function agsubnode(g, n, create) {
|
|
18259
|
-
if (g.root !== n.root) return null;
|
|
18260
|
-
const existing = g.nodes.get(n.name);
|
|
18261
|
-
if (existing !== void 0) return existing;
|
|
18262
|
-
if (!create) return null;
|
|
18263
|
-
const par = g.parent;
|
|
18264
|
-
if (par !== null) {
|
|
18265
|
-
agsubnode(par, n, create);
|
|
18266
|
-
}
|
|
18267
|
-
g.nodes.set(n.name, n);
|
|
18268
|
-
return n;
|
|
18269
|
-
}
|
|
18270
|
-
function agdelnode(g, n) {
|
|
18271
|
-
for (let cur = g; cur !== null; cur = cur.parent) {
|
|
18272
|
-
cur.nodes.delete(n.name);
|
|
18273
|
-
}
|
|
18274
|
-
}
|
|
18275
|
-
function agdelsubg(parent2, sg) {
|
|
18276
|
-
parent2.subgraphs.delete(sg.name);
|
|
18277
|
-
}
|
|
18278
|
-
function agGraphAttr(g, name) {
|
|
18279
|
-
const own = g.attrs.get(name);
|
|
18280
|
-
if (own !== void 0) return own;
|
|
18281
|
-
return g.root.declaredGraphAttrs.has(name) ? "" : void 0;
|
|
18282
|
-
}
|
|
18283
|
-
|
|
18284
18476
|
// src/layout/dot/mincross-flat.ts
|
|
18285
18477
|
function flatRevFindRev(head, tail) {
|
|
18286
18478
|
const fo = head.info.flat_out;
|
|
@@ -18320,7 +18512,7 @@ function flatSearchNormal(g, v, e, M2, hascl) {
|
|
|
18320
18512
|
}
|
|
18321
18513
|
function flatSearchEdge(g, v, e, M2, hascl) {
|
|
18322
18514
|
if (!M2) return false;
|
|
18323
|
-
if (hascl && !(
|
|
18515
|
+
if (hascl && !(agContainsNode2(g, e.tail) && agContainsNode2(g, e.head))) return false;
|
|
18324
18516
|
if ((e.info.weight !== void 0 ? e.info.weight : 0) === 0) return false;
|
|
18325
18517
|
if (e.head.info.onstack) return flatSearchOstack(g, v, e, M2);
|
|
18326
18518
|
flatSearchNormal(g, v, e, M2, hascl);
|
|
@@ -19550,11 +19742,11 @@ function initSubgraphRankdir(g) {
|
|
|
19550
19742
|
var CL_CROSS = 1e3;
|
|
19551
19743
|
function dotInitNode(n) {
|
|
19552
19744
|
n.info.UF_size = 1;
|
|
19553
|
-
|
|
19554
|
-
|
|
19555
|
-
|
|
19556
|
-
|
|
19557
|
-
|
|
19745
|
+
n.info.in = { list: [], size: 0 };
|
|
19746
|
+
n.info.out = { list: [], size: 0 };
|
|
19747
|
+
n.info.flat_in = { list: [], size: 0 };
|
|
19748
|
+
n.info.flat_out = { list: [], size: 0 };
|
|
19749
|
+
n.info.other = { list: [], size: 0 };
|
|
19558
19750
|
if (n.info.lw === void 0) n.info.lw = 27;
|
|
19559
19751
|
if (n.info.rw === void 0) n.info.rw = 27;
|
|
19560
19752
|
if (n.info.ht === void 0) n.info.ht = 36;
|
|
@@ -19581,7 +19773,7 @@ function applyNonconstraintZero(e) {
|
|
|
19581
19773
|
}
|
|
19582
19774
|
function dotInitEdge(e) {
|
|
19583
19775
|
initEdgeConstraint(e);
|
|
19584
|
-
e.info.weight =
|
|
19776
|
+
e.info.weight = lateInt(e.attrs.get("weight"), 1, 0);
|
|
19585
19777
|
e.info.count = 1;
|
|
19586
19778
|
e.info.xpenalty = 1;
|
|
19587
19779
|
applyGroupPenalty(e);
|
|
@@ -19611,7 +19803,6 @@ function clearFastGraphLists(n) {
|
|
|
19611
19803
|
function dotInitNodeEdge(g) {
|
|
19612
19804
|
for (const n of nodesInSeq(g)) {
|
|
19613
19805
|
commonInitNode(n, g);
|
|
19614
|
-
clearFastGraphLists(n);
|
|
19615
19806
|
dotInitNode(n);
|
|
19616
19807
|
}
|
|
19617
19808
|
const measurer = g.root.info.gvc?.textMeasurer;
|
|
@@ -19631,24 +19822,7 @@ function removeFill(g) {
|
|
|
19631
19822
|
}
|
|
19632
19823
|
agdelsubg(g.root, sg);
|
|
19633
19824
|
}
|
|
19634
|
-
function gvCleanupEdgeLabels(e) {
|
|
19635
|
-
e.info.label = void 0;
|
|
19636
|
-
e.info.xlabel = void 0;
|
|
19637
|
-
e.info.head_label = void 0;
|
|
19638
|
-
e.info.tail_label = void 0;
|
|
19639
|
-
}
|
|
19640
|
-
function gvCleanupNodeLabels(n) {
|
|
19641
|
-
n.info.label = void 0;
|
|
19642
|
-
n.info.xlabel = void 0;
|
|
19643
|
-
}
|
|
19644
|
-
function dotCleanupGraph(g) {
|
|
19645
|
-
for (const subg of g.subgraphs.values()) dotCleanupGraph(subg);
|
|
19646
|
-
if (g !== g.root) g.info.label = void 0;
|
|
19647
|
-
}
|
|
19648
19825
|
function dotCleanup(g) {
|
|
19649
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
19650
|
-
for (const n2 of g.nodes.values()) gvCleanupNodeLabels(n2);
|
|
19651
|
-
dotCleanupGraph(g);
|
|
19652
19826
|
let n = g.info.nlist;
|
|
19653
19827
|
while (n !== void 0) {
|
|
19654
19828
|
const next = n.info.next;
|
|
@@ -22096,12 +22270,22 @@ function setGradientFill(obj, color) {
|
|
|
22096
22270
|
obj.fill = 2 /* Linear */;
|
|
22097
22271
|
}
|
|
22098
22272
|
}
|
|
22273
|
+
var PEN_OF_STYLE = /* @__PURE__ */ new Map([
|
|
22274
|
+
["solid", 3 /* Solid */],
|
|
22275
|
+
["dashed", 1 /* Dashed */],
|
|
22276
|
+
["dotted", 2 /* Dotted */],
|
|
22277
|
+
["invis", 0 /* None */],
|
|
22278
|
+
["invisible", 0 /* None */]
|
|
22279
|
+
]);
|
|
22099
22280
|
function setStyle(obj, tokens) {
|
|
22100
22281
|
gvrenderSetStyle(tokens);
|
|
22101
22282
|
obj.rawStyle = [...tokens];
|
|
22102
|
-
const
|
|
22103
|
-
|
|
22104
|
-
|
|
22283
|
+
for (const token of tokens) {
|
|
22284
|
+
const pen = PEN_OF_STYLE.get(styleName(token));
|
|
22285
|
+
if (pen !== void 0) obj.pen = pen;
|
|
22286
|
+
const flags = parseStyleFlags(token);
|
|
22287
|
+
if (flags.bold || flags.setLineWidth !== null) obj.penWidth = resolvePenWidth(flags, void 0);
|
|
22288
|
+
}
|
|
22105
22289
|
}
|
|
22106
22290
|
function devicePoints(pts, job) {
|
|
22107
22291
|
return pts.map((p) => transformPoint({ x: p.x, y: p.y }, job));
|
|
@@ -22168,11 +22352,14 @@ function emitXdot(g, renderer, job) {
|
|
|
22168
22352
|
for (const op of xd.ops) {
|
|
22169
22353
|
styled ||= op.kind === "style";
|
|
22170
22354
|
if (op.kind === "text") continue;
|
|
22171
|
-
if (
|
|
22355
|
+
if (isDrawing(op) && !drawsNow(obj, inClip)) continue;
|
|
22172
22356
|
if (!drawOp(op, renderer, job)) stateOp(op, obj, warned2);
|
|
22173
22357
|
}
|
|
22174
22358
|
if (styled) setStyle(obj, DEFAULT_LINE_STYLE);
|
|
22175
22359
|
}
|
|
22360
|
+
function drawsNow(obj, inClip) {
|
|
22361
|
+
return inClip && obj.pen !== 0 /* None */;
|
|
22362
|
+
}
|
|
22176
22363
|
function isDrawing(op) {
|
|
22177
22364
|
return op.kind.endsWith("ellipse") || op.kind.endsWith("polygon") || op.kind.endsWith("bezier") || op.kind === "polyline";
|
|
22178
22365
|
}
|
|
@@ -25369,13 +25556,13 @@ function dfsNode(Xg, v, frames) {
|
|
|
25369
25556
|
frames.push({ v, edges: v.outEdges(Xg).slice(), i: 0 });
|
|
25370
25557
|
}
|
|
25371
25558
|
function dfsStep2(Xg, frames) {
|
|
25372
|
-
const
|
|
25373
|
-
if (
|
|
25374
|
-
const e =
|
|
25559
|
+
const fr12 = frames[frames.length - 1];
|
|
25560
|
+
if (fr12.i < fr12.edges.length) {
|
|
25561
|
+
const e = fr12.edges[fr12.i++];
|
|
25375
25562
|
if (e.head.info.onstack) reverseEdge2(Xg, e);
|
|
25376
25563
|
else if (!e.head.info.mark) dfsNode(Xg, e.head, frames);
|
|
25377
25564
|
} else {
|
|
25378
|
-
|
|
25565
|
+
fr12.v.info.onstack = 0;
|
|
25379
25566
|
frames.pop();
|
|
25380
25567
|
}
|
|
25381
25568
|
}
|
|
@@ -26522,8 +26709,8 @@ function vnodeNotRelatedTo(g, v) {
|
|
|
26522
26709
|
let e = v.info.save_out?.list[0];
|
|
26523
26710
|
while (e?.info.to_orig) e = e.info.to_orig;
|
|
26524
26711
|
if (!e) return false;
|
|
26525
|
-
if (
|
|
26526
|
-
if (
|
|
26712
|
+
if (agContainsNode2(g, e.tail)) return false;
|
|
26713
|
+
if (agContainsNode2(g, e.head)) return false;
|
|
26527
26714
|
return true;
|
|
26528
26715
|
}
|
|
26529
26716
|
function keepoutLeft(root, g, r, margin) {
|
|
@@ -29054,7 +29241,10 @@ function staleBezierCount(e) {
|
|
|
29054
29241
|
return staleBeziersByEdge.get(e) ?? 0;
|
|
29055
29242
|
}
|
|
29056
29243
|
function staleAdjacent(e) {
|
|
29057
|
-
|
|
29244
|
+
let rep = e;
|
|
29245
|
+
while (rep.info.to_virt !== void 0 && rep.info.to_virt !== rep) rep = rep.info.to_virt;
|
|
29246
|
+
const samePair = rep.tail === e.tail && rep.head === e.head || rep.tail === e.head && rep.head === e.tail;
|
|
29247
|
+
return staleBezierCount(e) > 0 && ((samePair ? rep : e).info.adjacent ?? 0) !== 0;
|
|
29058
29248
|
}
|
|
29059
29249
|
function swapStaleBeziers(g) {
|
|
29060
29250
|
for (const e of g.edges) {
|
|
@@ -29064,8 +29254,13 @@ function swapStaleBeziers(g) {
|
|
|
29064
29254
|
const old = spl.list.splice(0, stale).reverse();
|
|
29065
29255
|
for (const bz of old) swapBezier(bz);
|
|
29066
29256
|
spl.list.push(...old);
|
|
29257
|
+
fillEdgeArrowSlots(e, old);
|
|
29067
29258
|
}
|
|
29068
29259
|
}
|
|
29260
|
+
function fillEdgeArrowSlots(e, old) {
|
|
29261
|
+
e.info.tailArrowOps ??= old.find((bz) => bz.sflag !== 0)?.sArrowOps;
|
|
29262
|
+
e.info.headArrowOps ??= old.find((bz) => bz.eflag !== 0)?.eArrowOps;
|
|
29263
|
+
}
|
|
29069
29264
|
function rankEdgeInfoOf(g, tailNode, headNode) {
|
|
29070
29265
|
const rankTable = g.info.rank;
|
|
29071
29266
|
if (rankTable === void 0) return void 0;
|
|
@@ -30772,7 +30967,7 @@ function cloneNode(g, orign) {
|
|
|
30772
30967
|
}
|
|
30773
30968
|
return n;
|
|
30774
30969
|
}
|
|
30775
|
-
function
|
|
30970
|
+
function cloneEdge2(g, tn, hn, orig) {
|
|
30776
30971
|
const e = new Edge(tn, hn, orig.name);
|
|
30777
30972
|
e.info.tail_port = { ...makePort(), ...orig.info.tail_port };
|
|
30778
30973
|
e.info.head_port = { ...makePort(), ...orig.info.head_port };
|
|
@@ -32363,7 +32558,7 @@ function mapArrowOps(ops) {
|
|
|
32363
32558
|
return m;
|
|
32364
32559
|
});
|
|
32365
32560
|
}
|
|
32366
|
-
function
|
|
32561
|
+
function mapEdge2(e) {
|
|
32367
32562
|
const spl = e.info.spl;
|
|
32368
32563
|
if (spl === void 0) return;
|
|
32369
32564
|
mapSpl(spl);
|
|
@@ -32426,7 +32621,7 @@ function translateDrawing(g) {
|
|
|
32426
32621
|
}
|
|
32427
32622
|
continue;
|
|
32428
32623
|
}
|
|
32429
|
-
|
|
32624
|
+
mapEdge2(e);
|
|
32430
32625
|
}
|
|
32431
32626
|
}
|
|
32432
32627
|
translateBb(g, g.info.rankdir & 3);
|
|
@@ -32565,7 +32760,7 @@ function isPortless(e) {
|
|
|
32565
32760
|
return !e.info.tail_port.defined && !e.info.head_port.defined;
|
|
32566
32761
|
}
|
|
32567
32762
|
function cloneFlatEdge(auxg, tn, auxt, auxh, orig) {
|
|
32568
|
-
return orig.tail === tn ?
|
|
32763
|
+
return orig.tail === tn ? cloneEdge2(auxg, auxt, auxh, orig) : cloneEdge2(auxg, auxh, auxt, orig);
|
|
32569
32764
|
}
|
|
32570
32765
|
function flatLeadPair(edges) {
|
|
32571
32766
|
const t = edges[0].tail, h = edges[0].head;
|
|
@@ -32590,7 +32785,7 @@ function buildFlatAux(g, edges, cnt) {
|
|
|
32590
32785
|
hvye = new Edge(auxt, auxh, "");
|
|
32591
32786
|
auxg.edges.push(hvye);
|
|
32592
32787
|
}
|
|
32593
|
-
hvye.
|
|
32788
|
+
hvye.attrs.set("weight", "10000");
|
|
32594
32789
|
return { auxg, auxt, auxh, alg };
|
|
32595
32790
|
}
|
|
32596
32791
|
function blocksAdjacency(vn) {
|
|
@@ -32618,8 +32813,9 @@ function repositionFlatAux(g, edges, aux) {
|
|
|
32618
32813
|
else n.info.coord = { x: n.info.coord.x, y: midx };
|
|
32619
32814
|
}
|
|
32620
32815
|
}
|
|
32816
|
+
var transformArrowOps = (ops, del, flip) => ops.map((op) => mapArrowOpPoints(op, (p) => transformf(p, del, flip)));
|
|
32621
32817
|
function copyFlatArrow(orig, auxe, del, flip) {
|
|
32622
|
-
const xf = (ops) => ops
|
|
32818
|
+
const xf = (ops) => transformArrowOps(ops, del, flip);
|
|
32623
32819
|
const eflag = auxe.info.spl?.list[0]?.eflag;
|
|
32624
32820
|
const head = auxe.info.headArrowOps ?? (eflag ? auxe.info.tailArrowOps : void 0);
|
|
32625
32821
|
if (head !== void 0) orig.info.headArrowOps = xf(head);
|
|
@@ -32644,6 +32840,8 @@ function copyOneFlatSpline(orig, auxe, del, flip, g) {
|
|
|
32644
32840
|
bz.eflag = auxbz.eflag;
|
|
32645
32841
|
bz.sp = transformf(auxbz.sp, del, flip);
|
|
32646
32842
|
bz.ep = transformf(auxbz.ep, del, flip);
|
|
32843
|
+
if (auxbz.sArrowOps) bz.sArrowOps = transformArrowOps(auxbz.sArrowOps, del, flip);
|
|
32844
|
+
if (auxbz.eArrowOps) bz.eArrowOps = transformArrowOps(auxbz.eArrowOps, del, flip);
|
|
32647
32845
|
for (let j = 0; j < sz; j++) bz.list[j] = transformf(auxbz.list[j], del, flip);
|
|
32648
32846
|
const bb = g.info.bb;
|
|
32649
32847
|
if (bb !== void 0) {
|
|
@@ -33295,11 +33493,8 @@ function makeBezierRecord(bezierPts, arrowTip) {
|
|
|
33295
33493
|
ep: arrowTip
|
|
33296
33494
|
};
|
|
33297
33495
|
}
|
|
33298
|
-
function makeSplineRecord(bz) {
|
|
33299
|
-
return { list: [bz], size: 1, bb: { ll: { x: 0, y: 0 }, ur: { x: 0, y: 0 } } };
|
|
33300
|
-
}
|
|
33301
33496
|
function installEdgeSpline(e, bezierPts, arrowTip) {
|
|
33302
|
-
e.
|
|
33497
|
+
Object.assign(newSpline(e, bezierPts.length), makeBezierRecord(bezierPts, arrowTip));
|
|
33303
33498
|
const bb = e.tail.root.info.bb;
|
|
33304
33499
|
if (bb != null) {
|
|
33305
33500
|
for (let i = 0; i + 3 < bezierPts.length; i += 3) {
|
|
@@ -34396,7 +34591,7 @@ function makeGraph(n) {
|
|
|
34396
34591
|
}
|
|
34397
34592
|
return { nvs: n, vertices };
|
|
34398
34593
|
}
|
|
34399
|
-
function
|
|
34594
|
+
function insertEdge2(g, v1, v2) {
|
|
34400
34595
|
if (!edgeExists(g, v1, v2)) {
|
|
34401
34596
|
g.vertices[v1].adjList.push(v2);
|
|
34402
34597
|
}
|
|
@@ -35323,7 +35518,7 @@ function speFlip(isVert, commCoordMatchesP1, lDirMatchesTarget) {
|
|
|
35323
35518
|
}
|
|
35324
35519
|
function setParallelEdges(seg1, seg2, dir1, dir2, hops, mp) {
|
|
35325
35520
|
let chan = seg1.isVert ? chanSearch(mp.vchans, seg1.commCoord, seg1.p) : chanSearch(mp.hchans, seg1.commCoord, seg1.p);
|
|
35326
|
-
|
|
35521
|
+
insertEdge2(chan.G, seg1.indNo, seg2.indNo);
|
|
35327
35522
|
for (let x = 1; x <= hops; x++) {
|
|
35328
35523
|
const prev1 = nextSeg(seg1, dir1);
|
|
35329
35524
|
const prev2 = nextSeg(seg2, dir2);
|
|
@@ -35333,8 +35528,8 @@ function setParallelEdges(seg1, seg2, dir1, dir2, hops, mp) {
|
|
|
35333
35528
|
const target = seg1.isVert ? 2 /* B_LEFT */ : 1 /* B_UP */;
|
|
35334
35529
|
const flip = speFlip(seg1.isVert, commCoordMatchesP1, lDir === target);
|
|
35335
35530
|
const edgeSeen = edgeExists(chan.G, seg1.indNo, seg2.indNo);
|
|
35336
|
-
if (edgeSeen === flip)
|
|
35337
|
-
else
|
|
35531
|
+
if (edgeSeen === flip) insertEdge2(nchan.G, prev2.indNo, prev1.indNo);
|
|
35532
|
+
else insertEdge2(nchan.G, prev1.indNo, prev2.indNo);
|
|
35338
35533
|
chan = nchan;
|
|
35339
35534
|
seg1 = prev1;
|
|
35340
35535
|
seg2 = prev2;
|
|
@@ -35621,8 +35816,8 @@ function addEdgesInG(cp) {
|
|
|
35621
35816
|
for (let y = x + 1; y < size; y++) {
|
|
35622
35817
|
const cmp = segCmp(cp.segList[x], cp.segList[y]);
|
|
35623
35818
|
if (cmp === -2) return -1;
|
|
35624
|
-
if (cmp > 0)
|
|
35625
|
-
else if (cmp === -1)
|
|
35819
|
+
if (cmp > 0) insertEdge2(G, x, y);
|
|
35820
|
+
else if (cmp === -1) insertEdge2(G, y, x);
|
|
35626
35821
|
}
|
|
35627
35822
|
}
|
|
35628
35823
|
return 0;
|
|
@@ -36577,7 +36772,7 @@ function fillClustMap(g, map) {
|
|
|
36577
36772
|
fillClustMap(cl, map);
|
|
36578
36773
|
}
|
|
36579
36774
|
}
|
|
36580
|
-
function
|
|
36775
|
+
function mkClustMap2(g) {
|
|
36581
36776
|
const map = /* @__PURE__ */ new Map();
|
|
36582
36777
|
fillClustMap(g, map);
|
|
36583
36778
|
return map;
|
|
@@ -36732,7 +36927,7 @@ function makeCompoundEdge(e, clustMap) {
|
|
|
36732
36927
|
if (tailClipped && bez.sflag) restashArrow(e, bez.sp, bez.list[0], true);
|
|
36733
36928
|
}
|
|
36734
36929
|
function dotCompoundEdges(g) {
|
|
36735
|
-
const clustMap =
|
|
36930
|
+
const clustMap = mkClustMap2(g);
|
|
36736
36931
|
for (const e of g.edges) makeCompoundEdge(e, clustMap);
|
|
36737
36932
|
}
|
|
36738
36933
|
|
|
@@ -37296,20 +37491,33 @@ function copyParentAttrs(parent2, sg) {
|
|
|
37296
37491
|
for (const [k, v] of parent2.attrs) sg.attrs.set(k, v);
|
|
37297
37492
|
return sg;
|
|
37298
37493
|
}
|
|
37494
|
+
function componentSubgraph(g, nodes, name, reuse) {
|
|
37495
|
+
const existing = reuse ? g.subgraphs.get(name) : void 0;
|
|
37496
|
+
if (existing === void 0) return copyParentAttrs(g, buildSubgraph(g, nodes, name));
|
|
37497
|
+
const members = /* @__PURE__ */ new Set([...existing.nodes.values(), ...nodes]);
|
|
37498
|
+
existing.nodes.clear();
|
|
37499
|
+
for (const n of [...members].sort((a, b) => a.id - b.id)) existing.nodes.set(n.name, n);
|
|
37500
|
+
const ns = new Set(nodes);
|
|
37501
|
+
const have = new Set(existing.edges);
|
|
37502
|
+
for (const e of g.edges) {
|
|
37503
|
+
if (ns.has(e.tail) && ns.has(e.head) && !have.has(e)) existing.edges.push(e);
|
|
37504
|
+
}
|
|
37505
|
+
return existing;
|
|
37506
|
+
}
|
|
37299
37507
|
function isLegal(p) {
|
|
37300
37508
|
return /^[A-Za-z0-9_]*$/.test(p);
|
|
37301
37509
|
}
|
|
37302
37510
|
function setPrefix(pfx) {
|
|
37303
37511
|
return pfx == null || !isLegal(pfx) ? "_cc_" : pfx;
|
|
37304
37512
|
}
|
|
37305
|
-
function ccomps(g, pfx) {
|
|
37513
|
+
function ccomps(g, pfx, reuse = true) {
|
|
37306
37514
|
const visited = /* @__PURE__ */ new Set();
|
|
37307
37515
|
const result = [];
|
|
37308
37516
|
let idx = 0;
|
|
37309
37517
|
for (const n of g.nodes.values()) {
|
|
37310
37518
|
if (visited.has(n.name)) continue;
|
|
37311
37519
|
const comp = dfsCollect(g, n, visited);
|
|
37312
|
-
result.push(
|
|
37520
|
+
result.push(componentSubgraph(g, comp, `${setPrefix(pfx)}${idx++}`, reuse));
|
|
37313
37521
|
}
|
|
37314
37522
|
return result;
|
|
37315
37523
|
}
|
|
@@ -37325,12 +37533,12 @@ function pccomps(g, pfx) {
|
|
|
37325
37533
|
pinned = true;
|
|
37326
37534
|
}
|
|
37327
37535
|
if (pinnedNodes.length > 0) {
|
|
37328
|
-
result.push(
|
|
37536
|
+
result.push(componentSubgraph(g, pinnedNodes, `${setPrefix(pfx)}${idx++}`, true));
|
|
37329
37537
|
}
|
|
37330
37538
|
for (const n of g.nodes.values()) {
|
|
37331
37539
|
if (visited.has(n.name)) continue;
|
|
37332
37540
|
const comp = dfsCollect(g, n, visited);
|
|
37333
|
-
result.push(
|
|
37541
|
+
result.push(componentSubgraph(g, comp, `${setPrefix(pfx)}${idx++}`, true));
|
|
37334
37542
|
}
|
|
37335
37543
|
return { graphs: result, pinned };
|
|
37336
37544
|
}
|
|
@@ -37783,8 +37991,15 @@ function setEdgeTypeFromAttr(g, defaultValue) {
|
|
|
37783
37991
|
else et = edgeTypeFromString(s, defaultValue);
|
|
37784
37992
|
setEdgeType(g, et);
|
|
37785
37993
|
}
|
|
37994
|
+
function resetAbomShift(g) {
|
|
37995
|
+
const shift = g.info.abomShift ?? 0;
|
|
37996
|
+
if (shift !== 0) {
|
|
37997
|
+
for (const n of g.nodes.values()) n.info.rank = (n.info.rank ?? 0) - shift;
|
|
37998
|
+
}
|
|
37999
|
+
g.info.abomShift = 0;
|
|
38000
|
+
}
|
|
37786
38001
|
function dotPhaseInit(g) {
|
|
37787
|
-
|
|
38002
|
+
resetAbomShift(g);
|
|
37788
38003
|
dotGraphInit(g);
|
|
37789
38004
|
setEdgeTypeFromAttr(g, EDGETYPE_SPLINE);
|
|
37790
38005
|
setAspect(g);
|
|
@@ -37865,6 +38080,7 @@ function doDot(g) {
|
|
|
37865
38080
|
} else if (ratioIsNone(g)) {
|
|
37866
38081
|
pinfo.doSplines = true;
|
|
37867
38082
|
layoutAndPack(g, comps, pinfo, origOf);
|
|
38083
|
+
for (const comp of comps) resetAbomShift(comp);
|
|
37868
38084
|
} else {
|
|
37869
38085
|
dotLayoutPipeline(g);
|
|
37870
38086
|
}
|
|
@@ -38592,6 +38808,109 @@ function buildMask(max) {
|
|
|
38592
38808
|
return mask >>> 0;
|
|
38593
38809
|
}
|
|
38594
38810
|
|
|
38811
|
+
// src/common/utils-inputscale.ts
|
|
38812
|
+
var POINTS_PER_INCH4 = 72;
|
|
38813
|
+
function getInputscale(g) {
|
|
38814
|
+
const d = lateDouble(g.root.attrs.get("inputscale"), -1, 0);
|
|
38815
|
+
return d === 0 ? POINTS_PER_INCH4 : d;
|
|
38816
|
+
}
|
|
38817
|
+
function inputscaleDivisor(g) {
|
|
38818
|
+
const sc = getInputscale(g);
|
|
38819
|
+
return sc > 0 ? sc : 1;
|
|
38820
|
+
}
|
|
38821
|
+
|
|
38822
|
+
// src/layout/neato/init-dim.ts
|
|
38823
|
+
var DFLT_DIM = 2;
|
|
38824
|
+
var MAXDIM = 10;
|
|
38825
|
+
var POINTS_PER_INCH5 = 72;
|
|
38826
|
+
var NUM = "(-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)";
|
|
38827
|
+
var POS3 = new RegExp(`^\\s*${NUM}\\s*,\\s*${NUM}\\s*,\\s*${NUM}(.?)`);
|
|
38828
|
+
var POS2 = new RegExp(`^\\s*${NUM}\\s*,\\s*${NUM}(.?)`);
|
|
38829
|
+
var Z_NUM = new RegExp(`^\\s*${NUM}`);
|
|
38830
|
+
function neatoInitGraphDim(g) {
|
|
38831
|
+
const root = g.root;
|
|
38832
|
+
const outdim = lateInt(root.attrs.get("dimen"), DFLT_DIM, 2);
|
|
38833
|
+
const ndim = Math.min(lateInt(root.attrs.get("dim"), outdim, 2), MAXDIM);
|
|
38834
|
+
root.info.ndim = ndim;
|
|
38835
|
+
root.info.odim = Math.min(outdim, ndim);
|
|
38836
|
+
return ndim;
|
|
38837
|
+
}
|
|
38838
|
+
function ndimOf(g) {
|
|
38839
|
+
return g.root.info.ndim ?? DFLT_DIM;
|
|
38840
|
+
}
|
|
38841
|
+
function jitterD(np, nG, n, ndim) {
|
|
38842
|
+
const pos = np.info.pos;
|
|
38843
|
+
if (pos === void 0) return;
|
|
38844
|
+
for (let k = n; k < ndim; k++) pos[k] = nG * drand48();
|
|
38845
|
+
}
|
|
38846
|
+
function jitter3d(np, nG, ndim) {
|
|
38847
|
+
jitterD(np, nG, 2, ndim);
|
|
38848
|
+
}
|
|
38849
|
+
function nodeAttrDeclared(g, name) {
|
|
38850
|
+
if (g.nodeDefaults.has(name)) return true;
|
|
38851
|
+
for (const n of g.nodes.values()) if (n.attrs.has(name)) return true;
|
|
38852
|
+
for (const sub of g.subgraphs.values()) if (nodeAttrDeclared(sub, name)) return true;
|
|
38853
|
+
return false;
|
|
38854
|
+
}
|
|
38855
|
+
function zDeclared(g) {
|
|
38856
|
+
return nodeAttrDeclared(g.root, "z");
|
|
38857
|
+
}
|
|
38858
|
+
function zValue(np) {
|
|
38859
|
+
return np.attrs.get("z") ?? np.nodeDefaultsSnapshot?.get("z") ?? "";
|
|
38860
|
+
}
|
|
38861
|
+
function scalePos(pvec, ndim, div) {
|
|
38862
|
+
for (let i = 0; i < ndim; i++) pvec[i] = pvec[i] / div;
|
|
38863
|
+
}
|
|
38864
|
+
function userPos3(np, m, nG, ndim) {
|
|
38865
|
+
const pvec = np.info.pos;
|
|
38866
|
+
pvec[0] = Number(m[1]);
|
|
38867
|
+
pvec[1] = Number(m[2]);
|
|
38868
|
+
pvec[2] = Number(m[3]);
|
|
38869
|
+
scalePos(pvec, ndim, inputscaleDivisor(np.root));
|
|
38870
|
+
if (ndim > 3) jitterD(np, nG, 3, ndim);
|
|
38871
|
+
}
|
|
38872
|
+
function userPos2(np, m, nG, ndim) {
|
|
38873
|
+
const pvec = np.info.pos;
|
|
38874
|
+
const div = inputscaleDivisor(np.root);
|
|
38875
|
+
pvec[0] = Number(m[1]);
|
|
38876
|
+
pvec[1] = Number(m[2]);
|
|
38877
|
+
scalePos(pvec, ndim, div);
|
|
38878
|
+
if (ndim <= 2) return;
|
|
38879
|
+
const zm = zDeclared(np.root) ? Z_NUM.exec(zValue(np)) : null;
|
|
38880
|
+
if (zm === null) {
|
|
38881
|
+
jitter3d(np, nG, ndim);
|
|
38882
|
+
return;
|
|
38883
|
+
}
|
|
38884
|
+
pvec[2] = Number(zm[1]) / div;
|
|
38885
|
+
jitterD(np, nG, 3, ndim);
|
|
38886
|
+
}
|
|
38887
|
+
function ensurePos(n, ndim) {
|
|
38888
|
+
if (n.info.pos === void 0 || n.info.pos.length < ndim) n.info.pos = new Array(ndim).fill(0);
|
|
38889
|
+
}
|
|
38890
|
+
function pinRequested(n, c) {
|
|
38891
|
+
const pin = n.attrs.get("pin");
|
|
38892
|
+
return c === "!" || pin !== void 0 && mapbool(pin);
|
|
38893
|
+
}
|
|
38894
|
+
function userPos(n, ndim = DFLT_DIM, nG = n.root.nodes.size) {
|
|
38895
|
+
const p = n.attrs.get("pos");
|
|
38896
|
+
if (p === void 0 || p.length === 0) return false;
|
|
38897
|
+
const m3 = ndim >= 3 ? POS3.exec(p) : null;
|
|
38898
|
+
const m = m3 ?? POS2.exec(p);
|
|
38899
|
+
if (m === null) return false;
|
|
38900
|
+
n.info.posSet = true;
|
|
38901
|
+
ensurePos(n, ndim);
|
|
38902
|
+
if (m3 !== null) userPos3(n, m3, nG, ndim);
|
|
38903
|
+
else userPos2(n, m, nG, ndim);
|
|
38904
|
+
if (pinRequested(n, m[m.length - 1])) n.info.pinned = true;
|
|
38905
|
+
return true;
|
|
38906
|
+
}
|
|
38907
|
+
function addZ(g) {
|
|
38908
|
+
if (ndimOf(g) < 3 || !zDeclared(g)) return;
|
|
38909
|
+
for (const n of g.nodes.values()) {
|
|
38910
|
+
ownAttrs(n).set("z", (POINTS_PER_INCH5 * (n.info.pos?.[2] ?? 0)).toFixed(6));
|
|
38911
|
+
}
|
|
38912
|
+
}
|
|
38913
|
+
|
|
38595
38914
|
// src/layout/neato/start.ts
|
|
38596
38915
|
var INIT_SELF = 0;
|
|
38597
38916
|
var INIT_REGULAR = 1;
|
|
@@ -38630,6 +38949,7 @@ function parseStart(p, dflt) {
|
|
|
38630
38949
|
return { init, seed };
|
|
38631
38950
|
}
|
|
38632
38951
|
function initRegular(g, nG) {
|
|
38952
|
+
const ndim = ndimOf(g);
|
|
38633
38953
|
let a = 0;
|
|
38634
38954
|
const da = 2 * Math.PI / nG;
|
|
38635
38955
|
for (const np of g.nodes.values()) {
|
|
@@ -38637,6 +38957,7 @@ function initRegular(g, nG) {
|
|
|
38637
38957
|
np.info.posSet = true;
|
|
38638
38958
|
np.info.pinned = false;
|
|
38639
38959
|
a += da;
|
|
38960
|
+
if (ndim > 2) jitter3d(np, nG, ndim);
|
|
38640
38961
|
}
|
|
38641
38962
|
}
|
|
38642
38963
|
function checkStart(g, nG = g.nodes.size, dflt = INIT_RANDOM) {
|
|
@@ -38806,12 +39127,17 @@ function fisheryatesShuffle(terms, state3) {
|
|
|
38806
39127
|
function hasPos(np) {
|
|
38807
39128
|
return np.info.posSet === true || np.info.pinned === true;
|
|
38808
39129
|
}
|
|
39130
|
+
function randompos(np, nG, ndim) {
|
|
39131
|
+
np.info.pos = [nG * drand48(), nG * drand48()];
|
|
39132
|
+
if (ndim > 2) jitter3d(np, nG, ndim);
|
|
39133
|
+
}
|
|
38809
39134
|
function initialPositions(g, nG = g.nodes.size) {
|
|
38810
39135
|
if (parseStart(g.root.attrs.get("start"), INIT_RANDOM).init === INIT_REGULAR) return;
|
|
38811
39136
|
checkStart(g, nG, INIT_RANDOM);
|
|
39137
|
+
const ndim = ndimOf(g);
|
|
38812
39138
|
for (const np of g.nodes.values()) {
|
|
38813
39139
|
if (hasPos(np)) continue;
|
|
38814
|
-
np
|
|
39140
|
+
randompos(np, 1, ndim);
|
|
38815
39141
|
}
|
|
38816
39142
|
}
|
|
38817
39143
|
function computeSchedule(terms, maxIter, epsilon = SGD_EPSILON) {
|
|
@@ -39719,7 +40045,6 @@ function mdsModel2(dist5, n, edges) {
|
|
|
39719
40045
|
}
|
|
39720
40046
|
|
|
39721
40047
|
// src/layout/neato/kk.ts
|
|
39722
|
-
var NDIM = 2;
|
|
39723
40048
|
var DEFAULT_DAMPING = 0.99;
|
|
39724
40049
|
var EPSILON_PER_NODE = 1e-4;
|
|
39725
40050
|
var ITERATIONS_PER_NODE = 100;
|
|
@@ -39780,13 +40105,15 @@ function scanGraphMode(g, maxIter) {
|
|
|
39780
40105
|
const damp = g.root.attrs.get("Damping");
|
|
39781
40106
|
const { total, lens } = setEdgeLens(g, nodes);
|
|
39782
40107
|
const ini = initialDist(g, total, epsilon);
|
|
40108
|
+
const ndim = ndimOf(g);
|
|
39783
40109
|
const st = {
|
|
39784
40110
|
n,
|
|
40111
|
+
ndim,
|
|
39785
40112
|
nodes,
|
|
39786
40113
|
dist: new Float64Array(n * n).fill(ini),
|
|
39787
40114
|
spring: new Float64Array(n * n).fill(1),
|
|
39788
|
-
sumT: new Float64Array(n *
|
|
39789
|
-
t: new Float64Array(n * n *
|
|
40115
|
+
sumT: new Float64Array(n * ndim).fill(1),
|
|
40116
|
+
t: new Float64Array(n * n * ndim),
|
|
39790
40117
|
damping: damp === void 0 ? DEFAULT_DAMPING : parseFloat(damp) || 0,
|
|
39791
40118
|
epsilon,
|
|
39792
40119
|
maxIter,
|
|
@@ -39794,9 +40121,10 @@ function scanGraphMode(g, maxIter) {
|
|
|
39794
40121
|
};
|
|
39795
40122
|
return { st, adj: neighbours(g, nodes, lens), ini, lens };
|
|
39796
40123
|
}
|
|
39797
|
-
function
|
|
40124
|
+
function randompos2(np, ndim) {
|
|
39798
40125
|
np.info.pos[0] = drand48();
|
|
39799
40126
|
np.info.pos[1] = drand48();
|
|
40127
|
+
if (ndim > 2) jitter3d(np, 1, ndim);
|
|
39800
40128
|
}
|
|
39801
40129
|
function initialPositions2(g, st) {
|
|
39802
40130
|
const init = checkStart(g, st.n, INIT_RANDOM);
|
|
@@ -39804,12 +40132,12 @@ function initialPositions2(g, st) {
|
|
|
39804
40132
|
if (init === INIT_SELF) warnStartSelfOnce();
|
|
39805
40133
|
for (const np of st.nodes) {
|
|
39806
40134
|
if (np.info.posSet === true || np.info.pinned === true) continue;
|
|
39807
|
-
|
|
40135
|
+
randompos2(np, st.ndim);
|
|
39808
40136
|
}
|
|
39809
40137
|
}
|
|
39810
|
-
function distvec(p0, p1, del) {
|
|
40138
|
+
function distvec(p0, p1, del, ndim) {
|
|
39811
40139
|
let dist5 = 0;
|
|
39812
|
-
for (let k = 0; k <
|
|
40140
|
+
for (let k = 0; k < ndim; k++) {
|
|
39813
40141
|
del[k] = p0[k] - p1[k];
|
|
39814
40142
|
dist5 = fma(del[k], del[k], dist5);
|
|
39815
40143
|
}
|
|
@@ -39827,14 +40155,15 @@ function springFactors(g) {
|
|
|
39827
40155
|
return (a, b) => byEnds.get(`${a.info.id}:${b.info.id}`) ?? (undirected ? byEnds.get(`${b.info.id}:${a.info.id}`) : void 0);
|
|
39828
40156
|
}
|
|
39829
40157
|
function fillRow(st, i, del) {
|
|
40158
|
+
const { ndim } = st;
|
|
39830
40159
|
const vi = st.nodes[i];
|
|
39831
40160
|
for (let j = 0; j < st.n; j++) {
|
|
39832
40161
|
if (i === j) continue;
|
|
39833
|
-
const dist5 = distvec(vi.info.pos, st.nodes[j].info.pos, del);
|
|
39834
|
-
for (let k = 0; k <
|
|
40162
|
+
const dist5 = distvec(vi.info.pos, st.nodes[j].info.pos, del, ndim);
|
|
40163
|
+
for (let k = 0; k < ndim; k++) {
|
|
39835
40164
|
const v = st.spring[i * st.n + j] * (del[k] - st.dist[i * st.n + j] * del[k] / dist5);
|
|
39836
|
-
st.t[(i * st.n + j) *
|
|
39837
|
-
st.sumT[i *
|
|
40165
|
+
st.t[(i * st.n + j) * ndim + k] = v;
|
|
40166
|
+
st.sumT[i * ndim + k] += v;
|
|
39838
40167
|
}
|
|
39839
40168
|
}
|
|
39840
40169
|
}
|
|
@@ -39851,61 +40180,62 @@ function diffeqModel(g, st) {
|
|
|
39851
40180
|
}
|
|
39852
40181
|
}
|
|
39853
40182
|
st.sumT.fill(0);
|
|
39854
|
-
const del = new Float64Array(
|
|
40183
|
+
const del = new Float64Array(st.ndim);
|
|
39855
40184
|
for (let i = 0; i < n; i++) fillRow(st, i, del);
|
|
39856
40185
|
}
|
|
39857
40186
|
function updateArrays(st, i) {
|
|
39858
|
-
const { n } = st;
|
|
39859
|
-
const del = new Float64Array(
|
|
40187
|
+
const { n, ndim } = st;
|
|
40188
|
+
const del = new Float64Array(ndim);
|
|
39860
40189
|
const vi = st.nodes[i];
|
|
39861
|
-
for (let k = 0; k <
|
|
40190
|
+
for (let k = 0; k < ndim; k++) st.sumT[i * ndim + k] = 0;
|
|
39862
40191
|
for (let j = 0; j < n; j++) {
|
|
39863
40192
|
if (i === j) continue;
|
|
39864
|
-
const dist5 = distvec(vi.info.pos, st.nodes[j].info.pos, del);
|
|
39865
|
-
for (let k = 0; k <
|
|
40193
|
+
const dist5 = distvec(vi.info.pos, st.nodes[j].info.pos, del, ndim);
|
|
40194
|
+
for (let k = 0; k < ndim; k++) {
|
|
39866
40195
|
const tij = st.spring[i * n + j] * (del[k] - st.dist[i * n + j] * del[k] / dist5);
|
|
39867
|
-
st.t[(i * n + j) *
|
|
39868
|
-
st.sumT[i *
|
|
39869
|
-
const old = st.t[(j * n + i) *
|
|
39870
|
-
st.t[(j * n + i) *
|
|
39871
|
-
st.sumT[j *
|
|
40196
|
+
st.t[(i * n + j) * ndim + k] = tij;
|
|
40197
|
+
st.sumT[i * ndim + k] += tij;
|
|
40198
|
+
const old = st.t[(j * n + i) * ndim + k];
|
|
40199
|
+
st.t[(j * n + i) * ndim + k] = -tij;
|
|
40200
|
+
st.sumT[j * ndim + k] += -tij - old;
|
|
39872
40201
|
}
|
|
39873
40202
|
}
|
|
39874
40203
|
}
|
|
39875
40204
|
function d2e(st, m, M2) {
|
|
39876
|
-
const { n } = st;
|
|
40205
|
+
const { n, ndim } = st;
|
|
39877
40206
|
const vn = st.nodes[m];
|
|
39878
|
-
const t = new Float64Array(
|
|
40207
|
+
const t = new Float64Array(ndim);
|
|
39879
40208
|
M2.fill(0);
|
|
39880
40209
|
for (let i = 0; i < n; i++) {
|
|
39881
40210
|
if (m === i) continue;
|
|
39882
40211
|
const vi = st.nodes[i];
|
|
39883
40212
|
let sq = 0;
|
|
39884
|
-
for (let k = 0; k <
|
|
40213
|
+
for (let k = 0; k < ndim; k++) {
|
|
39885
40214
|
t[k] = vn.info.pos[k] - vi.info.pos[k];
|
|
39886
40215
|
sq = fma(t[k], t[k], sq);
|
|
39887
40216
|
}
|
|
39888
40217
|
const scale = 1 / Math.pow(sq, 1.5);
|
|
39889
40218
|
const K = st.spring[m * n + i];
|
|
39890
40219
|
const D = st.dist[m * n + i];
|
|
39891
|
-
for (let k = 0; k <
|
|
39892
|
-
for (let l = 0; l < k; l++) M2[l *
|
|
40220
|
+
for (let k = 0; k < ndim; k++) {
|
|
40221
|
+
for (let l = 0; l < k; l++) M2[l * ndim + k] = fma(K * D * t[k] * t[l], scale, M2[l * ndim + k]);
|
|
39893
40222
|
const inner = fms(D * fms(t[k], t[k], sq), scale, 1);
|
|
39894
|
-
M2[k *
|
|
40223
|
+
M2[k * ndim + k] = fma(K, inner, M2[k * ndim + k]);
|
|
39895
40224
|
}
|
|
39896
40225
|
}
|
|
39897
|
-
for (let k = 1; k <
|
|
39898
|
-
for (let l = 0; l < k; l++) M2[k *
|
|
40226
|
+
for (let k = 1; k < ndim; k++) {
|
|
40227
|
+
for (let l = 0; l < k; l++) M2[k * ndim + l] = M2[l * ndim + k];
|
|
39899
40228
|
}
|
|
39900
40229
|
}
|
|
39901
40230
|
function chooseNode(st) {
|
|
39902
40231
|
if (st.move >= st.maxIter) return -1;
|
|
40232
|
+
const { ndim } = st;
|
|
39903
40233
|
let max = 0;
|
|
39904
40234
|
let choice = -1;
|
|
39905
40235
|
for (let i = 0; i < st.n; i++) {
|
|
39906
40236
|
if (st.nodes[i].info.pinned === true) continue;
|
|
39907
40237
|
let m = 0;
|
|
39908
|
-
for (let k = 0; k <
|
|
40238
|
+
for (let k = 0; k < ndim; k++) m = fma(st.sumT[i * ndim + k], st.sumT[i * ndim + k], m);
|
|
39909
40239
|
if (m > max) {
|
|
39910
40240
|
choice = i;
|
|
39911
40241
|
max = m;
|
|
@@ -39914,14 +40244,15 @@ function chooseNode(st) {
|
|
|
39914
40244
|
return max < st.epsilon * st.epsilon ? -1 : choice;
|
|
39915
40245
|
}
|
|
39916
40246
|
function moveNode(st, m) {
|
|
39917
|
-
const
|
|
39918
|
-
const
|
|
39919
|
-
const
|
|
40247
|
+
const { ndim } = st;
|
|
40248
|
+
const a = new Float64Array(ndim * ndim);
|
|
40249
|
+
const b = new Float64Array(ndim);
|
|
40250
|
+
const c = new Float64Array(ndim);
|
|
39920
40251
|
d2e(st, m, a);
|
|
39921
|
-
for (let i = 0; i <
|
|
39922
|
-
solve(a, b, c,
|
|
40252
|
+
for (let i = 0; i < ndim; i++) c[i] = -st.sumT[m * ndim + i];
|
|
40253
|
+
solve(a, b, c, ndim);
|
|
39923
40254
|
const pos = st.nodes[m].info.pos;
|
|
39924
|
-
for (let i = 0; i <
|
|
40255
|
+
for (let i = 0; i < ndim; i++) {
|
|
39925
40256
|
b[i] = fma(2 * (1 - st.damping), drand48(), st.damping) * b[i];
|
|
39926
40257
|
pos[i] += b[i];
|
|
39927
40258
|
}
|
|
@@ -40375,8 +40706,567 @@ function imdsGivenDim(graph, n, givenCoords, newCoords, conjTol) {
|
|
|
40375
40706
|
return 0;
|
|
40376
40707
|
}
|
|
40377
40708
|
|
|
40378
|
-
// src/layout/neato/
|
|
40709
|
+
// src/layout/neato/embed-graph.ts
|
|
40710
|
+
function saveWeights(graph, n) {
|
|
40711
|
+
return graph[0].ewgts.length === 0 ? null : graph.slice(0, n).map((v) => v.ewgts);
|
|
40712
|
+
}
|
|
40713
|
+
function pivotDistances(node, graph, n, reweightGraph, dist5) {
|
|
40714
|
+
if (reweightGraph) ngdijkstra(node, graph, n, dist5);
|
|
40715
|
+
else bfs(node, graph, n, dist5);
|
|
40716
|
+
}
|
|
40717
|
+
function embedGraph(graph, n, dim, reweightGraph) {
|
|
40718
|
+
const dist5 = new Int32Array(n);
|
|
40719
|
+
const oldWeights = saveWeights(graph, n);
|
|
40720
|
+
const coords = Array.from({ length: dim }, () => new Int32Array(n));
|
|
40721
|
+
if (reweightGraph) computeNewWeights(graph, n);
|
|
40722
|
+
let node = crand() % n;
|
|
40723
|
+
pivotDistances(node, graph, n, reweightGraph, coords[0]);
|
|
40724
|
+
let maxDist = 0;
|
|
40725
|
+
for (let i = 0; i < n; i++) {
|
|
40726
|
+
dist5[i] = coords[0][i];
|
|
40727
|
+
if (dist5[i] > maxDist) {
|
|
40728
|
+
node = i;
|
|
40729
|
+
maxDist = dist5[i];
|
|
40730
|
+
}
|
|
40731
|
+
}
|
|
40732
|
+
for (let i = 1; i < dim; i++) {
|
|
40733
|
+
pivotDistances(node, graph, n, reweightGraph, coords[i]);
|
|
40734
|
+
maxDist = 0;
|
|
40735
|
+
for (let j = 0; j < n; j++) {
|
|
40736
|
+
dist5[j] = Math.min(dist5[j], coords[i][j]);
|
|
40737
|
+
if (dist5[j] > maxDist) {
|
|
40738
|
+
node = j;
|
|
40739
|
+
maxDist = dist5[j];
|
|
40740
|
+
}
|
|
40741
|
+
}
|
|
40742
|
+
}
|
|
40743
|
+
if (reweightGraph) restoreOldWeights(graph, n, oldWeights);
|
|
40744
|
+
return coords;
|
|
40745
|
+
}
|
|
40746
|
+
function centerCoordinate(coords, n, dim) {
|
|
40747
|
+
for (let i = 0; i < dim; i++) {
|
|
40748
|
+
let sum = 0;
|
|
40749
|
+
for (let j = 0; j < n; j++) sum += coords[i][j];
|
|
40750
|
+
const avg = Math.trunc(sum / n);
|
|
40751
|
+
for (let j = 0; j < n; j++) coords[i][j] = coords[i][j] - avg;
|
|
40752
|
+
}
|
|
40753
|
+
}
|
|
40754
|
+
|
|
40755
|
+
// src/layout/neato/matrix-ops-dense.ts
|
|
40379
40756
|
var fr5 = Math.fround;
|
|
40757
|
+
var P_ITERATION_THRESHOLD = 1e-3;
|
|
40758
|
+
var POWER_LENGTH_FLOOR2 = 1e-10;
|
|
40759
|
+
var GUESS_RANGE = 100;
|
|
40760
|
+
var BLOCK_ROW = 8;
|
|
40761
|
+
function rightMultWithVectorD(matrix, dim1, dim2, vector, result) {
|
|
40762
|
+
const blocked = dim2 - dim2 % BLOCK_ROW;
|
|
40763
|
+
for (let i = 0; i < dim1; i++) {
|
|
40764
|
+
const row = matrix[i];
|
|
40765
|
+
let res = 0;
|
|
40766
|
+
let j = 0;
|
|
40767
|
+
for (; j < blocked; j++) res += row[j] * vector[j];
|
|
40768
|
+
for (; j < dim2; j++) res = fma(row[j], vector[j], res);
|
|
40769
|
+
result[i] = res;
|
|
40770
|
+
}
|
|
40771
|
+
}
|
|
40772
|
+
function rightMultWithVectorTranspose(matrix, dim1, dim2, vector, result) {
|
|
40773
|
+
for (let i = 0; i < dim1; i++) {
|
|
40774
|
+
let res = 0;
|
|
40775
|
+
for (let j = 0; j < dim2; j++) res = fma(matrix[j][i], vector[j], res);
|
|
40776
|
+
result[i] = res;
|
|
40777
|
+
}
|
|
40778
|
+
}
|
|
40779
|
+
function multDenseMat(A3, B2, dim1, dim2, dim3) {
|
|
40780
|
+
const C6 = Array.from({ length: dim1 }, () => new Float32Array(dim3));
|
|
40781
|
+
for (let i = 0; i < dim1; i++) {
|
|
40782
|
+
for (let j = 0; j < dim3; j++) {
|
|
40783
|
+
let sum = 0;
|
|
40784
|
+
for (let k = 0; k < dim2; k++) sum = fma(A3[i][k], B2[k][j], sum);
|
|
40785
|
+
C6[i][j] = sum;
|
|
40786
|
+
}
|
|
40787
|
+
}
|
|
40788
|
+
return C6;
|
|
40789
|
+
}
|
|
40790
|
+
function multDenseMatD(A3, B2, dim1, dim2, dim3) {
|
|
40791
|
+
const C6 = Array.from({ length: dim1 }, () => new Float64Array(dim3));
|
|
40792
|
+
for (let i = 0; i < dim1; i++) {
|
|
40793
|
+
for (let j = 0; j < dim3; j++) {
|
|
40794
|
+
let sum = 0;
|
|
40795
|
+
for (let k = 0; k < dim2; k++) sum = fma(A3[i][k], B2[k][j], sum);
|
|
40796
|
+
C6[i][j] = sum;
|
|
40797
|
+
}
|
|
40798
|
+
}
|
|
40799
|
+
return C6;
|
|
40800
|
+
}
|
|
40801
|
+
function multSparseDenseMatTranspose(A3, B2, dim1, dim2) {
|
|
40802
|
+
const C6 = Array.from({ length: dim1 }, () => new Float32Array(dim2));
|
|
40803
|
+
for (let i = 0; i < dim1; i++) {
|
|
40804
|
+
const { edges, ewgts, nedges } = A3[i];
|
|
40805
|
+
for (let j = 0; j < dim2; j++) {
|
|
40806
|
+
let sum = 0;
|
|
40807
|
+
for (let k = 0; k < nedges; k++) sum = fma(fr5(ewgts[k]), B2[j][edges[k]], sum);
|
|
40808
|
+
C6[i][j] = sum;
|
|
40809
|
+
}
|
|
40810
|
+
}
|
|
40811
|
+
return C6;
|
|
40812
|
+
}
|
|
40813
|
+
function orthogonalize(st, i, vec) {
|
|
40814
|
+
for (let j = 0; j < i; j++) {
|
|
40815
|
+
const alpha = -innerProduct(st.n, st.eigs[j], vec, BLOCK_ROW);
|
|
40816
|
+
scadd(vec, st.n - 1, alpha, st.eigs[j]);
|
|
40817
|
+
}
|
|
40818
|
+
}
|
|
40819
|
+
function guess(st, i) {
|
|
40820
|
+
const curr = st.eigs[i];
|
|
40821
|
+
for (let j = 0; j < st.n; j++) curr[j] = crand() % GUESS_RANGE;
|
|
40822
|
+
orthogonalize(st, i, curr);
|
|
40823
|
+
return norm(curr, st.n - 1, BLOCK_NONE);
|
|
40824
|
+
}
|
|
40825
|
+
function iterate(st, i) {
|
|
40826
|
+
const { n, mat, tmpVec, lastVec } = st;
|
|
40827
|
+
const curr = st.eigs[i];
|
|
40828
|
+
let angle;
|
|
40829
|
+
let len;
|
|
40830
|
+
st.iteration = 0;
|
|
40831
|
+
do {
|
|
40832
|
+
st.iteration++;
|
|
40833
|
+
copyVector(n, curr, lastVec);
|
|
40834
|
+
rightMultWithVectorD(mat, n, n, curr, tmpVec);
|
|
40835
|
+
copyVector(n, tmpVec, curr);
|
|
40836
|
+
orthogonalize(st, i, curr);
|
|
40837
|
+
len = norm(curr, n - 1, BLOCK_NONE);
|
|
40838
|
+
if (len < POWER_LENGTH_FLOOR2 || st.iteration > st.maxIterations) return null;
|
|
40839
|
+
vectorsScalarMult(n, curr, 1 / len, curr);
|
|
40840
|
+
angle = innerProduct(n, curr, lastVec, BLOCK_ROW);
|
|
40841
|
+
} while (Math.abs(angle) < st.tol);
|
|
40842
|
+
return angle * len;
|
|
40843
|
+
}
|
|
40844
|
+
function fillNullSpace(st, from, neigs) {
|
|
40845
|
+
for (let i = from; i < neigs; i++) {
|
|
40846
|
+
const len = guess(st, i);
|
|
40847
|
+
vectorsScalarMult(st.n, st.eigs[i], 1 / len, st.eigs[i]);
|
|
40848
|
+
st.evals[i] = 0;
|
|
40849
|
+
}
|
|
40850
|
+
}
|
|
40851
|
+
function sortByEval(st, neigs) {
|
|
40852
|
+
const { n, eigs, evals, tmpVec } = st;
|
|
40853
|
+
for (let i = 0; i < neigs - 1; i++) {
|
|
40854
|
+
let largestIndex = i;
|
|
40855
|
+
let largestEval = evals[largestIndex];
|
|
40856
|
+
for (let j = i + 1; j < neigs; j++) {
|
|
40857
|
+
if (largestEval < evals[j]) {
|
|
40858
|
+
largestIndex = j;
|
|
40859
|
+
largestEval = evals[largestIndex];
|
|
40860
|
+
}
|
|
40861
|
+
}
|
|
40862
|
+
if (largestIndex !== i) {
|
|
40863
|
+
copyVector(n, eigs[i], tmpVec);
|
|
40864
|
+
copyVector(n, eigs[largestIndex], eigs[i]);
|
|
40865
|
+
copyVector(n, tmpVec, eigs[largestIndex]);
|
|
40866
|
+
evals[largestIndex] = evals[i];
|
|
40867
|
+
evals[i] = largestEval;
|
|
40868
|
+
}
|
|
40869
|
+
}
|
|
40870
|
+
}
|
|
40871
|
+
function powerIteration(mat, n, neigsIn, eigs) {
|
|
40872
|
+
const neigs = neigsIn >= n ? n : neigsIn;
|
|
40873
|
+
const st = {
|
|
40874
|
+
mat,
|
|
40875
|
+
n,
|
|
40876
|
+
eigs,
|
|
40877
|
+
evals: new Float64Array(neigs),
|
|
40878
|
+
tmpVec: new Float64Array(n),
|
|
40879
|
+
lastVec: new Float64Array(n),
|
|
40880
|
+
maxIterations: 30 * n,
|
|
40881
|
+
tol: 1 - P_ITERATION_THRESHOLD,
|
|
40882
|
+
iteration: 0
|
|
40883
|
+
};
|
|
40884
|
+
let i = 0;
|
|
40885
|
+
for (; i < neigs; i++) {
|
|
40886
|
+
let len = guess(st, i);
|
|
40887
|
+
while (len < POWER_LENGTH_FLOOR2) len = guess(st, i);
|
|
40888
|
+
vectorsScalarMult(n, eigs[i], 1 / len, eigs[i]);
|
|
40889
|
+
const rayleigh = iterate(st, i);
|
|
40890
|
+
if (rayleigh === null) break;
|
|
40891
|
+
st.evals[i] = rayleigh;
|
|
40892
|
+
}
|
|
40893
|
+
fillNullSpace(st, i, neigs);
|
|
40894
|
+
sortByEval(st, neigs);
|
|
40895
|
+
return st.iteration <= st.maxIterations;
|
|
40896
|
+
}
|
|
40897
|
+
|
|
40898
|
+
// src/layout/neato/closest.ts
|
|
40899
|
+
function greaterPriority2(h, i, j) {
|
|
40900
|
+
const a = h.data[i].dist;
|
|
40901
|
+
const b = h.data[j].dist;
|
|
40902
|
+
return a < b || a === b && crand() % 2 !== 0;
|
|
40903
|
+
}
|
|
40904
|
+
function swap3(h, i, j) {
|
|
40905
|
+
const t = h.data[i];
|
|
40906
|
+
h.data[i] = h.data[j];
|
|
40907
|
+
h.data[j] = t;
|
|
40908
|
+
}
|
|
40909
|
+
function heapify2(h, start) {
|
|
40910
|
+
let i = start;
|
|
40911
|
+
for (; ; ) {
|
|
40912
|
+
const l = 2 * i;
|
|
40913
|
+
const r = 2 * i + 1;
|
|
40914
|
+
let largest = l < h.heapSize && greaterPriority2(h, l, i) ? l : i;
|
|
40915
|
+
if (r < h.heapSize && greaterPriority2(h, r, largest)) largest = r;
|
|
40916
|
+
if (largest === i) break;
|
|
40917
|
+
swap3(h, largest, i);
|
|
40918
|
+
i = largest;
|
|
40919
|
+
}
|
|
40920
|
+
}
|
|
40921
|
+
function initHeap2(place, ordering, n) {
|
|
40922
|
+
const h = { data: [], heapSize: n - 1 };
|
|
40923
|
+
for (let i = 0; i < n - 1; i++) {
|
|
40924
|
+
const left2 = ordering[i];
|
|
40925
|
+
const right2 = ordering[i + 1];
|
|
40926
|
+
h.data.push({ left: left2, right: right2, dist: place[right2] - place[left2] });
|
|
40927
|
+
}
|
|
40928
|
+
for (let j = Math.trunc((n - 1) / 2); j >= 0; j--) heapify2(h, j);
|
|
40929
|
+
return h;
|
|
40930
|
+
}
|
|
40931
|
+
function extractMax2(h) {
|
|
40932
|
+
if (h.heapSize === 0) return null;
|
|
40933
|
+
const max = h.data[0];
|
|
40934
|
+
h.data[0] = h.data[h.heapSize - 1];
|
|
40935
|
+
h.heapSize--;
|
|
40936
|
+
heapify2(h, 0);
|
|
40937
|
+
return max;
|
|
40938
|
+
}
|
|
40939
|
+
function insert(h, edge) {
|
|
40940
|
+
let i = h.heapSize;
|
|
40941
|
+
h.heapSize++;
|
|
40942
|
+
h.data[i] = edge;
|
|
40943
|
+
while (i > 0 && greaterPriority2(h, i, Math.trunc(i / 2))) {
|
|
40944
|
+
swap3(h, i, Math.trunc(i / 2));
|
|
40945
|
+
i = Math.trunc(i / 2);
|
|
40946
|
+
}
|
|
40947
|
+
}
|
|
40948
|
+
function insertDescendants(s, pair) {
|
|
40949
|
+
const { place, ordering, invOrdering, left: left2, right: right2, heap } = s;
|
|
40950
|
+
const leftIndex = invOrdering[pair.left];
|
|
40951
|
+
const rightIndex = invOrdering[pair.right];
|
|
40952
|
+
if (leftIndex > 0) {
|
|
40953
|
+
const neighbor2 = ordering[leftIndex - 1];
|
|
40954
|
+
if (invOrdering[right2[neighbor2]] < rightIndex) {
|
|
40955
|
+
insert(heap, { left: neighbor2, right: pair.right, dist: place[pair.right] - place[neighbor2] });
|
|
40956
|
+
right2[neighbor2] = pair.right;
|
|
40957
|
+
left2[pair.right] = neighbor2;
|
|
40958
|
+
}
|
|
40959
|
+
}
|
|
40960
|
+
if (rightIndex < s.n - 1) {
|
|
40961
|
+
const neighbor2 = ordering[rightIndex + 1];
|
|
40962
|
+
if (invOrdering[left2[neighbor2]] > leftIndex) {
|
|
40963
|
+
insert(heap, { left: pair.left, right: neighbor2, dist: place[neighbor2] - place[pair.left] });
|
|
40964
|
+
left2[neighbor2] = pair.left;
|
|
40965
|
+
right2[pair.left] = neighbor2;
|
|
40966
|
+
}
|
|
40967
|
+
}
|
|
40968
|
+
}
|
|
40969
|
+
function orderByPlace(place, n) {
|
|
40970
|
+
const ordering = Array.from({ length: n }, (_, i) => i);
|
|
40971
|
+
return gvQsort(ordering, (x, y) => {
|
|
40972
|
+
if (place[x] < place[y]) return -1;
|
|
40973
|
+
if (place[x] > place[y]) return 1;
|
|
40974
|
+
return 0;
|
|
40975
|
+
});
|
|
40976
|
+
}
|
|
40977
|
+
function findClosestPairs(place, n, numPairs) {
|
|
40978
|
+
const ordering = orderByPlace(place, n);
|
|
40979
|
+
const invOrdering = new Int32Array(n);
|
|
40980
|
+
for (let i = 0; i < n; i++) invOrdering[ordering[i]] = i;
|
|
40981
|
+
const left2 = new Int32Array(n);
|
|
40982
|
+
const right2 = new Int32Array(n);
|
|
40983
|
+
const heap = initHeap2(place, ordering, n);
|
|
40984
|
+
for (let i = 1; i < n; i++) left2[ordering[i]] = ordering[i - 1];
|
|
40985
|
+
for (let i = 0; i < n - 1; i++) right2[ordering[i]] = ordering[i + 1];
|
|
40986
|
+
const scan = { place, n, ordering, invOrdering, left: left2, right: right2, heap };
|
|
40987
|
+
const stack = [];
|
|
40988
|
+
for (let i = 0; i < numPairs; i++) {
|
|
40989
|
+
const pair = extractMax2(heap);
|
|
40990
|
+
if (pair === null) break;
|
|
40991
|
+
stack.push(pair);
|
|
40992
|
+
insertDescendants(scan, pair);
|
|
40993
|
+
}
|
|
40994
|
+
return stack;
|
|
40995
|
+
}
|
|
40996
|
+
function addEdge2(graph, u, v) {
|
|
40997
|
+
const gu = graph[u];
|
|
40998
|
+
const gv = graph[v];
|
|
40999
|
+
if (gu.edges.includes(v)) return;
|
|
41000
|
+
gu.edges.push(v);
|
|
41001
|
+
gu.ewgts.push(1);
|
|
41002
|
+
gu.nedges++;
|
|
41003
|
+
gv.edges.push(u);
|
|
41004
|
+
gv.ewgts.push(1);
|
|
41005
|
+
gv.nedges++;
|
|
41006
|
+
gu.ewgts[0]--;
|
|
41007
|
+
gv.ewgts[0]--;
|
|
41008
|
+
}
|
|
41009
|
+
function constructGraph(n, edgesStack) {
|
|
41010
|
+
const graph = Array.from({ length: n }, (_, i) => ({ nedges: 1, edges: [i], ewgts: [0] }));
|
|
41011
|
+
for (let top = edgesStack.length - 1; top >= 0; top--) {
|
|
41012
|
+
addEdge2(graph, edgesStack[top].left, edgesStack[top].right);
|
|
41013
|
+
}
|
|
41014
|
+
return graph;
|
|
41015
|
+
}
|
|
41016
|
+
function closestPairs2Graph(place, n, numPairs) {
|
|
41017
|
+
return constructGraph(n, findClosestPairs(place, n, numPairs));
|
|
41018
|
+
}
|
|
41019
|
+
|
|
41020
|
+
// src/layout/neato/pca.ts
|
|
41021
|
+
var NUM_PAIRS = 4;
|
|
41022
|
+
function pcaAlloc(coords, dim, n, newCoords, newDim) {
|
|
41023
|
+
const eigs = Array.from({ length: newDim }, () => new Float64Array(dim));
|
|
41024
|
+
const DD = Array.from({ length: dim }, () => new Float64Array(dim));
|
|
41025
|
+
for (let i = 0; i < dim; i++) {
|
|
41026
|
+
for (let j = 0; j <= i; j++) {
|
|
41027
|
+
let sum = 0;
|
|
41028
|
+
for (let k = 0; k < n; k++) sum += Math.imul(coords[i][k], coords[j][k]);
|
|
41029
|
+
DD[i][j] = DD[j][i] = sum;
|
|
41030
|
+
}
|
|
41031
|
+
}
|
|
41032
|
+
powerIteration(DD, dim, newDim, eigs);
|
|
41033
|
+
for (let j = 0; j < newDim; j++) {
|
|
41034
|
+
for (let i = 0; i < n; i++) {
|
|
41035
|
+
let sum = 0;
|
|
41036
|
+
for (let k = 0; k < dim; k++) sum = fma(coords[k][i], eigs[j][k], sum);
|
|
41037
|
+
newCoords[j][i] = sum;
|
|
41038
|
+
}
|
|
41039
|
+
}
|
|
41040
|
+
}
|
|
41041
|
+
function iterativePCA1D(coords, dim, n, newDirection) {
|
|
41042
|
+
const laplacian = closestPairs2Graph(coords[0], n, NUM_PAIRS * n);
|
|
41043
|
+
const mat1 = multSparseDenseMatTranspose(laplacian, coords, n, dim);
|
|
41044
|
+
const mat = multDenseMatD(coords, mat1, dim, n, dim);
|
|
41045
|
+
return powerIteration(mat, dim, 1, [newDirection]);
|
|
41046
|
+
}
|
|
41047
|
+
|
|
41048
|
+
// src/layout/neato/stress-subspace.ts
|
|
41049
|
+
var fr6 = Math.fround;
|
|
41050
|
+
var STRESS_PCA_DIM = 50;
|
|
41051
|
+
var MIN_EMBEDDING_PIVOTS = 50;
|
|
41052
|
+
var ZERO_DISTANCE = 1e-30;
|
|
41053
|
+
var STRESS_GUARD = 1e-10;
|
|
41054
|
+
function distanceKD(coords, dim, i, j) {
|
|
41055
|
+
let sum = 0;
|
|
41056
|
+
for (let k = 0; k < dim; k++) {
|
|
41057
|
+
const d = coords[k][i] - coords[k][j];
|
|
41058
|
+
sum = fma(d, d, sum);
|
|
41059
|
+
}
|
|
41060
|
+
return Math.sqrt(sum);
|
|
41061
|
+
}
|
|
41062
|
+
function computeStress1(coords, distances, dim, n, exp) {
|
|
41063
|
+
let sum = 0;
|
|
41064
|
+
for (let i = 0; i < n; i++) {
|
|
41065
|
+
const row = distances[i];
|
|
41066
|
+
for (let j = 0; j < row.nedges; j++) {
|
|
41067
|
+
const node = row.edges[j];
|
|
41068
|
+
if (node <= i) continue;
|
|
41069
|
+
const dist5 = distanceKD(coords, dim, i, node);
|
|
41070
|
+
const Dij = row.edist[j];
|
|
41071
|
+
sum += exp === 2 ? (Dij - dist5) * (Dij - dist5) / (Dij * Dij) : (Dij - dist5) * (Dij - dist5) / Dij;
|
|
41072
|
+
}
|
|
41073
|
+
}
|
|
41074
|
+
return sum;
|
|
41075
|
+
}
|
|
41076
|
+
function nextPivot(dist5, Di, n, from) {
|
|
41077
|
+
let node = from;
|
|
41078
|
+
let maxDist = 0;
|
|
41079
|
+
for (let j = 0; j < n; j++) {
|
|
41080
|
+
dist5[j] = Math.min(dist5[j], Di[j]);
|
|
41081
|
+
if (dist5[j] > maxDist || dist5[j] === maxDist && crand() % (j + 1) === 0) {
|
|
41082
|
+
node = j;
|
|
41083
|
+
maxDist = dist5[j];
|
|
41084
|
+
}
|
|
41085
|
+
}
|
|
41086
|
+
return node;
|
|
41087
|
+
}
|
|
41088
|
+
function selectPivots(graph, n, numCenters, reweightGraph) {
|
|
41089
|
+
const centerIndex = new Int32Array(n).fill(-1);
|
|
41090
|
+
const invCenterIndex = new Int32Array(numCenters);
|
|
41091
|
+
const Dij = Array.from({ length: numCenters }, () => new Int32Array(n));
|
|
41092
|
+
const dist5 = new Int32Array(n);
|
|
41093
|
+
let node = crand() % n;
|
|
41094
|
+
centerIndex[node] = 0;
|
|
41095
|
+
invCenterIndex[0] = node;
|
|
41096
|
+
pivotDistances(node, graph, n, reweightGraph, Dij[0]);
|
|
41097
|
+
let maxDist = 0;
|
|
41098
|
+
for (let i = 0; i < n; i++) {
|
|
41099
|
+
dist5[i] = Dij[0][i];
|
|
41100
|
+
if (dist5[i] > maxDist) {
|
|
41101
|
+
node = i;
|
|
41102
|
+
maxDist = dist5[i];
|
|
41103
|
+
}
|
|
41104
|
+
}
|
|
41105
|
+
for (let i = 1; i < numCenters; i++) {
|
|
41106
|
+
centerIndex[node] = i;
|
|
41107
|
+
invCenterIndex[i] = node;
|
|
41108
|
+
pivotDistances(node, graph, n, reweightGraph, Dij[i]);
|
|
41109
|
+
node = nextPivot(dist5, Dij[i], n, node);
|
|
41110
|
+
}
|
|
41111
|
+
return { centerIndex, invCenterIndex, Dij };
|
|
41112
|
+
}
|
|
41113
|
+
function pivotRow(i, n, Di) {
|
|
41114
|
+
const edges = new Int32Array(n - 1);
|
|
41115
|
+
const edist = new Int32Array(n - 1);
|
|
41116
|
+
for (let j = 0; j < i; j++) {
|
|
41117
|
+
edges[j] = j;
|
|
41118
|
+
edist[j] = Di[j];
|
|
41119
|
+
}
|
|
41120
|
+
for (let j = i + 1; j < n; j++) {
|
|
41121
|
+
edges[j - 1] = j;
|
|
41122
|
+
edist[j - 1] = Di[j];
|
|
41123
|
+
}
|
|
41124
|
+
return { nedges: n - 1, edges, edist };
|
|
41125
|
+
}
|
|
41126
|
+
function nonPivotRow(i, numCenters, p) {
|
|
41127
|
+
const edges = new Int32Array(numCenters);
|
|
41128
|
+
const edist = new Int32Array(numCenters);
|
|
41129
|
+
for (let j = 0; j < numCenters; j++) {
|
|
41130
|
+
edges[j] = p.invCenterIndex[j];
|
|
41131
|
+
edist[j] = p.Dij[j][i];
|
|
41132
|
+
}
|
|
41133
|
+
return { nedges: numCenters, edges, edist };
|
|
41134
|
+
}
|
|
41135
|
+
function buildDistances(n, numCenters, p) {
|
|
41136
|
+
const distances = [];
|
|
41137
|
+
for (let i = 0; i < n; i++) {
|
|
41138
|
+
const index = p.centerIndex[i];
|
|
41139
|
+
distances.push(index >= 0 ? pivotRow(i, n, p.Dij[index]) : nonPivotRow(i, numCenters, p));
|
|
41140
|
+
}
|
|
41141
|
+
return distances;
|
|
41142
|
+
}
|
|
41143
|
+
function buildSparseLaplacian(distances, n, exp) {
|
|
41144
|
+
const lap = [];
|
|
41145
|
+
for (let i = 0; i < n; i++) {
|
|
41146
|
+
const row = distances[i];
|
|
41147
|
+
const edges = [i];
|
|
41148
|
+
const ewgts = [0];
|
|
41149
|
+
let degree = 0;
|
|
41150
|
+
for (let j = 0; j < row.nedges; j++) {
|
|
41151
|
+
const d = fr6(row.edist[j]);
|
|
41152
|
+
const w = exp === 2 ? fr6(-1 / fr6(d * d)) : fr6(-1 / d);
|
|
41153
|
+
edges.push(row.edges[j]);
|
|
41154
|
+
ewgts.push(w);
|
|
41155
|
+
degree -= w;
|
|
41156
|
+
}
|
|
41157
|
+
ewgts[0] = fr6(degree);
|
|
41158
|
+
lap.push({ nedges: row.nedges + 1, edges, ewgts });
|
|
41159
|
+
}
|
|
41160
|
+
return lap;
|
|
41161
|
+
}
|
|
41162
|
+
function initialDirections(subspace, subspaceDim, n, dim) {
|
|
41163
|
+
const storage = new Float64Array(dim * subspaceDim);
|
|
41164
|
+
const directions = Array.from({ length: dim }, (_, k) => storage.subarray(k * subspaceDim, (k + 1) * subspaceDim));
|
|
41165
|
+
if (dim !== 2) {
|
|
41166
|
+
for (let k = 0; k < dim; k++) storage[k * subspaceDim + k] = 1;
|
|
41167
|
+
return directions;
|
|
41168
|
+
}
|
|
41169
|
+
directions[0][0] = 1;
|
|
41170
|
+
if (!iterativePCA1D(subspace, subspaceDim, n, directions[1])) {
|
|
41171
|
+
directions[1].fill(0);
|
|
41172
|
+
directions[1][1] = 1;
|
|
41173
|
+
}
|
|
41174
|
+
return directions;
|
|
41175
|
+
}
|
|
41176
|
+
function computeB(st, k) {
|
|
41177
|
+
const { n, dim, coords, distances, lap, b } = st;
|
|
41178
|
+
const ck = coords[k];
|
|
41179
|
+
for (let i = 0; i < n; i++) {
|
|
41180
|
+
let degree = 0;
|
|
41181
|
+
let bi = 0;
|
|
41182
|
+
const { edges, ewgts, nedges } = lap[i];
|
|
41183
|
+
const edist = distances[i].edist;
|
|
41184
|
+
for (let j = 1; j < nedges; j++) {
|
|
41185
|
+
const node = edges[j];
|
|
41186
|
+
const distIj = distanceKD(coords, dim, i, node);
|
|
41187
|
+
if (distIj > ZERO_DISTANCE) {
|
|
41188
|
+
const Lij = fr6(-ewgts[j] * fr6(edist[j - 1])) / distIj;
|
|
41189
|
+
degree -= Lij;
|
|
41190
|
+
bi = fma(Lij, ck[node], bi);
|
|
41191
|
+
}
|
|
41192
|
+
}
|
|
41193
|
+
b[i] = fma(degree, ck[i], bi);
|
|
41194
|
+
}
|
|
41195
|
+
}
|
|
41196
|
+
function optimizeAxes(st) {
|
|
41197
|
+
const { n, dim, subspaceDim, subspace, matrix, directions, coords, b, bRestricted } = st;
|
|
41198
|
+
for (let k = 0; k < dim; k++) {
|
|
41199
|
+
computeB(st, k);
|
|
41200
|
+
rightMultWithVectorD(subspace, subspaceDim, n, b, bRestricted);
|
|
41201
|
+
const rc = conjugateGradientF(matrix, directions[k], bRestricted, subspaceDim, {
|
|
41202
|
+
tol: TOLERANCE_CG,
|
|
41203
|
+
maxIterations: subspaceDim,
|
|
41204
|
+
ortho1: false
|
|
41205
|
+
});
|
|
41206
|
+
if (rc !== 0) return true;
|
|
41207
|
+
rightMultWithVectorTranspose(subspace, n, subspaceDim, directions[k], coords[k]);
|
|
41208
|
+
}
|
|
41209
|
+
return false;
|
|
41210
|
+
}
|
|
41211
|
+
function optimizeLayout(st, o) {
|
|
41212
|
+
let oldStress = computeStress1(st.coords, st.distances, st.dim, st.n, o.exp);
|
|
41213
|
+
let converged = false;
|
|
41214
|
+
let iterations = 0;
|
|
41215
|
+
for (; iterations < o.nIterations && !converged; iterations++) {
|
|
41216
|
+
if (optimizeAxes(st)) return -1;
|
|
41217
|
+
if (iterations % 2 === 0) {
|
|
41218
|
+
const newStress = computeStress1(st.coords, st.distances, st.dim, st.n, o.exp);
|
|
41219
|
+
converged = Math.abs(newStress - oldStress) / (newStress + STRESS_GUARD) < o.epsilon;
|
|
41220
|
+
oldStress = newStress;
|
|
41221
|
+
}
|
|
41222
|
+
}
|
|
41223
|
+
return iterations;
|
|
41224
|
+
}
|
|
41225
|
+
function computeSubspace(graph, n, subspaceDim, reweightGraph) {
|
|
41226
|
+
const subspace = Array.from({ length: subspaceDim }, () => new Float64Array(n));
|
|
41227
|
+
const numCentersLocal = Math.min(n, Math.max(2 * subspaceDim, MIN_EMBEDDING_PIVOTS));
|
|
41228
|
+
const fullCoords = embedGraph(graph, n, numCentersLocal, reweightGraph);
|
|
41229
|
+
centerCoordinate(fullCoords, n, numCentersLocal);
|
|
41230
|
+
pcaAlloc(fullCoords, numCentersLocal, n, subspace, subspaceDim);
|
|
41231
|
+
return subspace;
|
|
41232
|
+
}
|
|
41233
|
+
function sparseStressSubspaceMajorizationKD(graph, n, coords, o) {
|
|
41234
|
+
const { dim, exp, reweightGraph, numCenters } = o;
|
|
41235
|
+
const subspaceDim = Math.min(STRESS_PCA_DIM, n);
|
|
41236
|
+
const subspace = computeSubspace(graph, n, subspaceDim, reweightGraph);
|
|
41237
|
+
const oldWeights = saveWeights(graph, n);
|
|
41238
|
+
if (reweightGraph) computeNewWeights(graph, n);
|
|
41239
|
+
const pivots = selectPivots(graph, n, numCenters, reweightGraph);
|
|
41240
|
+
const distances = buildDistances(n, numCenters, pivots);
|
|
41241
|
+
const lap = buildSparseLaplacian(distances, n, exp);
|
|
41242
|
+
const directions = initialDirections(subspace, subspaceDim, n, dim);
|
|
41243
|
+
for (let k = 0; k < dim; k++) {
|
|
41244
|
+
rightMultWithVectorTranspose(subspace, n, subspaceDim, directions[k], coords[k]);
|
|
41245
|
+
}
|
|
41246
|
+
const tmpMat = multSparseDenseMatTranspose(lap, subspace, n, subspaceDim);
|
|
41247
|
+
const matrix = multDenseMat(subspace, tmpMat, subspaceDim, n, subspaceDim);
|
|
41248
|
+
const iterations = optimizeLayout({
|
|
41249
|
+
n,
|
|
41250
|
+
dim,
|
|
41251
|
+
subspaceDim,
|
|
41252
|
+
subspace,
|
|
41253
|
+
distances,
|
|
41254
|
+
lap,
|
|
41255
|
+
matrix,
|
|
41256
|
+
directions,
|
|
41257
|
+
coords,
|
|
41258
|
+
b: new Float64Array(n),
|
|
41259
|
+
bRestricted: new Float64Array(subspaceDim)
|
|
41260
|
+
}, o);
|
|
41261
|
+
if (reweightGraph) restoreOldWeights(graph, n, oldWeights);
|
|
41262
|
+
return iterations;
|
|
41263
|
+
}
|
|
41264
|
+
|
|
41265
|
+
// src/layout/neato/stress-kernel.ts
|
|
41266
|
+
var fr7 = Math.fround;
|
|
41267
|
+
var SMART_SUBSPACE_ITERATIONS = 50;
|
|
41268
|
+
var NUM_PIVOTS_STRESS = 40;
|
|
41269
|
+
var SMART_NOISE = 1e-6;
|
|
40380
41270
|
function computeApspPacked2(graph, n) {
|
|
40381
41271
|
const Dij = new Float32Array(n * (n + 1) / 2);
|
|
40382
41272
|
const Di = new Int32Array(n);
|
|
@@ -40400,6 +41290,7 @@ function initLayout(n, dim, coords, nodes) {
|
|
|
40400
41290
|
if (hasPos2(np)) {
|
|
40401
41291
|
coords[0][i] = np.info.pos?.[0] ?? 0;
|
|
40402
41292
|
coords[1][i] = np.info.pos?.[1] ?? 0;
|
|
41293
|
+
for (let d = 2; d < dim; d++) coords[d][i] = np.info.pos?.[d] ?? 0;
|
|
40403
41294
|
if (isFixed(np)) pinned = true;
|
|
40404
41295
|
} else {
|
|
40405
41296
|
coords[0][i] = drand48();
|
|
@@ -40449,7 +41340,7 @@ function buildLap1(lap1, lap2, coords, shape) {
|
|
|
40449
41340
|
for (let k = 0; k < dim; k++) {
|
|
40450
41341
|
const ck = coords[k];
|
|
40451
41342
|
for (let x = 0; x < len; x++) {
|
|
40452
|
-
const tmp =
|
|
41343
|
+
const tmp = fr7(ck[i] + fr7(-1 * ck[i + 1 + x]));
|
|
40453
41344
|
distAccumulator[x] = ops.squareAdd(tmp, distAccumulator[x]);
|
|
40454
41345
|
}
|
|
40455
41346
|
}
|
|
@@ -40462,7 +41353,7 @@ function buildLap1(lap1, lap2, coords, shape) {
|
|
|
40462
41353
|
let degree = 0;
|
|
40463
41354
|
if (exp === 2) {
|
|
40464
41355
|
for (let j = 0; j < len; j++, count++) {
|
|
40465
|
-
const val2 = lap1[count] =
|
|
41356
|
+
const val2 = lap1[count] = fr7(lap1[count] * distAccumulator[j]);
|
|
40466
41357
|
degree += val2;
|
|
40467
41358
|
degrees[i + j + 1] = degrees[i + j + 1] - val2;
|
|
40468
41359
|
}
|
|
@@ -40507,19 +41398,50 @@ function solveAxis(st, k, havePinned, nodes) {
|
|
|
40507
41398
|
}
|
|
40508
41399
|
return 0;
|
|
40509
41400
|
}
|
|
41401
|
+
function smartLayout(smart, n, dCoords, o) {
|
|
41402
|
+
const { dim } = o;
|
|
41403
|
+
const iterations = sparseStressSubspaceMajorizationKD(smart.graph, n, dCoords, {
|
|
41404
|
+
dim,
|
|
41405
|
+
exp: o.opts & OPT_EXP_FLAG,
|
|
41406
|
+
reweightGraph: smart.reweightGraph,
|
|
41407
|
+
nIterations: SMART_SUBSPACE_ITERATIONS,
|
|
41408
|
+
numCenters: NUM_PIVOTS_STRESS,
|
|
41409
|
+
epsilon: o.epsilon
|
|
41410
|
+
});
|
|
41411
|
+
if (iterations < 0) return -1;
|
|
41412
|
+
for (let i = 0; i < dim; i++) {
|
|
41413
|
+
const c = dCoords[i];
|
|
41414
|
+
let max = 1;
|
|
41415
|
+
for (let j = 0; j < n; j++) {
|
|
41416
|
+
if (Math.abs(c[j]) > max) max = Math.abs(c[j]);
|
|
41417
|
+
}
|
|
41418
|
+
for (let j = 0; j < n; j++) c[j] = c[j] / max;
|
|
41419
|
+
for (let j = 0; j < n; j++) c[j] = fma(drand48() - 0.5, SMART_NOISE, c[j]);
|
|
41420
|
+
orthog1(n, c);
|
|
41421
|
+
}
|
|
41422
|
+
return 0;
|
|
41423
|
+
}
|
|
41424
|
+
function initialLayout(n, dCoords, nodes, o) {
|
|
41425
|
+
if (o.smart !== void 0 && (o.opts & OPT_SMART_INIT) !== 0 && n > 1) {
|
|
41426
|
+
return smartLayout(o.smart, n, dCoords, o);
|
|
41427
|
+
}
|
|
41428
|
+
return initLayout(n, o.dim, dCoords, nodes) ? 1 : 0;
|
|
41429
|
+
}
|
|
40510
41430
|
function stressMajorizationKDMkernel(Dij, n, dCoords, nodes, o) {
|
|
40511
41431
|
const { dim, maxi } = o;
|
|
40512
41432
|
const exp = o.opts & OPT_EXP_FLAG;
|
|
40513
41433
|
if (maxi < 0) return 0;
|
|
40514
|
-
const
|
|
41434
|
+
const layout2 = initialLayout(n, dCoords, nodes, o);
|
|
41435
|
+
if (layout2 < 0) return -1;
|
|
41436
|
+
const havePinned = layout2 === 1;
|
|
40515
41437
|
if (n === 1 || maxi === 0) return 0;
|
|
40516
41438
|
const coords = [];
|
|
40517
41439
|
for (let i = 0; i < dim; i++) {
|
|
40518
41440
|
const c = new Float32Array(n);
|
|
40519
|
-
for (let j = 0; j < n; j++) c[j] =
|
|
41441
|
+
for (let j = 0; j < n; j++) c[j] = fr7(dCoords[i][j]);
|
|
40520
41442
|
coords.push(c);
|
|
40521
41443
|
}
|
|
40522
|
-
const constantTerm =
|
|
41444
|
+
const constantTerm = fr7(n * (n - 1) / 2);
|
|
40523
41445
|
const lap2 = Dij;
|
|
40524
41446
|
buildLap2(lap2, n, exp);
|
|
40525
41447
|
const lapLength = n * (n + 1) / 2;
|
|
@@ -40541,7 +41463,6 @@ function stressMajorizationKDMkernel(Dij, n, dCoords, nodes, o) {
|
|
|
40541
41463
|
for (; iterations < maxi && !converged; iterations++) {
|
|
40542
41464
|
buildLap1(st.lap1, lap2, coords, { n, dim, exp, ops: st.ops });
|
|
40543
41465
|
const newStress = computeStress(st);
|
|
40544
|
-
if (typeof process !== "undefined" && process.env["STRESS_DEBUG"] && iterations % 5 === 0) console.error(newStress.toFixed(3));
|
|
40545
41466
|
const change = Math.abs(oldStress - newStress);
|
|
40546
41467
|
converged = change / oldStress < o.epsilon || newStress < o.epsilon;
|
|
40547
41468
|
oldStress = newStress;
|
|
@@ -40659,7 +41580,7 @@ function stressModelDij(graph, n, model) {
|
|
|
40659
41580
|
}
|
|
40660
41581
|
|
|
40661
41582
|
// src/layout/neato/constrained-majorization.ts
|
|
40662
|
-
var
|
|
41583
|
+
var fr8 = Math.fround;
|
|
40663
41584
|
var LOCAL_CONSTR_MAJOR_ITERATIONS = 15;
|
|
40664
41585
|
var LEVELS_SEP_TOL = 0.1;
|
|
40665
41586
|
var ABS_TOL = 0.01;
|
|
@@ -40668,18 +41589,15 @@ var FLT_MAX3 = 34028234663852886e22;
|
|
|
40668
41589
|
var DBL_MAX = Number.MAX_VALUE;
|
|
40669
41590
|
var MIN_LEVELS = 1;
|
|
40670
41591
|
var Y_AXIS = 1;
|
|
40671
|
-
function unsupported2(what) {
|
|
40672
|
-
throw new RenderError(`hierarchical stress majorization: ${what} is not supported yet`, "UNSUPPORTED_FEATURE");
|
|
40673
|
-
}
|
|
40674
41592
|
function unconstrainedMajorization(graph, n, dCoords, nodes, o) {
|
|
40675
41593
|
if (o.maxi < 0) return 0;
|
|
40676
41594
|
const Dij = stressModelDij(graph, n, o.model);
|
|
40677
|
-
if ((o.opts & OPT_SMART_INIT) !== 0 && n > 1) unsupported2("the smart initial layout");
|
|
40678
41595
|
return stressMajorizationKDMkernel(Dij, n, dCoords, nodes, {
|
|
40679
41596
|
dim: o.dim,
|
|
40680
41597
|
opts: o.opts,
|
|
40681
41598
|
maxi: o.maxi,
|
|
40682
|
-
epsilon: o.epsilon
|
|
41599
|
+
epsilon: o.epsilon,
|
|
41600
|
+
smart: { graph, reweightGraph: o.model === MODEL_SUBSET2 }
|
|
40683
41601
|
});
|
|
40684
41602
|
}
|
|
40685
41603
|
function hasDirectionality(graph, n) {
|
|
@@ -40727,14 +41645,6 @@ function plainInitLayers(graph, n, dCoords, nodes, dim) {
|
|
|
40727
41645
|
const h = computeHierarchy(graph, n, ABS_TOL, LEVELS_SEP_TOL, null);
|
|
40728
41646
|
return h === null ? -1 : h;
|
|
40729
41647
|
}
|
|
40730
|
-
function distanceKD(coords, dim, i, j) {
|
|
40731
|
-
let sum = 0;
|
|
40732
|
-
for (let k = 0; k < dim; k++) {
|
|
40733
|
-
const d = coords[k][i] - coords[k][j];
|
|
40734
|
-
sum = fma(d, d, sum);
|
|
40735
|
-
}
|
|
40736
|
-
return Math.sqrt(sum);
|
|
40737
|
-
}
|
|
40738
41648
|
function scaleDownLayout(dCoords, n, dim) {
|
|
40739
41649
|
let max = 1;
|
|
40740
41650
|
for (let i = 0; i < dim; i++) {
|
|
@@ -40757,7 +41667,7 @@ function scaleDistances(Dij, dCoords, n, dim) {
|
|
|
40757
41667
|
sum2 += distanceKD(dCoords, dim, i, j) / Dij[count];
|
|
40758
41668
|
}
|
|
40759
41669
|
}
|
|
40760
|
-
const scaleRatio =
|
|
41670
|
+
const scaleRatio = fr8(sum2 / sum1);
|
|
40761
41671
|
for (let i = 0; i < length; i++) Dij[i] = Dij[i] * scaleRatio;
|
|
40762
41672
|
}
|
|
40763
41673
|
function centerLayout(dCoords, n, dim) {
|
|
@@ -40813,7 +41723,7 @@ function buildLap12(st) {
|
|
|
40813
41723
|
count++;
|
|
40814
41724
|
let degree = 0;
|
|
40815
41725
|
for (let j = 0; j < len; j++, count++) {
|
|
40816
|
-
const val2 =
|
|
41726
|
+
const val2 = fr8(lap1[count] * distAccumulator[j]);
|
|
40817
41727
|
lap1[count] = val2;
|
|
40818
41728
|
degree += val2;
|
|
40819
41729
|
degrees[i + j + 1] -= val2;
|
|
@@ -42366,8 +43276,8 @@ function genYConstraints(rects, vs) {
|
|
|
42366
43276
|
}
|
|
42367
43277
|
|
|
42368
43278
|
// src/layout/neato/quad-prog-vpsc-overlap.ts
|
|
42369
|
-
var
|
|
42370
|
-
var X_GROWTH =
|
|
43279
|
+
var fr9 = Math.fround;
|
|
43280
|
+
var X_GROWTH = fr9(1.0001);
|
|
42371
43281
|
var BOUNDARY_WIDTH = 1e-4;
|
|
42372
43282
|
var TMP_CLUSTER_VAR_ID = 123;
|
|
42373
43283
|
function copyBox(b) {
|
|
@@ -42513,7 +43423,7 @@ function generateNonoverlapConstraints(e, a) {
|
|
|
42513
43423
|
n -= 2 * a.opt.clusters.nclusters;
|
|
42514
43424
|
}
|
|
42515
43425
|
if (a.k === 0) {
|
|
42516
|
-
nsizeScale =
|
|
43426
|
+
nsizeScale = fr9(nsizeScale * X_GROWTH);
|
|
42517
43427
|
}
|
|
42518
43428
|
const bb = nodeBoxes(n, nsizeScale, a);
|
|
42519
43429
|
let csol;
|
|
@@ -42576,15 +43486,15 @@ function getNumDigcolaConstraints(levels, numLevels) {
|
|
|
42576
43486
|
}
|
|
42577
43487
|
|
|
42578
43488
|
// src/layout/neato/quad-prog-vpsc.ts
|
|
42579
|
-
var
|
|
43489
|
+
var fr10 = Math.fround;
|
|
42580
43490
|
var QUAD_PROG_TOL = 1e-4;
|
|
42581
43491
|
var DUMMY_WEIGHT = 1e-6;
|
|
42582
43492
|
var VECTOR_BLOCK = 4;
|
|
42583
43493
|
function rowReduce(row, factor, v, n, acc) {
|
|
42584
43494
|
const blocked = n - n % VECTOR_BLOCK;
|
|
42585
43495
|
let j = 0;
|
|
42586
|
-
for (; j < blocked; j++) acc =
|
|
42587
|
-
for (; j < n; j++) acc = fmaf(
|
|
43496
|
+
for (; j < blocked; j++) acc = fr10(acc + fr10(fr10(factor * row[j]) * v[j]));
|
|
43497
|
+
for (; j < n; j++) acc = fmaf(fr10(factor * row[j]), v[j], acc);
|
|
42588
43498
|
return acc;
|
|
42589
43499
|
}
|
|
42590
43500
|
function project(e, place, n) {
|
|
@@ -42602,7 +43512,7 @@ function descentStep(e, b, place, n) {
|
|
|
42602
43512
|
const oldPlace = e.fArray2;
|
|
42603
43513
|
for (let i = 0; i < n; i++) {
|
|
42604
43514
|
oldPlace[i] = place[i];
|
|
42605
|
-
g[i] = rowReduce(A3[i], -2, place, n,
|
|
43515
|
+
g[i] = rowReduce(A3[i], -2, place, n, fr10(2 * b[i]));
|
|
42606
43516
|
}
|
|
42607
43517
|
let numerator = 0;
|
|
42608
43518
|
let denominator = 0;
|
|
@@ -42611,7 +43521,7 @@ function descentStep(e, b, place, n) {
|
|
|
42611
43521
|
const r = rowReduce(A3[i], 2, g, n, 0);
|
|
42612
43522
|
denominator = fmaf(-r, g[i], denominator);
|
|
42613
43523
|
}
|
|
42614
|
-
return denominator !== 0 ? -
|
|
43524
|
+
return denominator !== 0 ? -fr10(numerator / denominator) : -1;
|
|
42615
43525
|
}
|
|
42616
43526
|
function lineSearchBeta(e, place, n) {
|
|
42617
43527
|
const A3 = e.A;
|
|
@@ -42619,7 +43529,7 @@ function lineSearchBeta(e, place, n) {
|
|
|
42619
43529
|
const oldPlace = e.fArray2;
|
|
42620
43530
|
const d = e.fArray3;
|
|
42621
43531
|
for (let i = 0; i < n; i++) {
|
|
42622
|
-
d[i] =
|
|
43532
|
+
d[i] = fr10(place[i] - oldPlace[i]);
|
|
42623
43533
|
}
|
|
42624
43534
|
let numerator = 0;
|
|
42625
43535
|
let denominator = 0;
|
|
@@ -42628,7 +43538,7 @@ function lineSearchBeta(e, place, n) {
|
|
|
42628
43538
|
const r = rowReduce(A3[i], 2, d, n, 0);
|
|
42629
43539
|
denominator = fmaf(r, d[i], denominator);
|
|
42630
43540
|
}
|
|
42631
|
-
if (!Object.is(denominator, 0) && !Object.is(denominator, -0)) return
|
|
43541
|
+
if (!Object.is(denominator, 0) && !Object.is(denominator, -0)) return fr10(numerator / denominator);
|
|
42632
43542
|
return 1;
|
|
42633
43543
|
}
|
|
42634
43544
|
function applyBeta(e, place, n, beta) {
|
|
@@ -42639,7 +43549,7 @@ function applyBeta(e, place, n, beta) {
|
|
|
42639
43549
|
if (beta > 0 && beta < 1) {
|
|
42640
43550
|
place[i] = fmaf(beta, d[i], oldPlace[i]);
|
|
42641
43551
|
}
|
|
42642
|
-
test =
|
|
43552
|
+
test = fr10(test + fr10(Math.abs(place[i] - oldPlace[i])));
|
|
42643
43553
|
}
|
|
42644
43554
|
return test;
|
|
42645
43555
|
}
|
|
@@ -42785,11 +43695,11 @@ function deleteCMajEnvVPSC(e) {
|
|
|
42785
43695
|
}
|
|
42786
43696
|
|
|
42787
43697
|
// src/layout/neato/stress-cola.ts
|
|
42788
|
-
var
|
|
43698
|
+
var fr11 = Math.fround;
|
|
42789
43699
|
var LOCAL_CONSTR_MAJOR_ITERATIONS2 = 1e3;
|
|
42790
43700
|
var FLT_MAX4 = 34028234663852886e22;
|
|
42791
|
-
var CLUSTER_WEIGHT_FLOOR =
|
|
42792
|
-
var
|
|
43701
|
+
var CLUSTER_WEIGHT_FLOOR = fr11(0.01);
|
|
43702
|
+
var STRESS_GUARD2 = 1e-10;
|
|
42793
43703
|
var NSIZE_SCALE_STEP = 0.1;
|
|
42794
43704
|
var NSIZE_SCALE_LIMIT = 0.999;
|
|
42795
43705
|
var NSIZE_SCALE_ACTIVE = 1e-3;
|
|
@@ -42800,7 +43710,7 @@ function maxEdgeLength(graph, n) {
|
|
|
42800
43710
|
let maxEdgeLen = 0;
|
|
42801
43711
|
for (let i = 0; i < n; i++) {
|
|
42802
43712
|
for (let j = 1; j < graph[i].nedges; j++) {
|
|
42803
|
-
maxEdgeLen =
|
|
43713
|
+
maxEdgeLen = fr11(Math.max(graph[i].ewgts[j], maxEdgeLen));
|
|
42804
43714
|
}
|
|
42805
43715
|
}
|
|
42806
43716
|
return maxEdgeLen;
|
|
@@ -42852,8 +43762,8 @@ function clusterLaplacian(lap2, n, nclusters, maxEdgeLen) {
|
|
|
42852
43762
|
if (i < n && j < n - i) {
|
|
42853
43763
|
v = lap2[c0++];
|
|
42854
43764
|
} else if (j === 1 && i % 2 === 1) {
|
|
42855
|
-
v =
|
|
42856
|
-
if (v > CLUSTER_WEIGHT_FLOOR) v =
|
|
43765
|
+
v = fr11(maxEdgeLen * maxEdgeLen);
|
|
43766
|
+
if (v > CLUSTER_WEIGHT_FLOOR) v = fr11(1 / v);
|
|
42857
43767
|
} else {
|
|
42858
43768
|
v = 0;
|
|
42859
43769
|
}
|
|
@@ -42911,7 +43821,7 @@ function colaState(Dij, origN, dCoords, o, maxEdgeLen) {
|
|
|
42911
43821
|
degrees,
|
|
42912
43822
|
coords: floatCoords(dCoords, o.dim, n, origN),
|
|
42913
43823
|
/* compute constant term in stress sum which is \sum_{i<j} w_{ij}d_{ij}^2 */
|
|
42914
|
-
constantTerm:
|
|
43824
|
+
constantTerm: fr11(n * (n - 1) / 2),
|
|
42915
43825
|
b: Array.from({ length: o.dim }, () => new Float32Array(n)),
|
|
42916
43826
|
tmpCoords: new Float32Array(n),
|
|
42917
43827
|
distAccumulator: new Float32Array(n)
|
|
@@ -42943,7 +43853,7 @@ function buildLap13(st) {
|
|
|
42943
43853
|
count++;
|
|
42944
43854
|
let degree = 0;
|
|
42945
43855
|
for (let j = 0; j < len; j++, count++) {
|
|
42946
|
-
const val2 = lap1[count] =
|
|
43856
|
+
const val2 = lap1[count] = fr11(lap1[count] * st.distAccumulator[j]);
|
|
42947
43857
|
degree += val2;
|
|
42948
43858
|
degrees[i + j + 1] = degrees[i + j + 1] - val2;
|
|
42949
43859
|
}
|
|
@@ -42978,7 +43888,7 @@ var overlapDue = (opt, nsizeScale) => opt.noverlap === NOVERLAP_CONSTRAINTS && n
|
|
|
42978
43888
|
function solveHorizontal(st, e, nsizeScale, opt) {
|
|
42979
43889
|
if (overlapDue(opt, nsizeScale)) {
|
|
42980
43890
|
generateNonoverlapConstraints(e, {
|
|
42981
|
-
nsizeScale:
|
|
43891
|
+
nsizeScale: fr11(nsizeScale),
|
|
42982
43892
|
coords: st.coords,
|
|
42983
43893
|
k: 0,
|
|
42984
43894
|
transitiveClosure: nsizeScale >= TRANSITIVE_CLOSURE_SCALE,
|
|
@@ -42997,7 +43907,7 @@ function solveHorizontal(st, e, nsizeScale, opt) {
|
|
|
42997
43907
|
}
|
|
42998
43908
|
function solveVertical(st, e, nsizeScale, opt) {
|
|
42999
43909
|
if (overlapDue(opt, nsizeScale)) {
|
|
43000
|
-
generateNonoverlapConstraints(e, { nsizeScale:
|
|
43910
|
+
generateNonoverlapConstraints(e, { nsizeScale: fr11(nsizeScale), coords: st.coords, k: 1, transitiveClosure: false, opt });
|
|
43001
43911
|
}
|
|
43002
43912
|
if (e.m > 0) {
|
|
43003
43913
|
if (constrainedMajorizationVpsc(e, st.b[1], st.coords[1], LOCAL_CONSTR_MAJOR_ITERATIONS2) < 0) return -1;
|
|
@@ -43006,13 +43916,13 @@ function solveVertical(st, e, nsizeScale, opt) {
|
|
|
43006
43916
|
}
|
|
43007
43917
|
return 0;
|
|
43008
43918
|
}
|
|
43009
|
-
function
|
|
43919
|
+
function iterate2(st, envs, o, observe) {
|
|
43010
43920
|
const s = { iterations: 0, converged: false, oldStress: Number.MAX_VALUE, nsizeScale: 0 };
|
|
43011
43921
|
for (; s.iterations < o.maxi && !s.converged; s.iterations++) {
|
|
43012
43922
|
buildLap13(st);
|
|
43013
43923
|
const newStress = computeStress2(st);
|
|
43014
43924
|
observe?.(newStress);
|
|
43015
|
-
s.converged = newStress < s.oldStress && Math.abs(newStress - s.oldStress) / Math.abs(s.oldStress +
|
|
43925
|
+
s.converged = newStress < s.oldStress && Math.abs(newStress - s.oldStress) / Math.abs(s.oldStress + STRESS_GUARD2) < o.epsilon;
|
|
43016
43926
|
s.oldStress = newStress;
|
|
43017
43927
|
scaleUpNodes(s, o.maxi, o.opt);
|
|
43018
43928
|
if (solveHorizontal(st, envs.hor, s.nsizeScale, o.opt) < 0) return -1;
|
|
@@ -43026,7 +43936,7 @@ function optimize(st, graph, o, observe) {
|
|
|
43026
43936
|
const vrt = initCMajVPSC(st.n, st.lap2, graph, o.opt, o.opt.diredges);
|
|
43027
43937
|
if (vrt === null) return -1;
|
|
43028
43938
|
st.lap1 = new Float32Array(st.lapLength);
|
|
43029
|
-
const iterations =
|
|
43939
|
+
const iterations = iterate2(st, { hor, vrt }, o, observe);
|
|
43030
43940
|
if (iterations < 0) return iterations;
|
|
43031
43941
|
deleteCMajEnvVPSC(hor);
|
|
43032
43942
|
deleteCMajEnvVPSC(vrt);
|
|
@@ -43131,7 +44041,7 @@ function realEdges(de) {
|
|
|
43131
44041
|
function isNewEdge(de) {
|
|
43132
44042
|
return de.info.alg === void 0;
|
|
43133
44043
|
}
|
|
43134
|
-
function
|
|
44044
|
+
function addEdge3(de, e) {
|
|
43135
44045
|
const el = de.info.alg;
|
|
43136
44046
|
if (el === void 0) {
|
|
43137
44047
|
de.info.alg = [e];
|
|
@@ -43679,10 +44589,10 @@ var Cdt = class {
|
|
|
43679
44589
|
}
|
|
43680
44590
|
/** gts_point_locate (guess=NULL): closest_face + barycenter walk. */
|
|
43681
44591
|
pointLocate(x, y) {
|
|
43682
|
-
const
|
|
43683
|
-
if (
|
|
43684
|
-
const [bx, by] = this.barycenter(
|
|
43685
|
-
return this.pointLocateWalk(bx, by, x, y,
|
|
44592
|
+
const guess2 = this.closestFace(x, y);
|
|
44593
|
+
if (guess2 === null) return null;
|
|
44594
|
+
const [bx, by] = this.barycenter(guess2);
|
|
44595
|
+
return this.pointLocateWalk(bx, by, x, y, guess2);
|
|
43686
44596
|
}
|
|
43687
44597
|
// -------------------------------------------------------------------
|
|
43688
44598
|
// Delaunay insertion (cdt.c: swap_if_in_circle, add_vertex_to_face)
|
|
@@ -47559,10 +48469,19 @@ var SMOOTHING_NONE = 0;
|
|
|
47559
48469
|
var INT_MAX2 = 2147483647;
|
|
47560
48470
|
var ELSCHEME_PENALTY2 = 2;
|
|
47561
48471
|
var EDGE_LABEL_NODE_PREFIX = "|edgelabel|";
|
|
48472
|
+
function sfdpInitDim(g) {
|
|
48473
|
+
const root = g.root;
|
|
48474
|
+
const outdim = lateInt(aggetGraph(g, "dimen"), DFLT_DIM, 2);
|
|
48475
|
+
const ndim = Math.min(lateInt(aggetGraph(g, "dim"), outdim, 2), MAXDIM);
|
|
48476
|
+
root.info.ndim = ndim;
|
|
48477
|
+
root.info.odim = Math.min(outdim, ndim);
|
|
48478
|
+
return ndim;
|
|
48479
|
+
}
|
|
47562
48480
|
function sfdpInitGraph(g) {
|
|
47563
48481
|
setEdgeTypeFromAttr(g, EDGETYPE_LINE);
|
|
48482
|
+
const ndim = sfdpInitDim(g);
|
|
47564
48483
|
commonInitNodeEdge(g);
|
|
47565
|
-
for (const n of g.nodes.values()) neatoInitNode(n);
|
|
48484
|
+
for (const n of g.nodes.values()) neatoInitNode(n, ndim);
|
|
47566
48485
|
const measurer = layoutMeasurer(g);
|
|
47567
48486
|
if (measurer !== void 0) {
|
|
47568
48487
|
for (const n of g.nodes.values()) {
|
|
@@ -47679,12 +48598,12 @@ function makeMatrix(g) {
|
|
|
47679
48598
|
MATRIX_TYPE_REAL
|
|
47680
48599
|
);
|
|
47681
48600
|
}
|
|
47682
|
-
function getSizes(g, pad) {
|
|
47683
|
-
const sizes = new Array(
|
|
48601
|
+
function getSizes(g, pad, ndim = DFLT_DIM) {
|
|
48602
|
+
const sizes = new Array(ndim * g.nodes.size).fill(0);
|
|
47684
48603
|
for (const n of g.nodes.values()) {
|
|
47685
48604
|
const i = n.info.id;
|
|
47686
|
-
sizes[i *
|
|
47687
|
-
sizes[i *
|
|
48605
|
+
sizes[i * ndim] = (n.info.width ?? 0) * 0.5 + pad.x;
|
|
48606
|
+
sizes[i * ndim + 1] = (n.info.height ?? 0) * 0.5 + pad.y;
|
|
47688
48607
|
}
|
|
47689
48608
|
return sizes;
|
|
47690
48609
|
}
|
|
@@ -47708,8 +48627,6 @@ function getPos(g, dim) {
|
|
|
47708
48627
|
return pos;
|
|
47709
48628
|
}
|
|
47710
48629
|
function sfdpCleanup(g) {
|
|
47711
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
47712
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
47713
48630
|
for (const n of g.nodes.values()) {
|
|
47714
48631
|
n.info.pos = void 0;
|
|
47715
48632
|
n.info.id = void 0;
|
|
@@ -48618,7 +49535,7 @@ var AM_PORTHOYX = 12;
|
|
|
48618
49535
|
var SCALE = 10;
|
|
48619
49536
|
var SCALE2 = SCALE / 2;
|
|
48620
49537
|
var INT_MAX3 = 2147483647;
|
|
48621
|
-
var
|
|
49538
|
+
var POINTS_PER_INCH6 = 72;
|
|
48622
49539
|
function cmpitem(a, b) {
|
|
48623
49540
|
if (a < b) return -1;
|
|
48624
49541
|
if (a > b) return 1;
|
|
@@ -48846,18 +49763,18 @@ function overlaps(p) {
|
|
|
48846
49763
|
return false;
|
|
48847
49764
|
}
|
|
48848
49765
|
function initItem(n, margin) {
|
|
48849
|
-
const x = cround(SCALE * (n.info.pos?.[0] ?? 0) *
|
|
48850
|
-
const y = cround(SCALE * (n.info.pos?.[1] ?? 0) *
|
|
49766
|
+
const x = cround(SCALE * (n.info.pos?.[0] ?? 0) * POINTS_PER_INCH6);
|
|
49767
|
+
const y = cround(SCALE * (n.info.pos?.[1] ?? 0) * POINTS_PER_INCH6);
|
|
48851
49768
|
const width2 = n.info.width ?? 0;
|
|
48852
49769
|
const height2 = n.info.height ?? 0;
|
|
48853
49770
|
let w2;
|
|
48854
49771
|
let h2;
|
|
48855
49772
|
if (margin.doAdd) {
|
|
48856
|
-
w2 = d2i(SCALE * (cround(width2 / 2 *
|
|
48857
|
-
h2 = d2i(SCALE * (cround(height2 / 2 *
|
|
49773
|
+
w2 = d2i(SCALE * (cround(width2 / 2 * POINTS_PER_INCH6) + margin.x));
|
|
49774
|
+
h2 = d2i(SCALE * (cround(height2 / 2 * POINTS_PER_INCH6) + margin.y));
|
|
48858
49775
|
} else {
|
|
48859
|
-
w2 = cround(margin.x * SCALE2 * width2 *
|
|
48860
|
-
h2 = cround(margin.y * SCALE2 * height2 *
|
|
49776
|
+
w2 = cround(margin.x * SCALE2 * width2 * POINTS_PER_INCH6);
|
|
49777
|
+
h2 = cround(margin.y * SCALE2 * height2 * POINTS_PER_INCH6);
|
|
48861
49778
|
}
|
|
48862
49779
|
return {
|
|
48863
49780
|
val: 0,
|
|
@@ -48892,8 +49809,8 @@ function cAdjust(g, mode) {
|
|
|
48892
49809
|
if (!overlaps(nlist)) return 0;
|
|
48893
49810
|
runPlan(g, nlist, PLANS.get(mode) ?? PLANS.get(AM_PORTHO));
|
|
48894
49811
|
for (const p of nlist) {
|
|
48895
|
-
const x = p.pos.x /
|
|
48896
|
-
const y = p.pos.y /
|
|
49812
|
+
const x = p.pos.x / POINTS_PER_INCH6 / SCALE;
|
|
49813
|
+
const y = p.pos.y / POINTS_PER_INCH6 / SCALE;
|
|
48897
49814
|
if (p.np.info.pos) {
|
|
48898
49815
|
p.np.info.pos[0] = x;
|
|
48899
49816
|
p.np.info.pos[1] = y;
|
|
@@ -48908,10 +49825,10 @@ function cAdjust(g, mode) {
|
|
|
48908
49825
|
var POLY_BOX = 1;
|
|
48909
49826
|
var POLY_CIRCLE = 2;
|
|
48910
49827
|
var DFLT_SAMPLE2 = 20;
|
|
48911
|
-
var
|
|
49828
|
+
var POINTS_PER_INCH7 = 72;
|
|
48912
49829
|
var MIN_SAMPLES = 3;
|
|
48913
49830
|
function ps2inch2(a) {
|
|
48914
|
-
return a /
|
|
49831
|
+
return a / POINTS_PER_INCH7;
|
|
48915
49832
|
}
|
|
48916
49833
|
function isBoxKind(p) {
|
|
48917
49834
|
return (p.kind & POLY_BOX) !== 0;
|
|
@@ -49204,7 +50121,7 @@ function polyOverlap(p, pp, q, qp) {
|
|
|
49204
50121
|
// src/layout/neato/adjust-info.ts
|
|
49205
50122
|
var DEFAULT_VORO_MARGIN = 0.05;
|
|
49206
50123
|
var INCR = 0.05;
|
|
49207
|
-
var
|
|
50124
|
+
var POINTS_PER_INCH8 = 72;
|
|
49208
50125
|
function newInfoState() {
|
|
49209
50126
|
return {
|
|
49210
50127
|
nodeInfo: [],
|
|
@@ -49259,8 +50176,8 @@ function chkBoundBox(st, graph) {
|
|
|
49259
50176
|
function makeInfo(st, graph) {
|
|
49260
50177
|
const pmargin = { ...sepFactor(graph) };
|
|
49261
50178
|
if (pmargin.doAdd) {
|
|
49262
|
-
pmargin.x /=
|
|
49263
|
-
pmargin.y /=
|
|
50179
|
+
pmargin.x /= POINTS_PER_INCH8;
|
|
50180
|
+
pmargin.y /= POINTS_PER_INCH8;
|
|
49264
50181
|
}
|
|
49265
50182
|
const polyf = pmargin.doAdd ? makeAddPoly : makePoly;
|
|
49266
50183
|
const info = [];
|
|
@@ -49394,7 +50311,7 @@ function sAdjustGraph(g) {
|
|
|
49394
50311
|
}
|
|
49395
50312
|
|
|
49396
50313
|
// src/layout/neato/vpsc-adjust.ts
|
|
49397
|
-
var
|
|
50314
|
+
var POINTS_PER_INCH9 = 72;
|
|
49398
50315
|
function noClusters() {
|
|
49399
50316
|
return {
|
|
49400
50317
|
nvars: 0,
|
|
@@ -49420,21 +50337,30 @@ function vpscAdjust(g) {
|
|
|
49420
50337
|
noverlap: 2,
|
|
49421
50338
|
clusters: noClusters(),
|
|
49422
50339
|
gap: {
|
|
49423
|
-
x: 2 * ((margin.doAdd ? margin.x : DFLT_MARGIN) /
|
|
49424
|
-
y: 2 * ((margin.doAdd ? margin.y : DFLT_MARGIN) /
|
|
50340
|
+
x: 2 * ((margin.doAdd ? margin.x : DFLT_MARGIN) / POINTS_PER_INCH9),
|
|
50341
|
+
y: 2 * ((margin.doAdd ? margin.y : DFLT_MARGIN) / POINTS_PER_INCH9)
|
|
49425
50342
|
},
|
|
49426
50343
|
nsize: nodes.map((n) => ({ x: n.info.width, y: n.info.height }))
|
|
49427
50344
|
};
|
|
49428
50345
|
removeoverlaps(nodes.length, coords, opt);
|
|
49429
50346
|
nodes.forEach((n, j) => {
|
|
49430
|
-
n.info.pos =
|
|
50347
|
+
n.info.pos[0] = coords[0][j];
|
|
50348
|
+
n.info.pos[1] = coords[1][j];
|
|
49431
50349
|
});
|
|
49432
50350
|
return 0;
|
|
49433
50351
|
}
|
|
49434
50352
|
|
|
49435
50353
|
// src/layout/neato/fdp-adjust.ts
|
|
49436
50354
|
var DFLT_MARGIN2 = 4;
|
|
49437
|
-
|
|
50355
|
+
function sizesByNdim(sizes2, ndim) {
|
|
50356
|
+
if (ndim === 2) return sizes2;
|
|
50357
|
+
const sizes = new Array(sizes2.length / 2 * ndim).fill(0);
|
|
50358
|
+
for (let i = 0; i < sizes2.length / 2; i++) {
|
|
50359
|
+
sizes[i * ndim] = sizes2[i * 2];
|
|
50360
|
+
sizes[i * ndim + 1] = sizes2[i * 2 + 1];
|
|
50361
|
+
}
|
|
50362
|
+
return sizes;
|
|
50363
|
+
}
|
|
49438
50364
|
function mapBoolDflt(p, defaultValue) {
|
|
49439
50365
|
if (p === void 0 || p === "") return defaultValue;
|
|
49440
50366
|
const s = p.toLowerCase();
|
|
@@ -49476,14 +50402,14 @@ function overlapPrismTries(flag) {
|
|
|
49476
50402
|
}
|
|
49477
50403
|
function fdpAdjust(g, ntry) {
|
|
49478
50404
|
const A0 = makeMatrix(g);
|
|
49479
|
-
const
|
|
50405
|
+
const ndim = ndimOf(g);
|
|
50406
|
+
const pos = new Array(ndim * g.nodes.size).fill(0);
|
|
49480
50407
|
const sep = sepFactor(g);
|
|
49481
50408
|
const pad = sep.doAdd ? { x: sep.x / 72, y: sep.y / 72 } : { x: DFLT_MARGIN2 / 72, y: DFLT_MARGIN2 / 72 };
|
|
49482
|
-
const sizes = getSizes(g, pad);
|
|
50409
|
+
const sizes = sizesByNdim(getSizes(g, pad), ndim);
|
|
49483
50410
|
for (const n of g.nodes.values()) {
|
|
49484
50411
|
const i = n.info.id;
|
|
49485
|
-
pos[i *
|
|
49486
|
-
pos[i * NDIM2 + 1] = n.info.pos?.[1] ?? 0;
|
|
50412
|
+
for (let k = 0; k < ndim; k++) pos[i * ndim + k] = n.info.pos?.[k] ?? 0;
|
|
49487
50413
|
}
|
|
49488
50414
|
const A3 = !smIsSymmetric(A0, false) || A0.type !== MATRIX_TYPE_REAL ? smGetRealAdjacencySymmetrized(A0) : smRemoveDiagonal(A0);
|
|
49489
50415
|
const scaling = lateDouble(
|
|
@@ -49495,12 +50421,11 @@ function fdpAdjust(g, ntry) {
|
|
|
49495
50421
|
g.attrs.get("overlap_shrink") ?? g.root.attrs.get("overlap_shrink"),
|
|
49496
50422
|
true
|
|
49497
50423
|
);
|
|
49498
|
-
removeOverlapPrism(
|
|
50424
|
+
removeOverlapPrism(ndim, A3, pos, sizes, ntry, scaling, doShrinking);
|
|
49499
50425
|
for (const n of g.nodes.values()) {
|
|
49500
50426
|
const i = n.info.id;
|
|
49501
50427
|
if (!n.info.pos) n.info.pos = [0, 0];
|
|
49502
|
-
n.info.pos[
|
|
49503
|
-
n.info.pos[1] = pos[i * NDIM2 + 1];
|
|
50428
|
+
for (let k = 0; k < ndim; k++) n.info.pos[k] = pos[i * ndim + k];
|
|
49504
50429
|
}
|
|
49505
50430
|
}
|
|
49506
50431
|
var AM_NONE = 0;
|
|
@@ -49594,9 +50519,9 @@ function graphAdjustMode(g) {
|
|
|
49594
50519
|
}
|
|
49595
50520
|
|
|
49596
50521
|
// src/layout/neato/ipsep-opts.ts
|
|
49597
|
-
var
|
|
50522
|
+
var POINTS_PER_INCH10 = 72;
|
|
49598
50523
|
var HIER_PREFIX = "hier";
|
|
49599
|
-
var ps2inch3 = (points2) => points2 /
|
|
50524
|
+
var ps2inch3 = (points2) => points2 / POINTS_PER_INCH10;
|
|
49600
50525
|
var zeroBox = () => ({ ll: { x: 0, y: 0 }, ur: { x: 0, y: 0 } });
|
|
49601
50526
|
function memberIndices(subg, nodes) {
|
|
49602
50527
|
const members = nodesInSeq(subg);
|
|
@@ -49675,19 +50600,8 @@ function ipsepOptions(mg, g, nodes, am) {
|
|
|
49675
50600
|
return { diredges, edgeGap, noverlap, gap, nsize, clusters };
|
|
49676
50601
|
}
|
|
49677
50602
|
|
|
49678
|
-
// src/common/utils-inputscale.ts
|
|
49679
|
-
var POINTS_PER_INCH9 = 72;
|
|
49680
|
-
function getInputscale(g) {
|
|
49681
|
-
const d = lateDouble(g.root.attrs.get("inputscale"), -1, 0);
|
|
49682
|
-
return d === 0 ? POINTS_PER_INCH9 : d;
|
|
49683
|
-
}
|
|
49684
|
-
function inputscaleDivisor(g) {
|
|
49685
|
-
const sc = getInputscale(g);
|
|
49686
|
-
return sc > 0 ? sc : 1;
|
|
49687
|
-
}
|
|
49688
|
-
|
|
49689
50603
|
// src/layout/neato/set-aspect.ts
|
|
49690
|
-
var
|
|
50604
|
+
var POINTS_PER_INCH11 = 72;
|
|
49691
50605
|
function neatoRatioKind(g) {
|
|
49692
50606
|
const p = g.attrs.get("ratio");
|
|
49693
50607
|
if (p === void 0) return null;
|
|
@@ -49735,8 +50649,8 @@ function neatoTranslate(g) {
|
|
|
49735
50649
|
const bb = g.info.bb;
|
|
49736
50650
|
if (!bb) return;
|
|
49737
50651
|
const ll = bb.ll;
|
|
49738
|
-
const ox = ll.x /
|
|
49739
|
-
const oy = ll.y /
|
|
50652
|
+
const ox = ll.x / POINTS_PER_INCH11;
|
|
50653
|
+
const oy = ll.y / POINTS_PER_INCH11;
|
|
49740
50654
|
for (const n of g.nodes.values()) {
|
|
49741
50655
|
if (!n.info.pos) n.info.pos = [0, 0];
|
|
49742
50656
|
n.info.pos[0] = (n.info.pos[0] ?? 0) - ox;
|
|
@@ -49821,8 +50735,7 @@ var MODEL_SHORTPATH2 = 0;
|
|
|
49821
50735
|
var MODEL_CIRCUIT2 = 1;
|
|
49822
50736
|
var MODEL_SUBSET2 = 2;
|
|
49823
50737
|
var MODEL_MDS2 = 3;
|
|
49824
|
-
var
|
|
49825
|
-
var POINTS_PER_INCH11 = 72;
|
|
50738
|
+
var POINTS_PER_INCH12 = 72;
|
|
49826
50739
|
function neatoInitNode(n, dim = DFLT_DIM) {
|
|
49827
50740
|
if (!n.info.pos || n.info.pos.length < dim) {
|
|
49828
50741
|
const pos = [];
|
|
@@ -49834,19 +50747,6 @@ function neatoInitNode(n, dim = DFLT_DIM) {
|
|
|
49834
50747
|
if (!n.info.width && !plainShaped) n.info.width = 0.75;
|
|
49835
50748
|
if (!n.info.height && !plainShaped) n.info.height = 0.5;
|
|
49836
50749
|
}
|
|
49837
|
-
function userPos(n) {
|
|
49838
|
-
const p = n.attrs.get("pos");
|
|
49839
|
-
if (p === void 0 || p.length === 0) return false;
|
|
49840
|
-
const num2 = "(-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)";
|
|
49841
|
-
const m = new RegExp(`^\\s*${num2}\\s*,\\s*${num2}(.?)`).exec(p);
|
|
49842
|
-
if (m === null) return false;
|
|
49843
|
-
const div = inputscaleDivisor(n.root);
|
|
49844
|
-
n.info.pos = [Number(m[1]) / div, Number(m[2]) / div];
|
|
49845
|
-
n.info.posSet = true;
|
|
49846
|
-
const pin = n.attrs.get("pin");
|
|
49847
|
-
if (m[3] === "!" || pin !== void 0 && mapbool(pin)) n.info.pinned = true;
|
|
49848
|
-
return true;
|
|
49849
|
-
}
|
|
49850
50750
|
function assignNodeIds2(g) {
|
|
49851
50751
|
const nodeList = [];
|
|
49852
50752
|
let idx = 0;
|
|
@@ -49866,10 +50766,11 @@ function solveStress(c, vtx, dCoords, nodeList) {
|
|
|
49866
50766
|
const { g, mode, model, opts } = c;
|
|
49867
50767
|
const n = nodeList.length;
|
|
49868
50768
|
const maxi = neatoMaxIter(g.attrs.get("maxiter"), mode, n);
|
|
50769
|
+
const dim = ndimOf(g);
|
|
49869
50770
|
const epsilon = lateDouble(g.attrs.get("epsilon"), 1e-4, 0);
|
|
49870
50771
|
if (mode === MODE_HIER) {
|
|
49871
50772
|
return stressMajorizationWithHierarchy(vtx, n, dCoords, nodeList, {
|
|
49872
|
-
dim
|
|
50773
|
+
dim,
|
|
49873
50774
|
opts,
|
|
49874
50775
|
model,
|
|
49875
50776
|
maxi,
|
|
@@ -49880,7 +50781,7 @@ function solveStress(c, vtx, dCoords, nodeList) {
|
|
|
49880
50781
|
if (mode === MODE_IPSEP) {
|
|
49881
50782
|
const opt = ipsepOptions(g.root, g, nodeList, c.am);
|
|
49882
50783
|
return stressMajorizationCola(vtx, n, dCoords, nodeList, {
|
|
49883
|
-
dim
|
|
50784
|
+
dim,
|
|
49884
50785
|
model,
|
|
49885
50786
|
maxi,
|
|
49886
50787
|
epsilon,
|
|
@@ -49889,7 +50790,7 @@ function solveStress(c, vtx, dCoords, nodeList) {
|
|
|
49889
50790
|
}
|
|
49890
50791
|
const Dij = stressModelDij(vtx, n, model);
|
|
49891
50792
|
return stressMajorizationKDMkernel(Dij, n, dCoords, nodeList, {
|
|
49892
|
-
dim
|
|
50793
|
+
dim,
|
|
49893
50794
|
opts,
|
|
49894
50795
|
maxi,
|
|
49895
50796
|
epsilon
|
|
@@ -49904,13 +50805,14 @@ function runMajorization(g, mode, model, am) {
|
|
|
49904
50805
|
const opts = checkExp(g) | (init === INIT_SELF ? OPT_SMART_INIT : 0);
|
|
49905
50806
|
const haveDir = mode === MODE_HIER || mode === MODE_IPSEP;
|
|
49906
50807
|
const vtx = makeGraphDataC(g, nodeList, haveLen, haveDir, mode);
|
|
49907
|
-
const
|
|
50808
|
+
const ndim = ndimOf(g);
|
|
50809
|
+
const dCoords = Array.from({ length: ndim }, () => new Float64Array(n));
|
|
49908
50810
|
if (solveStress({ g, mode, model, opts, am }, vtx, dCoords, nodeList) < 0) {
|
|
49909
50811
|
agerr("prev", "layout aborted");
|
|
49910
50812
|
return;
|
|
49911
50813
|
}
|
|
49912
50814
|
for (let i = 0; i < n; i++) {
|
|
49913
|
-
nodeList[i].info.pos =
|
|
50815
|
+
nodeList[i].info.pos = dCoords.map((c) => c[i]);
|
|
49914
50816
|
}
|
|
49915
50817
|
}
|
|
49916
50818
|
var NO_ADJUST = { mode: AM_NONE, print: "none", value: 0 };
|
|
@@ -49933,14 +50835,12 @@ function neatoSetAspect(g) {
|
|
|
49933
50835
|
const pos = n.info.pos;
|
|
49934
50836
|
if (!pos) continue;
|
|
49935
50837
|
n.info.coord = {
|
|
49936
|
-
x: (pos[0] ?? 0) *
|
|
49937
|
-
y: (pos[1] ?? 0) *
|
|
50838
|
+
x: (pos[0] ?? 0) * POINTS_PER_INCH12,
|
|
50839
|
+
y: (pos[1] ?? 0) * POINTS_PER_INCH12
|
|
49938
50840
|
};
|
|
49939
50841
|
}
|
|
49940
50842
|
}
|
|
49941
50843
|
function neatoCleanup(g) {
|
|
49942
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
49943
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
49944
50844
|
for (const [, n] of g.nodes) {
|
|
49945
50845
|
n.info.pos = void 0;
|
|
49946
50846
|
n.info.pinned = void 0;
|
|
@@ -49952,7 +50852,7 @@ function neatoCleanup(g) {
|
|
|
49952
50852
|
}
|
|
49953
50853
|
|
|
49954
50854
|
// src/layout/twopi/init.ts
|
|
49955
|
-
var
|
|
50855
|
+
var POINTS_PER_INCH13 = 72;
|
|
49956
50856
|
function makeRdata(INF) {
|
|
49957
50857
|
return {
|
|
49958
50858
|
kind: "twopi",
|
|
@@ -50004,8 +50904,8 @@ function finaliseCoords(g) {
|
|
|
50004
50904
|
const pos = n.info.pos;
|
|
50005
50905
|
if (!pos) continue;
|
|
50006
50906
|
n.info.coord = {
|
|
50007
|
-
x: (pos[0] ?? 0) *
|
|
50008
|
-
y: (pos[1] ?? 0) *
|
|
50907
|
+
x: (pos[0] ?? 0) * POINTS_PER_INCH13,
|
|
50908
|
+
y: (pos[1] ?? 0) * POINTS_PER_INCH13
|
|
50009
50909
|
};
|
|
50010
50910
|
}
|
|
50011
50911
|
}
|
|
@@ -50020,8 +50920,6 @@ function twopiFreeAlg(g) {
|
|
|
50020
50920
|
}
|
|
50021
50921
|
function twopiCleanup(g) {
|
|
50022
50922
|
if (g.nodes.size === 0) return;
|
|
50023
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
50024
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
50025
50923
|
g.info.neato_nlist = void 0;
|
|
50026
50924
|
}
|
|
50027
50925
|
|
|
@@ -50243,7 +51141,10 @@ function circleLayout(sg, center) {
|
|
|
50243
51141
|
if (center === null) center = findCenterNode(sg);
|
|
50244
51142
|
if (center === null) return null;
|
|
50245
51143
|
const maxN = setParentNodes(sg, center);
|
|
50246
|
-
if (maxN === Number.MAX_SAFE_INTEGER)
|
|
51144
|
+
if (maxN === Number.MAX_SAFE_INTEGER) {
|
|
51145
|
+
agerrorf("twopi: use of weight=0 creates disconnected component.");
|
|
51146
|
+
return center;
|
|
51147
|
+
}
|
|
50247
51148
|
setSubtreeSize(sg);
|
|
50248
51149
|
setSubtreeSpans(sg, center);
|
|
50249
51150
|
setPositions(sg, center);
|
|
@@ -50334,18 +51235,21 @@ function parseModel(g) {
|
|
|
50334
51235
|
function maybeRemoveOverlap(g, am) {
|
|
50335
51236
|
removeOverlapWith(g, am);
|
|
50336
51237
|
}
|
|
50337
|
-
function
|
|
50338
|
-
graphInit(g, false);
|
|
50339
|
-
setEdgeTypeFromAttr(g, EDGETYPE_LINE);
|
|
50340
|
-
commonInitNodeEdge(g);
|
|
51238
|
+
function neatoInitNodeEdge(g, ndim) {
|
|
50341
51239
|
for (const [, n] of g.nodes) {
|
|
50342
|
-
neatoInitNode(n);
|
|
50343
|
-
userPos(n);
|
|
51240
|
+
neatoInitNode(n, ndim);
|
|
51241
|
+
userPos(n, ndim, g.nodes.size);
|
|
50344
51242
|
}
|
|
50345
51243
|
const measurer = layoutMeasurer(g);
|
|
50346
51244
|
if (measurer !== void 0) {
|
|
50347
51245
|
for (const e of g.edges) initEdgeLabels(e, g, measurer);
|
|
50348
51246
|
}
|
|
51247
|
+
}
|
|
51248
|
+
function neatoLayout(g) {
|
|
51249
|
+
graphInit(g, false);
|
|
51250
|
+
setEdgeTypeFromAttr(g, EDGETYPE_LINE);
|
|
51251
|
+
commonInitNodeEdge(g);
|
|
51252
|
+
neatoInitNodeEdge(g, neatoInitGraphDim(g));
|
|
50349
51253
|
const mode = parseMode(g);
|
|
50350
51254
|
const am = graphAdjustMode(g);
|
|
50351
51255
|
const model = parseModel(g);
|
|
@@ -50357,6 +51261,7 @@ function neatoLayout(g) {
|
|
|
50357
51261
|
maybeRemoveOverlap(g, am);
|
|
50358
51262
|
splineEdgesShifted(g);
|
|
50359
51263
|
}
|
|
51264
|
+
addZ(g);
|
|
50360
51265
|
addClusters(g);
|
|
50361
51266
|
g.info.bb = computeSubgraphBB(g, 0);
|
|
50362
51267
|
placeGraphLabel(g);
|
|
@@ -50548,127 +51453,6 @@ function initParams(g, xpms) {
|
|
|
50548
51453
|
return ret;
|
|
50549
51454
|
}
|
|
50550
51455
|
|
|
50551
|
-
// src/layout/fdp/cluster-edges.ts
|
|
50552
|
-
function fillMap(g, map) {
|
|
50553
|
-
const n = g.info.n_cluster ?? 0;
|
|
50554
|
-
for (let c = 0; c < n; c++) {
|
|
50555
|
-
const cl = g.info.clust[c];
|
|
50556
|
-
const s = cl.name;
|
|
50557
|
-
if (!map.has(s)) map.set(s, cl);
|
|
50558
|
-
fillMap(cl, map);
|
|
50559
|
-
}
|
|
50560
|
-
}
|
|
50561
|
-
function mkClustMap2(g) {
|
|
50562
|
-
const map = /* @__PURE__ */ new Map();
|
|
50563
|
-
fillMap(g, map);
|
|
50564
|
-
return map;
|
|
50565
|
-
}
|
|
50566
|
-
function mapc(cmap, n) {
|
|
50567
|
-
if (n.name.startsWith("cluster")) return cmap.get(n.name) ?? null;
|
|
50568
|
-
return null;
|
|
50569
|
-
}
|
|
50570
|
-
function edgeKey(t, h) {
|
|
50571
|
-
return `${t.name}\0${h.name}`;
|
|
50572
|
-
}
|
|
50573
|
-
function mapEdge2(map, t, h) {
|
|
50574
|
-
return map.get(edgeKey(t, h));
|
|
50575
|
-
}
|
|
50576
|
-
function insertEdge2(map, t, h, ce) {
|
|
50577
|
-
map.set(edgeKey(t, h), { t: ce.tail, h: ce.head });
|
|
50578
|
-
map.set(edgeKey(h, t), { t: ce.head, h: ce.tail });
|
|
50579
|
-
}
|
|
50580
|
-
function clustNode(n, cg, root, delSet, idx) {
|
|
50581
|
-
const name = `__${idx.v}:${cg.name}`;
|
|
50582
|
-
const cn = agnode(root, name, true);
|
|
50583
|
-
cn.info.clustnode = true;
|
|
50584
|
-
agsubnode(cg, cn, true);
|
|
50585
|
-
delSet.add(n);
|
|
50586
|
-
cn.attrs.set("label", "");
|
|
50587
|
-
cn.attrs.set("style", "invis");
|
|
50588
|
-
cn.attrs.set("shape", "box");
|
|
50589
|
-
return cn;
|
|
50590
|
-
}
|
|
50591
|
-
function cloneEdge2(root, e, ct, ch) {
|
|
50592
|
-
const ce = new Edge(ct, ch, "");
|
|
50593
|
-
for (const [k, v] of e.attrs) ce.attrs.set(k, v);
|
|
50594
|
-
ce.info.compound = 1;
|
|
50595
|
-
root.edges.push(ce);
|
|
50596
|
-
ce.graphSeq = root.edges.length;
|
|
50597
|
-
return ce;
|
|
50598
|
-
}
|
|
50599
|
-
function checkCompound(e, root, cmap, map, delSet, idx) {
|
|
50600
|
-
const t = e.tail;
|
|
50601
|
-
const h = e.head;
|
|
50602
|
-
if (h.info.clustnode) return 0;
|
|
50603
|
-
const tg = mapc(cmap, t);
|
|
50604
|
-
const hg = mapc(cmap, h);
|
|
50605
|
-
if (!tg && !hg) return 0;
|
|
50606
|
-
if (tg === hg) return 0;
|
|
50607
|
-
const ip = mapEdge2(map, t, h);
|
|
50608
|
-
if (ip) {
|
|
50609
|
-
cloneEdge2(root, e, ip.t, ip.h);
|
|
50610
|
-
return 1;
|
|
50611
|
-
}
|
|
50612
|
-
let cn;
|
|
50613
|
-
let ce;
|
|
50614
|
-
if (hg) {
|
|
50615
|
-
if (tg) {
|
|
50616
|
-
if (agContains(hg, tg) || agContains(tg, hg)) return 0;
|
|
50617
|
-
cn = clustNode(t, tg, root, delSet, idx);
|
|
50618
|
-
const cn1 = clustNode(h, hg, root, delSet, idx);
|
|
50619
|
-
ce = cloneEdge2(root, e, cn, cn1);
|
|
50620
|
-
insertEdge2(map, t, h, ce);
|
|
50621
|
-
} else {
|
|
50622
|
-
if (agContainsNode2(hg, t)) return 0;
|
|
50623
|
-
cn = clustNode(h, hg, root, delSet, idx);
|
|
50624
|
-
ce = cloneEdge2(root, e, t, cn);
|
|
50625
|
-
insertEdge2(map, t, h, ce);
|
|
50626
|
-
}
|
|
50627
|
-
} else {
|
|
50628
|
-
if (agContainsNode2(tg, h)) return 0;
|
|
50629
|
-
cn = clustNode(t, tg, root, delSet, idx);
|
|
50630
|
-
ce = cloneEdge2(root, e, cn, h);
|
|
50631
|
-
insertEdge2(map, t, h, ce);
|
|
50632
|
-
}
|
|
50633
|
-
return 1;
|
|
50634
|
-
}
|
|
50635
|
-
function agContains(a, b) {
|
|
50636
|
-
for (let g = b; g !== null; g = g.parent) {
|
|
50637
|
-
if (g === a) return true;
|
|
50638
|
-
}
|
|
50639
|
-
return false;
|
|
50640
|
-
}
|
|
50641
|
-
function agContainsNode2(cg, n) {
|
|
50642
|
-
return cg.nodes.has(n.name);
|
|
50643
|
-
}
|
|
50644
|
-
function deleteNodeAndEdges(root, n) {
|
|
50645
|
-
const purge = (gr) => {
|
|
50646
|
-
if (gr.edges.length > 0) {
|
|
50647
|
-
gr.edges = gr.edges.filter((e) => e.tail !== n && e.head !== n);
|
|
50648
|
-
}
|
|
50649
|
-
gr.nodes.delete(n.name);
|
|
50650
|
-
for (const sg of gr.subgraphs.values()) purge(sg);
|
|
50651
|
-
};
|
|
50652
|
-
purge(root);
|
|
50653
|
-
}
|
|
50654
|
-
function processClusterEdges(g) {
|
|
50655
|
-
const root = g.root;
|
|
50656
|
-
const cmap = mkClustMap2(g);
|
|
50657
|
-
if (cmap.size === 0) return;
|
|
50658
|
-
const map = /* @__PURE__ */ new Map();
|
|
50659
|
-
const delSet = /* @__PURE__ */ new Set();
|
|
50660
|
-
const idx = { v: 0 };
|
|
50661
|
-
let numClEdges = 0;
|
|
50662
|
-
for (const n of [...g.nodes.values()]) {
|
|
50663
|
-
if (n.info.clustnode) continue;
|
|
50664
|
-
for (const e of n.outEdges(g)) {
|
|
50665
|
-
numClEdges += checkCompound(e, root, cmap, map, delSet, idx);
|
|
50666
|
-
}
|
|
50667
|
-
}
|
|
50668
|
-
for (const n of delSet) deleteNodeAndEdges(root, n);
|
|
50669
|
-
if (numClEdges > 0) g.info.n_cluster_edges = numClEdges;
|
|
50670
|
-
}
|
|
50671
|
-
|
|
50672
51456
|
// src/layout/fdp/init.ts
|
|
50673
51457
|
function initialPositions3(g) {
|
|
50674
51458
|
const div = inputscaleDivisor(g);
|
|
@@ -50714,18 +51498,7 @@ function fdpInitNodeEdge(g) {
|
|
|
50714
51498
|
}
|
|
50715
51499
|
initialPositions3(g);
|
|
50716
51500
|
}
|
|
50717
|
-
function fdpCleanupSubgs(g) {
|
|
50718
|
-
const nClust = g.info.n_cluster ?? 0;
|
|
50719
|
-
for (let i = 1; i <= nClust; i++) {
|
|
50720
|
-
const subg = g.info.clust[i - 1];
|
|
50721
|
-
subg.info.label = void 0;
|
|
50722
|
-
fdpCleanupSubgs(subg);
|
|
50723
|
-
}
|
|
50724
|
-
}
|
|
50725
51501
|
function fdpCleanup(g) {
|
|
50726
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
50727
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
50728
|
-
fdpCleanupSubgs(g);
|
|
50729
51502
|
for (const n of g.nodes.values()) {
|
|
50730
51503
|
n.info.alg = void 0;
|
|
50731
51504
|
n.info.pos = void 0;
|
|
@@ -51537,7 +52310,7 @@ function deriveEdges(g, dg, byPair) {
|
|
|
51537
52310
|
dndata(hd).deg++;
|
|
51538
52311
|
dndata(tl).deg++;
|
|
51539
52312
|
}
|
|
51540
|
-
|
|
52313
|
+
addEdge3(de, e);
|
|
51541
52314
|
}
|
|
51542
52315
|
}
|
|
51543
52316
|
}
|
|
@@ -51559,7 +52332,7 @@ function derivePort(g, dg, byPair, port, m) {
|
|
|
51559
52332
|
const de = deriveEdge(dg, byPair, m, dn);
|
|
51560
52333
|
de.info.dist = port.e.info.dist;
|
|
51561
52334
|
de.info.factor = port.e.info.factor;
|
|
51562
|
-
|
|
52335
|
+
addEdge3(de, port.e);
|
|
51563
52336
|
dndata(dn).wdeg++;
|
|
51564
52337
|
dndata(m).wdeg++;
|
|
51565
52338
|
dndata(dn).deg++;
|
|
@@ -51669,7 +52442,7 @@ function expandCluster2(n, cg) {
|
|
|
51669
52442
|
}
|
|
51670
52443
|
|
|
51671
52444
|
// src/layout/fdp/layout.ts
|
|
51672
|
-
var
|
|
52445
|
+
var POINTS_PER_INCH14 = 72;
|
|
51673
52446
|
var DEFAULT_NODEWIDTH_PTS = 54;
|
|
51674
52447
|
var DEFAULT_NODEHEIGHT_PTS = 36;
|
|
51675
52448
|
function initInfo(g) {
|
|
@@ -51764,7 +52537,7 @@ function shiftComponents(cc, pts, pt) {
|
|
|
51764
52537
|
} else {
|
|
51765
52538
|
p = pt;
|
|
51766
52539
|
}
|
|
51767
|
-
const del = { x: p.x /
|
|
52540
|
+
const del = { x: p.x / POINTS_PER_INCH14, y: p.y / POINTS_PER_INCH14 };
|
|
51768
52541
|
for (const n of cc[i].nodes.values()) {
|
|
51769
52542
|
n.info.pos[0] += del.x;
|
|
51770
52543
|
n.info.pos[1] += del.y;
|
|
@@ -51780,8 +52553,8 @@ function finalCC(g, cc, pts, rg, infop) {
|
|
|
51780
52553
|
const pt = applyMarginAndBorder(rg, bb, margin);
|
|
51781
52554
|
if (cc.length > 0) shiftComponents(cc, pts, pt);
|
|
51782
52555
|
gdata(g).bb = {
|
|
51783
|
-
ll: { x: bb.ll.x /
|
|
51784
|
-
ur: { x: bb.ur.x /
|
|
52556
|
+
ll: { x: bb.ll.x / POINTS_PER_INCH14, y: bb.ll.y / POINTS_PER_INCH14 },
|
|
52557
|
+
ur: { x: bb.ur.x / POINTS_PER_INCH14, y: bb.ur.y / POINTS_PER_INCH14 }
|
|
51785
52558
|
};
|
|
51786
52559
|
}
|
|
51787
52560
|
function applyMarginAndBorder(rg, bb, margin) {
|
|
@@ -51827,8 +52600,8 @@ function translateOwnNodes(g, bb) {
|
|
|
51827
52600
|
function setBB(g) {
|
|
51828
52601
|
const bb = gdata(g).bb;
|
|
51829
52602
|
g.info.bb = {
|
|
51830
|
-
ll: { x:
|
|
51831
|
-
ur: { x:
|
|
52603
|
+
ll: { x: POINTS_PER_INCH14 * bb.ll.x, y: POINTS_PER_INCH14 * bb.ll.y },
|
|
52604
|
+
ur: { x: POINTS_PER_INCH14 * bb.ur.x, y: POINTS_PER_INCH14 * bb.ur.y }
|
|
51832
52605
|
};
|
|
51833
52606
|
const nClusters = g.info.n_cluster ?? 0;
|
|
51834
52607
|
for (let i = 0; i < nClusters; i++) {
|
|
@@ -51843,8 +52616,8 @@ function setClustNodes(root) {
|
|
|
51843
52616
|
const bb = gdata(p).bb;
|
|
51844
52617
|
const w = bb.ur.x - bb.ll.x;
|
|
51845
52618
|
const h = bb.ur.y - bb.ll.y;
|
|
51846
|
-
const w2 =
|
|
51847
|
-
const h2 =
|
|
52619
|
+
const w2 = POINTS_PER_INCH14 * (w / 2);
|
|
52620
|
+
const h2 = POINTS_PER_INCH14 * (h / 2);
|
|
51848
52621
|
n.info.pos[0] = w / 2;
|
|
51849
52622
|
n.info.pos[1] = h / 2;
|
|
51850
52623
|
n.info.width = w;
|
|
@@ -51853,7 +52626,7 @@ function setClustNodes(root) {
|
|
|
51853
52626
|
n.info.outline_width = w + penwidth;
|
|
51854
52627
|
n.info.outline_height = h + penwidth;
|
|
51855
52628
|
n.info.lw = n.info.rw = w2;
|
|
51856
|
-
n.info.ht =
|
|
52629
|
+
n.info.ht = POINTS_PER_INCH14 * h;
|
|
51857
52630
|
const poly = n.info.shape_info;
|
|
51858
52631
|
if (poly && poly.vertices) {
|
|
51859
52632
|
poly.vertices[0] = { x: w2, y: h2 };
|
|
@@ -51866,8 +52639,8 @@ function setClustNodes(root) {
|
|
|
51866
52639
|
function syncCoordFromPos(cg) {
|
|
51867
52640
|
for (const n of cg.nodes.values()) {
|
|
51868
52641
|
n.info.coord = {
|
|
51869
|
-
x:
|
|
51870
|
-
y:
|
|
52642
|
+
x: POINTS_PER_INCH14 * n.info.pos[0],
|
|
52643
|
+
y: POINTS_PER_INCH14 * n.info.pos[1]
|
|
51871
52644
|
};
|
|
51872
52645
|
}
|
|
51873
52646
|
}
|
|
@@ -51879,8 +52652,8 @@ function expandComponentClusters(cg, infop, counter) {
|
|
|
51879
52652
|
if (r !== 0) return r;
|
|
51880
52653
|
n.info.width = gdata(sg).bb.ur.x;
|
|
51881
52654
|
n.info.height = gdata(sg).bb.ur.y;
|
|
51882
|
-
const ptx =
|
|
51883
|
-
const pty =
|
|
52655
|
+
const ptx = POINTS_PER_INCH14 * gdata(sg).bb.ur.x;
|
|
52656
|
+
const pty = POINTS_PER_INCH14 * gdata(sg).bb.ur.y;
|
|
51884
52657
|
n.info.rw = n.info.lw = ptx / 2;
|
|
51885
52658
|
n.info.ht = pty;
|
|
51886
52659
|
} else if (isPort(n)) {
|
|
@@ -52444,15 +53217,15 @@ function multilevelSpringElectricalEmbedding(dim, A0, ctrl, labelSizes, x) {
|
|
|
52444
53217
|
}
|
|
52445
53218
|
|
|
52446
53219
|
// src/layout/sfdp/index.ts
|
|
52447
|
-
var DIM = 2;
|
|
52448
53220
|
function sfdpLayoutComponent(g, ctrl, pad) {
|
|
53221
|
+
const ndim = ndimOf(g);
|
|
52449
53222
|
const A3 = makeMatrix(g);
|
|
52450
|
-
const sizes = ctrl.overlap >= 0 ? getSizes(g, pad) : null;
|
|
52451
|
-
const pos = getPos(g,
|
|
52452
|
-
multilevelSpringElectricalEmbedding(
|
|
53223
|
+
const sizes = ctrl.overlap >= 0 ? getSizes(g, pad, ndim) : null;
|
|
53224
|
+
const pos = getPos(g, ndim);
|
|
53225
|
+
multilevelSpringElectricalEmbedding(ndim, A3, ctrl, sizes, pos);
|
|
52453
53226
|
for (const n of g.nodes.values()) {
|
|
52454
53227
|
const i = n.info.id;
|
|
52455
|
-
n.info.pos =
|
|
53228
|
+
n.info.pos = pos.slice(i * ndim, (i + 1) * ndim);
|
|
52456
53229
|
}
|
|
52457
53230
|
}
|
|
52458
53231
|
function resolveControl(g) {
|
|
@@ -52463,7 +53236,8 @@ function resolveControl(g) {
|
|
|
52463
53236
|
const flag = overlap5 === void 0 ? "prism0" : overlap5;
|
|
52464
53237
|
warnUnrecognizedOverlap(flag);
|
|
52465
53238
|
const ntry = overlapPrismTries(flag);
|
|
52466
|
-
|
|
53239
|
+
const doAdjust = ndimOf(g) === 2;
|
|
53240
|
+
if (ntry !== null && doAdjust) {
|
|
52467
53241
|
ctrl.overlap = ntry;
|
|
52468
53242
|
ctrl.initialScaling = lateDouble(
|
|
52469
53243
|
g.root.attrs.get("overlap_scaling"),
|
|
@@ -52478,7 +53252,7 @@ function resolveControl(g) {
|
|
|
52478
53252
|
return { ctrl, pad, doAdjust: false };
|
|
52479
53253
|
}
|
|
52480
53254
|
ctrl.overlap = -1;
|
|
52481
|
-
return { ctrl, pad, doAdjust
|
|
53255
|
+
return { ctrl, pad, doAdjust };
|
|
52482
53256
|
}
|
|
52483
53257
|
function layoutComponents3(g, comps, ctrl, pad, doAdjust) {
|
|
52484
53258
|
const pinfo = {
|
|
@@ -52526,6 +53300,7 @@ function sfdpLayout(g) {
|
|
|
52526
53300
|
} else {
|
|
52527
53301
|
layoutComponents3(g, comps, ctrl, pad, doAdjust);
|
|
52528
53302
|
}
|
|
53303
|
+
for (const c of comps) agdelsubg(g, c);
|
|
52529
53304
|
}
|
|
52530
53305
|
postprocess(g, singleComponent);
|
|
52531
53306
|
}
|
|
@@ -53439,7 +54214,7 @@ function buildDerivedEdges(g, dg) {
|
|
|
53439
54214
|
return edges;
|
|
53440
54215
|
}
|
|
53441
54216
|
function derivedComponents(g, dg, allEdges3) {
|
|
53442
|
-
const comps = ccomps(g);
|
|
54217
|
+
const comps = ccomps(g, null, false);
|
|
53443
54218
|
return comps.map((sg, i) => {
|
|
53444
54219
|
const nodes = [];
|
|
53445
54220
|
for (const n of sg.nodes.values()) {
|
|
@@ -53545,8 +54320,6 @@ function circoLayoutFull(g) {
|
|
|
53545
54320
|
}
|
|
53546
54321
|
function circoCleanup(g) {
|
|
53547
54322
|
if (g.nodes.size === 0) return;
|
|
53548
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
53549
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
53550
54323
|
g.info.alg = void 0;
|
|
53551
54324
|
g.info.neato_nlist = void 0;
|
|
53552
54325
|
}
|
|
@@ -53575,6 +54348,7 @@ function twopiLayout(g) {
|
|
|
53575
54348
|
} else {
|
|
53576
54349
|
layoutMulti(g, comps, globalRoot, buildPackInfo(g));
|
|
53577
54350
|
}
|
|
54351
|
+
for (const c of comps) agdelsubg(g, c);
|
|
53578
54352
|
normalizeGraphBB(g);
|
|
53579
54353
|
placeGraphLabel(g);
|
|
53580
54354
|
gvPostprocess(g);
|
|
@@ -53832,23 +54606,10 @@ function osageLayout(g) {
|
|
|
53832
54606
|
placeGraphLabel(g);
|
|
53833
54607
|
gvPostprocess(g);
|
|
53834
54608
|
}
|
|
53835
|
-
function cleanupGraphs(g) {
|
|
53836
|
-
const nClust = g.info.n_cluster ?? 0;
|
|
53837
|
-
for (let i = 1; i <= nClust; i++) {
|
|
53838
|
-
const subg = g.info.clust[i - 1];
|
|
53839
|
-
subg.info.label = void 0;
|
|
53840
|
-
cleanupGraphs(subg);
|
|
53841
|
-
}
|
|
53842
|
-
g.info.clust = void 0;
|
|
53843
|
-
g.info.n_cluster = void 0;
|
|
53844
|
-
}
|
|
53845
54609
|
function osageCleanup(g) {
|
|
53846
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
53847
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
53848
54610
|
for (const n of g.nodes.values()) {
|
|
53849
54611
|
if (n.info.alg?.kind === "osage") n.info.alg = void 0;
|
|
53850
54612
|
}
|
|
53851
|
-
cleanupGraphs(g);
|
|
53852
54613
|
}
|
|
53853
54614
|
var OSAGE_LAYOUT_ENGINE = {
|
|
53854
54615
|
type: "osage",
|
|
@@ -54196,8 +54957,6 @@ function patchworkEngineLayout(g) {
|
|
|
54196
54957
|
}
|
|
54197
54958
|
function patchworkEngineCleanup(g) {
|
|
54198
54959
|
if (g.nodes.size === 0) return;
|
|
54199
|
-
for (const e of g.edges) gvCleanupEdgeLabels(e);
|
|
54200
|
-
for (const n of g.nodes.values()) gvCleanupNodeLabels(n);
|
|
54201
54960
|
g.info.clust = void 0;
|
|
54202
54961
|
g.info.n_cluster = void 0;
|
|
54203
54962
|
for (const n of g.nodes.values()) {
|
|
@@ -54402,8 +55161,8 @@ var forfunc = (cur, total, init) => (1 - cur / total) * init / 2;
|
|
|
54402
55161
|
var revfunc = (cur, total, init) => cur / total * init / 2;
|
|
54403
55162
|
var nonefunc = (_cur, _total, init) => init / 2;
|
|
54404
55163
|
var bothfunc = (cur, total, init) => {
|
|
54405
|
-
const
|
|
54406
|
-
return
|
|
55164
|
+
const fr12 = cur / total;
|
|
55165
|
+
return fr12 <= 0.5 ? fr12 * init : (1 - fr12) * init;
|
|
54407
55166
|
};
|
|
54408
55167
|
function taperfun(dir, directed) {
|
|
54409
55168
|
if (dir === "forward") return forfunc;
|
|
@@ -55265,6 +56024,15 @@ function trimFixed3(v) {
|
|
|
55265
56024
|
function edgeAttrsAttached(e) {
|
|
55266
56025
|
return e.info.edge_type !== IGNORED && e.info.spl != null;
|
|
55267
56026
|
}
|
|
56027
|
+
function nodePosRaw(n) {
|
|
56028
|
+
const c = n.info.coord;
|
|
56029
|
+
let raw = gfmt5(c.x) + "," + gfmt5(c.y);
|
|
56030
|
+
const odim = n.root.info.odim ?? 2;
|
|
56031
|
+
for (let k = 2; odim >= 3 && k < odim; k++) {
|
|
56032
|
+
raw += "," + gfmt5(POINTS_PER_INCH2 * (n.info.pos?.[k] ?? 0));
|
|
56033
|
+
}
|
|
56034
|
+
return raw;
|
|
56035
|
+
}
|
|
55268
56036
|
function appendRecordRects(n, f, out) {
|
|
55269
56037
|
const c = n.info.coord;
|
|
55270
56038
|
if (f.n_flds === 0) {
|
|
@@ -55736,7 +56504,7 @@ var DotWriterBase = class {
|
|
|
55736
56504
|
nodeAttrs(n, scope) {
|
|
55737
56505
|
const info = n.info;
|
|
55738
56506
|
const defs = effectiveNodeDefaults(scope);
|
|
55739
|
-
const posRaw =
|
|
56507
|
+
const posRaw = nodePosRaw(n);
|
|
55740
56508
|
const widthRaw = gfmt5((info.lw + info.rw) / 72);
|
|
55741
56509
|
const heightRaw = gfmt5(info.ht / 72);
|
|
55742
56510
|
const parts = [
|
|
@@ -55988,13 +56756,13 @@ var EdgeDrawBase = class extends DotWriterBase {
|
|
|
55988
56756
|
};
|
|
55989
56757
|
|
|
55990
56758
|
// src/render/dot/write-back.ts
|
|
55991
|
-
var
|
|
56759
|
+
var POINTS_PER_INCH15 = 72;
|
|
55992
56760
|
function attachNode(n) {
|
|
55993
56761
|
const attrs = ownAttrs(n);
|
|
55994
56762
|
const info = n.info;
|
|
55995
|
-
attrs.set("pos",
|
|
55996
|
-
attrs.set("height", gfmt5(info.ht /
|
|
55997
|
-
attrs.set("width", gfmt5((info.lw + info.rw) /
|
|
56763
|
+
attrs.set("pos", nodePosRaw(n));
|
|
56764
|
+
attrs.set("height", gfmt5(info.ht / POINTS_PER_INCH15));
|
|
56765
|
+
attrs.set("width", gfmt5((info.lw + info.rw) / POINTS_PER_INCH15));
|
|
55998
56766
|
const xlabel = info.xlabel;
|
|
55999
56767
|
if (xlabel?.set) attrs.set("xlp", lpStr(xlabel.pos));
|
|
56000
56768
|
if (info.shape?.name === "record") {
|
|
@@ -56024,8 +56792,8 @@ function recAttachBb(g) {
|
|
|
56024
56792
|
const label = g.info.label;
|
|
56025
56793
|
if (label && label.text.length > 0) {
|
|
56026
56794
|
g.attrs.set("lp", lpStr(label.pos));
|
|
56027
|
-
g.attrs.set("lwidth", gfmt2(label.dimen.x /
|
|
56028
|
-
g.attrs.set("lheight", gfmt2(label.dimen.y /
|
|
56795
|
+
g.attrs.set("lwidth", gfmt2(label.dimen.x / POINTS_PER_INCH15));
|
|
56796
|
+
g.attrs.set("lheight", gfmt2(label.dimen.y / POINTS_PER_INCH15));
|
|
56029
56797
|
}
|
|
56030
56798
|
for (const sg of clustersOf(g)) recAttachBb(sg);
|
|
56031
56799
|
}
|
|
@@ -60172,8 +60940,8 @@ var StmtProcessor = class _StmtProcessor {
|
|
|
60172
60940
|
* @see lib/cgraph/edge.c:agedge:274-275 (`if (e == NULL && agisundirected(g))`)
|
|
60173
60941
|
*/
|
|
60174
60942
|
static strictKey(tail, head, undirected) {
|
|
60175
|
-
const
|
|
60176
|
-
return
|
|
60943
|
+
const swap4 = undirected && head.id < tail.id;
|
|
60944
|
+
return swap4 ? `${head.id}\0${tail.id}` : `${tail.id}\0${head.id}`;
|
|
60177
60945
|
}
|
|
60178
60946
|
/**
|
|
60179
60947
|
* Apply the DOT-syntax `:port:compass` endpoints to an edge's attrs.
|