@knowvah/dot-engine 2.8.1 → 2.10.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/common/graph-init.d.ts.map +1 -1
- package/dist/common/htmltable.d.ts +1 -1
- package/dist/common/htmltable.d.ts.map +1 -1
- package/dist/common/poly-gencode.d.ts.map +1 -1
- package/dist/common/poly-init.d.ts +9 -8
- package/dist/common/poly-init.d.ts.map +1 -1
- package/dist/common/safefile.d.ts +38 -0
- package/dist/common/safefile.d.ts.map +1 -0
- package/dist/common/shapes.d.ts +6 -6
- package/dist/common/shapes.d.ts.map +1 -1
- package/dist/gvc/device.d.ts.map +1 -1
- package/dist/gvc/image-resolver.d.ts +5 -0
- package/dist/gvc/image-resolver.d.ts.map +1 -1
- package/dist/gvc/image-type.d.ts +41 -0
- package/dist/gvc/image-type.d.ts.map +1 -0
- package/dist/gvc/render-usershape.d.ts +8 -0
- package/dist/gvc/render-usershape.d.ts.map +1 -1
- package/dist/gvc/usershape.d.ts +25 -1
- package/dist/gvc/usershape.d.ts.map +1 -1
- package/dist/index.js +9179 -7729
- package/dist/index.js.map +4 -4
- package/dist/layout/neato/__fixtures__/kk-models.d.ts +59 -0
- package/dist/layout/neato/__fixtures__/kk-models.d.ts.map +1 -0
- package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts +124 -0
- package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts.map +1 -0
- package/dist/layout/neato/__fixtures__/stress-models.d.ts +39 -0
- package/dist/layout/neato/__fixtures__/stress-models.d.ts.map +1 -0
- package/dist/layout/neato/circuit.d.ts +48 -0
- package/dist/layout/neato/circuit.d.ts.map +1 -0
- package/dist/layout/neato/constrained-majorization.d.ts.map +1 -1
- package/dist/layout/neato/index.d.ts +6 -3
- package/dist/layout/neato/index.d.ts.map +1 -1
- package/dist/layout/neato/init.d.ts +3 -2
- package/dist/layout/neato/init.d.ts.map +1 -1
- package/dist/layout/neato/ipsep-opts.d.ts +19 -0
- package/dist/layout/neato/ipsep-opts.d.ts.map +1 -0
- package/dist/layout/neato/kk-paths.d.ts +11 -1
- package/dist/layout/neato/kk-paths.d.ts.map +1 -1
- package/dist/layout/neato/kk-solve.d.ts.map +1 -1
- package/dist/layout/neato/kk.d.ts +5 -3
- package/dist/layout/neato/kk.d.ts.map +1 -1
- package/dist/layout/neato/kkutils.d.ts +45 -0
- package/dist/layout/neato/kkutils.d.ts.map +1 -1
- package/dist/layout/neato/lu.d.ts +35 -0
- package/dist/layout/neato/lu.d.ts.map +1 -0
- package/dist/layout/neato/matinv.d.ts +8 -0
- package/dist/layout/neato/matinv.d.ts.map +1 -0
- package/dist/layout/neato/quad-prog-vpsc-overlap.d.ts +35 -0
- package/dist/layout/neato/quad-prog-vpsc-overlap.d.ts.map +1 -0
- package/dist/layout/neato/quad-prog-vpsc.d.ts +110 -0
- package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -0
- package/dist/layout/neato/start.d.ts +11 -9
- package/dist/layout/neato/start.d.ts.map +1 -1
- package/dist/layout/neato/stress-cola.d.ts +65 -0
- package/dist/layout/neato/stress-cola.d.ts.map +1 -0
- package/dist/layout/neato/stress-kernel.d.ts +0 -2
- package/dist/layout/neato/stress-kernel.d.ts.map +1 -1
- package/dist/layout/neato/stress-models.d.ts +54 -0
- package/dist/layout/neato/stress-models.d.ts.map +1 -0
- package/dist/layout/neato/vpsc-adjust.d.ts +7 -8
- package/dist/layout/neato/vpsc-adjust.d.ts.map +1 -1
- package/dist/render/color-resolve.d.ts +14 -0
- package/dist/render/color-resolve.d.ts.map +1 -1
- package/dist/render/dot/edge-draw.d.ts.map +1 -1
- package/dist/render/svg-arrow-ops.d.ts +21 -4
- package/dist/render/svg-arrow-ops.d.ts.map +1 -1
- package/dist/render/svg-edge-arrows.d.ts +3 -3
- package/dist/render/svg-edge-arrows.d.ts.map +1 -1
- package/dist/render/svg-helpers.d.ts +1 -1
- package/dist/render/svg-helpers.d.ts.map +1 -1
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render.js +9179 -7729
- package/dist/render.js.map +4 -4
- package/dist/vpsc/SweepLine.d.ts +21 -8
- package/dist/vpsc/SweepLine.d.ts.map +1 -1
- package/dist/vpsc/sweepTypes.d.ts +12 -2
- package/dist/vpsc/sweepTypes.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/graph-init.ts +8 -2
- package/src/common/htmltable.ts +6 -4
- package/src/common/poly-gencode.ts +2 -1
- package/src/common/poly-init.ts +51 -22
- package/src/common/safefile.ts +92 -0
- package/src/common/shapes.ts +43 -22
- package/src/gvc/__fixtures__/p7/colors/98-point.gv +1 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.json +54 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.svg +17 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.svg.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.xdot +13 -0
- package/src/gvc/__fixtures__/p7/colors/98-point.xdot.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.gv +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.json +150 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.svg +30 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.svg.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.xdot +22 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-color.xdot.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.gv +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.json +149 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.json.stderr +0 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.svg +30 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.xdot +21 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.gv +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.json +149 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.svg +30 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.svg.stderr +1 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.xdot +21 -0
- package/src/gvc/__fixtures__/p7/colors/99-edge.xdot.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/100-rotate.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/100-rotate.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/100-rotate.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.cmapx.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.dot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.json +68 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.json.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.plain.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.svg.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-bad.xdot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.cmapx.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.dot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.json +70 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.plain.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-gif.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.cmapx.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.dot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.json +70 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.plain.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-jpg.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-png.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-png.cmapx.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-png.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-png.dot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-png.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-png.json +70 -0
- package/src/gvc/__fixtures__/p7/images/101-png.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/101-png.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-png.plain.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-png.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/101-png.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-png.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-png.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.cmapx.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.dot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.json +70 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.json.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.plain.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-svg.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.cmapx +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.cmapx.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.dot +8 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.dot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.json +68 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.json.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.plain +3 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.plain.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.svg.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/101-svgbare.xdot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-abs.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-abs.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-abs.svg.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-abs.xdot +14 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-abs.xdot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-found.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-found.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-found.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-found.xdot +14 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-found.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-missing.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-missing.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-missing.svg.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-missing.xdot +14 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-missing.xdot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.svg.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.xdot +15 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.xdot.stderr +2 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-two.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-two.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-two.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-two.xdot +14 -0
- package/src/gvc/__fixtures__/p7/images/102-ip-two.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p7/images/97-custom.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/97-custom.svg +18 -0
- package/src/gvc/__fixtures__/p7/images/97-custom.svg.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/97-custom.xdot +13 -0
- package/src/gvc/__fixtures__/p7/images/97-custom.xdot.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/97-nosuch-image.gv +1 -0
- package/src/gvc/__fixtures__/p7/images/97-nosuch-image.svg +19 -0
- package/src/gvc/__fixtures__/p7/images/97-nosuch-image.svg.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/97-nosuch-image.xdot +14 -0
- package/src/gvc/__fixtures__/p7/images/97-nosuch-image.xdot.stderr +1 -0
- package/src/gvc/__fixtures__/p7/images/bad.png +1 -0
- package/src/gvc/__fixtures__/p7/images/d/r.png +0 -0
- package/src/gvc/__fixtures__/p7/images/d2/r.png +0 -0
- package/src/gvc/__fixtures__/p7/images/g.gif +0 -0
- package/src/gvc/__fixtures__/p7/images/graphs-val_val.gv +10 -0
- package/src/gvc/__fixtures__/p7/images/graphs-val_val.svg +25 -0
- package/src/gvc/__fixtures__/p7/images/graphs-val_val.svg.stderr +3 -0
- package/src/gvc/__fixtures__/p7/images/graphs-val_val.xdot +30 -0
- package/src/gvc/__fixtures__/p7/images/graphs-val_val.xdot.stderr +3 -0
- package/src/gvc/__fixtures__/p7/images/j.jpg +0 -0
- package/src/gvc/__fixtures__/p7/images/r.png +0 -0
- package/src/gvc/__fixtures__/p7/images/s.svg +2 -0
- package/src/gvc/__fixtures__/p7/images/sb.svg +1 -0
- package/src/gvc/__fixtures__/p7/images/t.png +0 -0
- package/src/gvc/__fixtures__/p7/regen.sh +23 -0
- package/src/gvc/__fixtures__/p8/bad.png +1 -0
- package/src/gvc/__fixtures__/p8/d/r.png +0 -0
- package/src/gvc/__fixtures__/p8/html-img-bad.gv +1 -0
- package/src/gvc/__fixtures__/p8/html-img-bad.svg +19 -0
- package/src/gvc/__fixtures__/p8/html-img-bad.svg.stderr +3 -0
- package/src/gvc/__fixtures__/p8/html-img-bad.xdot +13 -0
- package/src/gvc/__fixtures__/p8/html-img-bad.xdot.stderr +3 -0
- package/src/gvc/__fixtures__/p8/ip-shapefile.gv +1 -0
- package/src/gvc/__fixtures__/p8/ip-shapefile.svg +19 -0
- package/src/gvc/__fixtures__/p8/ip-shapefile.svg.stderr +0 -0
- package/src/gvc/__fixtures__/p8/ip-shapefile.xdot +15 -0
- package/src/gvc/__fixtures__/p8/ip-shapefile.xdot.stderr +0 -0
- package/src/gvc/__fixtures__/p8/regen.sh +13 -0
- package/src/gvc/device.ts +11 -4
- package/src/gvc/image-resolver.ts +8 -0
- package/src/gvc/image-type.ts +122 -0
- package/src/gvc/render-usershape.ts +52 -1
- package/src/gvc/usershape.ts +45 -1
- package/src/layout/neato/__fixtures__/ipsep/big-dired.gv +243 -0
- package/src/layout/neato/__fixtures__/ipsep/big-dired.trace +55 -0
- package/src/layout/neato/__fixtures__/ipsep/big-dired.xdot +1832 -0
- package/src/layout/neato/__fixtures__/ipsep/big-dired.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/cluster.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/cluster.trace +95 -0
- package/src/layout/neato/__fixtures__/ipsep/cluster.xdot +58 -0
- package/src/layout/neato/__fixtures__/ipsep/cluster.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.trace +40 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.xdot +72 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.trace +43 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.xdot +72 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier.trace +43 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier.xdot +71 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-hier.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-true.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-true.trace +51 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-true.xdot +71 -0
- package/src/layout/neato/__fixtures__/ipsep/dired-true.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.trace +41 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +77 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.trace +41 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +68 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.trace +42 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +110 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.trace +49 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +108 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.trace +43 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +83 -0
- package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.trace +49 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +48 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.trace +45 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +47 -0
- package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/len-dired.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/len-dired.trace +44 -0
- package/src/layout/neato/__fixtures__/ipsep/len-dired.xdot +66 -0
- package/src/layout/neato/__fixtures__/ipsep/len-dired.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/model-circuit.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/model-circuit.trace +46 -0
- package/src/layout/neato/__fixtures__/ipsep/model-circuit.xdot +83 -0
- package/src/layout/neato/__fixtures__/ipsep/model-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds-len.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds-len.trace +52 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds-len.xdot +72 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds-len.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds.trace +52 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds.xdot +83 -0
- package/src/layout/neato/__fixtures__/ipsep/model-mds.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/ipsep/model-subset.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/model-subset.trace +49 -0
- package/src/layout/neato/__fixtures__/ipsep/model-subset.xdot +83 -0
- package/src/layout/neato/__fixtures__/ipsep/model-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.trace +211 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.xdot +60 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.trace +50 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.xdot +60 -0
- package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self-dired.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self-dired.trace +51 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self-dired.xdot +72 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self-dired.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self.gv +1 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self.trace +43 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self.xdot +84 -0
- package/src/layout/neato/__fixtures__/ipsep/start-self.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/kk-models.ts +82 -0
- package/src/layout/neato/__fixtures__/models/hier-circuit.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +92 -0
- package/src/layout/neato/__fixtures__/models/hier-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-default.gv +14 -0
- package/src/layout/neato/__fixtures__/models/hier-default.xdot +91 -0
- package/src/layout/neato/__fixtures__/models/hier-default.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-disc-circuit.gv +9 -0
- package/src/layout/neato/__fixtures__/models/hier-disc-circuit.xdot +54 -0
- package/src/layout/neato/__fixtures__/models/hier-disc-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-len-circuit.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-len-circuit.xdot +97 -0
- package/src/layout/neato/__fixtures__/models/hier-len-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-len-mds.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-len-mds.xdot +97 -0
- package/src/layout/neato/__fixtures__/models/hier-len-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-len-subset.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-len-subset.xdot +97 -0
- package/src/layout/neato/__fixtures__/models/hier-len-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-long-mds.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-long-mds.xdot +95 -0
- package/src/layout/neato/__fixtures__/models/hier-long-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +92 -0
- package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.gv +10 -0
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +54 -0
- package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot.stderr +3 -0
- package/src/layout/neato/__fixtures__/models/hier-shortpath.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +92 -0
- package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/hier-subset.gv +15 -0
- package/src/layout/neato/__fixtures__/models/hier-subset.xdot +92 -0
- package/src/layout/neato/__fixtures__/models/hier-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-circuit.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-circuit.xdot +81 -0
- package/src/layout/neato/__fixtures__/models/kk-circuit.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-default.gv +14 -0
- package/src/layout/neato/__fixtures__/models/kk-default.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/kk-default.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.gv +10 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.native-crash +1 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.xdot +0 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit.gv +9 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit.xdot +49 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-circuit.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.gv +10 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.xdot +50 -0
- package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.gv +13 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.native-crash +1 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.xdot +0 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.gv +13 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.xdot +66 -0
- package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-circuit.gv +11 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-circuit.xdot +51 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-circuit.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.gv +11 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.xdot +57 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.gv +11 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.xdot +57 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.gv +11 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.xdot +57 -0
- package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-large.gv +203 -0
- package/src/layout/neato/__fixtures__/models/kk-large.pow.json +1088 -0
- package/src/layout/neato/__fixtures__/models/kk-large.xdot +1208 -0
- package/src/layout/neato/__fixtures__/models/kk-large.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-len-circuit.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-len-circuit.xdot +86 -0
- package/src/layout/neato/__fixtures__/models/kk-len-circuit.xdot.stderr +4 -0
- package/src/layout/neato/__fixtures__/models/kk-len-mds.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-len-mds.xdot +86 -0
- package/src/layout/neato/__fixtures__/models/kk-len-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-len-subset.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-len-subset.xdot +86 -0
- package/src/layout/neato/__fixtures__/models/kk-len-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-mds-nolen.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-mds-nolen.xdot +81 -0
- package/src/layout/neato/__fixtures__/models/kk-mds-nolen.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/models/kk-shortpath.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-shortpath.xdot +81 -0
- package/src/layout/neato/__fixtures__/models/kk-shortpath.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/kk-subset.gv +15 -0
- package/src/layout/neato/__fixtures__/models/kk-subset.xdot +81 -0
- package/src/layout/neato/__fixtures__/models/kk-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/large-circuit.gv +203 -0
- package/src/layout/neato/__fixtures__/models/large-circuit.xdot +1208 -0
- package/src/layout/neato/__fixtures__/models/large-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-circuit.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-circuit.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-default.gv +13 -0
- package/src/layout/neato/__fixtures__/models/major-default.xdot +79 -0
- package/src/layout/neato/__fixtures__/models/major-default.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-disc-circuit.gv +8 -0
- package/src/layout/neato/__fixtures__/models/major-disc-circuit.xdot +48 -0
- package/src/layout/neato/__fixtures__/models/major-disc-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-len-circuit.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-len-circuit.xdot +85 -0
- package/src/layout/neato/__fixtures__/models/major-len-circuit.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-len-mds.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-len-mds.xdot +85 -0
- package/src/layout/neato/__fixtures__/models/major-len-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-len-subset.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-len-subset.xdot +85 -0
- package/src/layout/neato/__fixtures__/models/major-len-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-long-mds.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-long-mds.xdot +83 -0
- package/src/layout/neato/__fixtures__/models/major-long-mds.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-long-shortpath.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-long-shortpath.xdot +83 -0
- package/src/layout/neato/__fixtures__/models/major-long-shortpath.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-mds-edge-default.gv +15 -0
- package/src/layout/neato/__fixtures__/models/major-mds-edge-default.xdot +81 -0
- package/src/layout/neato/__fixtures__/models/major-mds-edge-default.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-mds-nolen.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/models/major-model-Subset.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-model-Subset.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-model-Subset.xdot.stderr +1 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo-anon.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo-anon.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo-anon.xdot.stderr +1 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-model-foo.xdot.stderr +1 -0
- package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.gv +9 -0
- package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.xdot +48 -0
- package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.xdot.stderr +2 -0
- package/src/layout/neato/__fixtures__/models/major-shortpath.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-shortpath.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-shortpath.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/major-subset.gv +14 -0
- package/src/layout/neato/__fixtures__/models/major-subset.xdot +80 -0
- package/src/layout/neato/__fixtures__/models/major-subset.xdot.stderr +0 -0
- package/src/layout/neato/__fixtures__/models/regen.sh +46 -0
- package/src/layout/neato/__fixtures__/quad-prog-vpsc.ts +115 -0
- package/src/layout/neato/__fixtures__/stress-models.ts +64 -0
- package/src/layout/neato/circuit.ts +96 -0
- package/src/layout/neato/constrained-majorization.ts +5 -22
- package/src/layout/neato/index.ts +43 -16
- package/src/layout/neato/init.ts +31 -44
- package/src/layout/neato/ipsep-opts.ts +158 -0
- package/src/layout/neato/kk-paths.ts +23 -1
- package/src/layout/neato/kk-solve.ts +5 -3
- package/src/layout/neato/kk.ts +53 -21
- package/src/layout/neato/kkutils.ts +108 -3
- package/src/layout/neato/lu.ts +189 -0
- package/src/layout/neato/matinv.ts +37 -0
- package/src/layout/neato/quad-prog-vpsc-overlap.ts +365 -0
- package/src/layout/neato/quad-prog-vpsc.ts +416 -0
- package/src/layout/neato/start.ts +24 -84
- package/src/layout/neato/stress-cola.ts +497 -0
- package/src/layout/neato/stress-kernel.ts +1 -17
- package/src/layout/neato/stress-models.ts +208 -0
- package/src/layout/neato/vpsc-adjust.ts +35 -66
- package/src/layout/pack/index.ts +2 -2
- package/src/render/color-resolve.ts +25 -2
- package/src/render/dot/edge-draw.ts +7 -4
- package/src/render/svg-arrow-ops.ts +35 -19
- package/src/render/svg-edge-arrows.ts +7 -6
- package/src/render/svg-helpers.ts +19 -11
- package/src/render/svg.ts +15 -3
- package/src/vpsc/SweepLine.ts +39 -26
- package/src/vpsc/sweepTypes.ts +13 -2
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Quadratic programming with separation constraints (IPSep-CoLa): minimise
|
|
5
|
+
* `X' A X + b X` subject to VPSC separation constraints by gradient
|
|
6
|
+
* projection — a float32-faithful port of `lib/neatogen/quad_prog_vpsc.c`.
|
|
7
|
+
* The C works on `float`; arrays are `Float32Array` and every float result is
|
|
8
|
+
* rounded with `Math.fround`.
|
|
9
|
+
*
|
|
10
|
+
* Fused multiply-adds follow the 16.1 arm64 `-O3 -flto=thin` build
|
|
11
|
+
* (`libgvplugin_neato_layout.8.0.15.dylib`, `_constrained_majorization_vpsc`):
|
|
12
|
+
* each `A`-row reduction is vectorised in 16- and 4-wide blocks whose
|
|
13
|
+
* products are rounded before strictly in-order adds, and its scalar tail is
|
|
14
|
+
* `fmadd`; the per-`i` accumulations, the descent step and the beta step are
|
|
15
|
+
* `fmadd`/`fmsub`/`fmla` in every shape. See {@link rowReduce}.
|
|
16
|
+
*
|
|
17
|
+
* `Verbose` stderr lines and the `CONMAJ_LOGGING` trace are not ported (the
|
|
18
|
+
* port has no Verbose). `generateNonoverlapConstraints`, `removeoverlaps`,
|
|
19
|
+
* `assign_digcola_levels` and `get_num_digcola_constraints` live in
|
|
20
|
+
* `quad-prog-vpsc-overlap.ts` only because of the file-length limit.
|
|
21
|
+
*
|
|
22
|
+
* @see lib/neatogen/quad_prog_vpsc.c
|
|
23
|
+
* @see lib/neatogen/quad_prog_vpsc.h
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { Box, Point } from '../../model/geom.js';
|
|
27
|
+
import {
|
|
28
|
+
newVariable,
|
|
29
|
+
newConstraint,
|
|
30
|
+
newIncVPSC,
|
|
31
|
+
deleteVPSC,
|
|
32
|
+
deleteConstraints,
|
|
33
|
+
deleteVariable,
|
|
34
|
+
satisfyVPSC,
|
|
35
|
+
setVariableDesiredPos,
|
|
36
|
+
getVariablePos,
|
|
37
|
+
type Constraint,
|
|
38
|
+
type IncVPSC,
|
|
39
|
+
type Variable,
|
|
40
|
+
} from '../../vpsc/index.js';
|
|
41
|
+
import { InternalError } from '../../errors.js';
|
|
42
|
+
import { computeHierarchy } from './compute-hierarchy.js';
|
|
43
|
+
import type { DirectedVtxData } from './opt-arrangement.js';
|
|
44
|
+
import { fmaf, unpackMatrix } from './quad-prog-solve.js';
|
|
45
|
+
import { assignDigcolaLevels, getNumDigcolaConstraints } from './quad-prog-vpsc-overlap.js';
|
|
46
|
+
|
|
47
|
+
const fr = Math.fround;
|
|
48
|
+
|
|
49
|
+
/** `#define quad_prog_tol` @see lib/neatogen/quad_prog_vpsc.c */
|
|
50
|
+
const QUAD_PROG_TOL = 1e-4;
|
|
51
|
+
/** Weight of a DiG-CoLa boundary dummy variable. @see quad_prog_vpsc.c:initCMajVPSC */
|
|
52
|
+
const DUMMY_WEIGHT = 0.000001;
|
|
53
|
+
/**
|
|
54
|
+
* Width of the oracle's smallest vector block: a row reduction rounds the
|
|
55
|
+
* products of its first `n - n % 4` terms (16- then 4-wide blocks, in-order
|
|
56
|
+
* adds) and fuses the rest. Below 4 terms the whole loop is scalar.
|
|
57
|
+
*/
|
|
58
|
+
const VECTOR_BLOCK = 4;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Cluster membership for the containment and cluster non-overlap constraints.
|
|
62
|
+
* C counts are `size_t`; `bb` is written by `generateNonoverlapConstraints`.
|
|
63
|
+
* @see lib/neatogen/defs.h:cluster_data
|
|
64
|
+
*/
|
|
65
|
+
export interface ClusterData {
|
|
66
|
+
/** Total count of vars in clusters. */
|
|
67
|
+
nvars: number;
|
|
68
|
+
/** Number of clusters. */
|
|
69
|
+
nclusters: number;
|
|
70
|
+
/** Number of vars in each cluster. */
|
|
71
|
+
clustersizes: Int32Array;
|
|
72
|
+
/** Var indices of the constituents of each cluster. */
|
|
73
|
+
clusters: Int32Array[];
|
|
74
|
+
/** Number of nodes not in any cluster. */
|
|
75
|
+
ntoplevel: number;
|
|
76
|
+
/** Nodes not in any cluster. */
|
|
77
|
+
toplevel: Int32Array;
|
|
78
|
+
/** Bounding box of each cluster. */
|
|
79
|
+
bb: Box[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @see lib/neatogen/digcola.h:ipsep_options */
|
|
83
|
+
export interface IpsepOptions {
|
|
84
|
+
/** 1 = directed edge constraints, 2 = DiG-CoLa hierarchy level constraints. */
|
|
85
|
+
diredges: 0 | 1 | 2;
|
|
86
|
+
/** Vertical separation forced between the ends of a directed edge. */
|
|
87
|
+
edgeGap: number;
|
|
88
|
+
/** 1 = non-overlap constraints, 2 = remove overlaps after layout. */
|
|
89
|
+
noverlap: 0 | 1 | 2;
|
|
90
|
+
/** Horizontal and vertical gap enforced when removing overlap. */
|
|
91
|
+
gap: Point;
|
|
92
|
+
/** Node widths and heights. */
|
|
93
|
+
nsize: Point[];
|
|
94
|
+
clusters: ClusterData;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @see lib/neatogen/quad_prog_vpsc.h:DigColaLevel */
|
|
98
|
+
export interface DigColaLevel {
|
|
99
|
+
nodes: Int32Array;
|
|
100
|
+
numNodes: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** @see lib/neatogen/quad_prog_vpsc.h:CMajEnvVPSC */
|
|
104
|
+
export interface CMajEnvVPSC {
|
|
105
|
+
/** Unpacked matrix, or null when none was given. */
|
|
106
|
+
A: Float32Array[] | null;
|
|
107
|
+
/** Number of actual vars. */
|
|
108
|
+
nv: number;
|
|
109
|
+
/** Number of dummy nodes included in the Laplacian matrix. */
|
|
110
|
+
nldv: number;
|
|
111
|
+
/** Number of dummy nodes not included in the Laplacian matrix. */
|
|
112
|
+
ndv: number;
|
|
113
|
+
vs: Variable[];
|
|
114
|
+
/** Total number of constraints for the next iteration. */
|
|
115
|
+
m: number;
|
|
116
|
+
/** Number of global constraints. */
|
|
117
|
+
gm: number;
|
|
118
|
+
cs: Constraint[] | null;
|
|
119
|
+
/** Global constraints, persistent throughout the optimisation. */
|
|
120
|
+
gcs: Constraint[] | null;
|
|
121
|
+
vpsc: IncVPSC | null;
|
|
122
|
+
/** Utility arrays (reusable memory). */
|
|
123
|
+
fArray1: Float32Array;
|
|
124
|
+
fArray2: Float32Array;
|
|
125
|
+
fArray3: Float32Array;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `acc + Σ_j (factor·row[j])·v[j]` as the oracle's vectorised copy of the
|
|
130
|
+
* loop computes it: `factor·row[j]` is exact (±2), the first `n - n % 4`
|
|
131
|
+
* products are rounded and added in order, the tail is `fmadd`.
|
|
132
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc
|
|
133
|
+
*/
|
|
134
|
+
function rowReduce(row: Float32Array, factor: number, v: Float32Array, n: number, acc: number): number {
|
|
135
|
+
const blocked = n - (n % VECTOR_BLOCK);
|
|
136
|
+
let j = 0;
|
|
137
|
+
for (; j < blocked; j++) acc = fr(acc + fr(fr(factor * row[j]!) * v[j]!));
|
|
138
|
+
for (; j < n; j++) acc = fmaf(fr(factor * row[j]!), v[j]!, acc);
|
|
139
|
+
return acc;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Project `place` onto the constraint boundary.
|
|
144
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc (71-79, 118-126)
|
|
145
|
+
*/
|
|
146
|
+
function project(e: CMajEnvVPSC, place: Float32Array, n: number): void {
|
|
147
|
+
for (let i = 0; i < n; i++) {
|
|
148
|
+
setVariableDesiredPos(e.vs[i]!, place[i]!);
|
|
149
|
+
}
|
|
150
|
+
satisfyVPSC(e.vpsc!);
|
|
151
|
+
for (let i = 0; i < n; i++) {
|
|
152
|
+
place[i] = getVariablePos(e.vs[i]!);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Steepest-descent direction `g = 2b - 2A·place` (saving `old_place`), then
|
|
158
|
+
* the exact step `alpha` along it; returns `-alpha` as the build forms it.
|
|
159
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc (96-115)
|
|
160
|
+
*/
|
|
161
|
+
function descentStep(e: CMajEnvVPSC, b: Float32Array, place: Float32Array, n: number): number {
|
|
162
|
+
const A = e.A!;
|
|
163
|
+
const g = e.fArray1;
|
|
164
|
+
const oldPlace = e.fArray2;
|
|
165
|
+
for (let i = 0; i < n; i++) {
|
|
166
|
+
oldPlace[i] = place[i]!;
|
|
167
|
+
g[i] = rowReduce(A[i]!, -2, place, n, fr(2 * b[i]!));
|
|
168
|
+
}
|
|
169
|
+
let numerator = 0;
|
|
170
|
+
let denominator = 0;
|
|
171
|
+
for (let i = 0; i < n; i++) {
|
|
172
|
+
numerator = fmaf(g[i]!, g[i]!, numerator);
|
|
173
|
+
const r = rowReduce(A[i]!, 2, g, n, 0);
|
|
174
|
+
denominator = fmaf(-r, g[i]!, denominator);
|
|
175
|
+
}
|
|
176
|
+
return denominator !== 0 ? -fr(numerator / denominator) : -1.0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* `d = place - old_place` and the line-search factor `beta` along it.
|
|
181
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc (130-147)
|
|
182
|
+
*/
|
|
183
|
+
function lineSearchBeta(e: CMajEnvVPSC, place: Float32Array, n: number): number {
|
|
184
|
+
const A = e.A!;
|
|
185
|
+
const g = e.fArray1;
|
|
186
|
+
const oldPlace = e.fArray2;
|
|
187
|
+
const d = e.fArray3;
|
|
188
|
+
for (let i = 0; i < n; i++) {
|
|
189
|
+
d[i] = fr(place[i]! - oldPlace[i]!);
|
|
190
|
+
}
|
|
191
|
+
let numerator = 0;
|
|
192
|
+
let denominator = 0;
|
|
193
|
+
for (let i = 0; i < n; i++) {
|
|
194
|
+
numerator = fmaf(g[i]!, d[i]!, numerator);
|
|
195
|
+
const r = rowReduce(A[i]!, 2, d, n, 0);
|
|
196
|
+
denominator = fmaf(r, d[i]!, denominator);
|
|
197
|
+
}
|
|
198
|
+
// C: !is_exactly_zero(denominator) && !is_exactly_equal(denominator, -0.0)
|
|
199
|
+
if (!Object.is(denominator, 0) && !Object.is(denominator, -0)) return fr(numerator / denominator);
|
|
200
|
+
return 1.0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Take the `beta` step where it stays feasible; returns the sum of moves.
|
|
205
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc (149-157)
|
|
206
|
+
*/
|
|
207
|
+
function applyBeta(e: CMajEnvVPSC, place: Float32Array, n: number, beta: number): number {
|
|
208
|
+
const oldPlace = e.fArray2;
|
|
209
|
+
const d = e.fArray3;
|
|
210
|
+
let test = 0;
|
|
211
|
+
for (let i = 0; i < n; i++) {
|
|
212
|
+
/* beta > 1.0 takes us back outside the feasible region
|
|
213
|
+
* beta < 0 clearly not useful and may happen due to numerical imp.
|
|
214
|
+
*/
|
|
215
|
+
if (beta > 0 && beta < 1.0) {
|
|
216
|
+
place[i] = fmaf(beta, d[i]!, oldPlace[i]!);
|
|
217
|
+
}
|
|
218
|
+
test = fr(test + fr(Math.abs(place[i]! - oldPlace[i]!)));
|
|
219
|
+
}
|
|
220
|
+
return test;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Use gradient projection to solve Variable Placement with Separation
|
|
225
|
+
* Constraints. Returns the iteration count.
|
|
226
|
+
* @see lib/neatogen/quad_prog_vpsc.c:constrained_majorization_vpsc
|
|
227
|
+
*/
|
|
228
|
+
export function constrainedMajorizationVpsc(
|
|
229
|
+
e: CMajEnvVPSC, b: Float32Array, place: Float32Array, maxIterations: number,
|
|
230
|
+
): number {
|
|
231
|
+
/* for laplacian computation need number of real vars and those
|
|
232
|
+
* dummy vars included in lap
|
|
233
|
+
*/
|
|
234
|
+
const n = e.nv + e.nldv;
|
|
235
|
+
let converged = false;
|
|
236
|
+
if (maxIterations === 0) return 0;
|
|
237
|
+
if (e.m > 0) project(e, place, n);
|
|
238
|
+
let counter: number;
|
|
239
|
+
for (counter = 0; counter < maxIterations && !converged; counter++) {
|
|
240
|
+
converged = true;
|
|
241
|
+
/* find steepest descent direction */
|
|
242
|
+
const negAlpha = descentStep(e, b, place, n);
|
|
243
|
+
for (let i = 0; i < n; i++) {
|
|
244
|
+
place[i] = fmaf(negAlpha, e.fArray1[i]!, place[i]!);
|
|
245
|
+
}
|
|
246
|
+
/* project to constraint boundary */
|
|
247
|
+
if (e.m > 0) project(e, place, n);
|
|
248
|
+
const beta = lineSearchBeta(e, place, n);
|
|
249
|
+
const test = applyBeta(e, place, n, beta);
|
|
250
|
+
if (test > QUAD_PROG_TOL) {
|
|
251
|
+
converged = false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return counter;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* One separation constraint per directed edge of the acyclic subgraph.
|
|
259
|
+
* @see lib/neatogen/quad_prog_vpsc.c:initCMajVPSC (215-235)
|
|
260
|
+
*/
|
|
261
|
+
function directedEdgeConstraints(e: CMajEnvVPSC, graph: DirectedVtxData[], opt: IpsepOptions): void {
|
|
262
|
+
for (let i = 0; i < e.nv; i++) {
|
|
263
|
+
for (let j = 1; j < graph[i]!.nedges; j++) {
|
|
264
|
+
if (graph[i]!.edists![j]! > 0) {
|
|
265
|
+
e.gm++;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
e.gcs = [];
|
|
270
|
+
e.gm = 0;
|
|
271
|
+
for (let i = 0; i < e.nv; i++) {
|
|
272
|
+
for (let j = 1; j < graph[i]!.nedges; j++) {
|
|
273
|
+
const u = i;
|
|
274
|
+
const v = graph[i]!.edges[j]!;
|
|
275
|
+
if (graph[i]!.edists![j]! > 0) {
|
|
276
|
+
e.gcs[e.gm++] = newConstraint(e.vs[u]!, e.vs[v]!, opt.edgeGap);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* DiG-CoLa level constraints through one dummy variable per level boundary.
|
|
284
|
+
* Returns false where C returns NULL (`compute_hierarchy` failed).
|
|
285
|
+
* @see lib/neatogen/quad_prog_vpsc.c:initCMajVPSC (236-282)
|
|
286
|
+
*/
|
|
287
|
+
function digcolaConstraints(
|
|
288
|
+
e: CMajEnvVPSC, n: number, graph: DirectedVtxData[], opt: IpsepOptions,
|
|
289
|
+
): boolean {
|
|
290
|
+
/* e->ndv is the number of dummy variables required, one for each boundary */
|
|
291
|
+
const h = computeHierarchy(graph, e.nv, 1e-2, 1e-1, null);
|
|
292
|
+
// Unreachable: compute_y_coords tests `conjugate_gradient(...) < 0`, which
|
|
293
|
+
// never holds (it returns 0 or 1); kept because C has the branch.
|
|
294
|
+
/* v8 ignore next -- @preserve */
|
|
295
|
+
if (h === null) return false;
|
|
296
|
+
e.ndv = h.numLevels;
|
|
297
|
+
const levels = assignDigcolaLevels(h.ordering, e.nv, h.levels, e.ndv);
|
|
298
|
+
if (e.ndv === 0) {
|
|
299
|
+
// C's `e->ndv - 1` is a size_t: it wraps, and the boundary loop reads
|
|
300
|
+
// e->vs[n] past the array — native 16.1 segfaults here.
|
|
301
|
+
throw new InternalError('initCMajVPSC: DiG-CoLa found 0 boundaries');
|
|
302
|
+
}
|
|
303
|
+
e.gm = getNumDigcolaConstraints(levels, e.ndv + 1) + e.ndv - 1;
|
|
304
|
+
e.gcs = [];
|
|
305
|
+
e.gm = 0;
|
|
306
|
+
/* create dummy vars */
|
|
307
|
+
for (let i = 0; i < e.ndv; i++) {
|
|
308
|
+
/* dummy vars should have 0 weight */
|
|
309
|
+
const cvar = n + i;
|
|
310
|
+
e.vs[cvar] = newVariable(cvar, 1.0, DUMMY_WEIGHT);
|
|
311
|
+
}
|
|
312
|
+
const halfgap = opt.edgeGap;
|
|
313
|
+
for (let i = 0; i < e.ndv; i++) {
|
|
314
|
+
const cvar = n + i;
|
|
315
|
+
/* outgoing constraints for each var in level below boundary */
|
|
316
|
+
for (let j = 0; j < levels[i]!.numNodes; j++) {
|
|
317
|
+
e.gcs[e.gm++] = newConstraint(e.vs[levels[i]!.nodes[j]!]!, e.vs[cvar]!, halfgap);
|
|
318
|
+
}
|
|
319
|
+
/* incoming constraints for each var in level above boundary */
|
|
320
|
+
for (let j = 0; j < levels[i + 1]!.numNodes; j++) {
|
|
321
|
+
e.gcs[e.gm++] = newConstraint(e.vs[cvar]!, e.vs[levels[i + 1]!.nodes[j]!]!, halfgap);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/* constraints between adjacent boundary dummy vars */
|
|
325
|
+
for (let i = 0; i < e.ndv - 1; i++) {
|
|
326
|
+
e.gcs[e.gm++] = newConstraint(e.vs[n + i]!, e.vs[n + i + 1]!, 0);
|
|
327
|
+
}
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Two containment constraints for each var in a cluster, after the global
|
|
333
|
+
* constraints generated so far.
|
|
334
|
+
* @see lib/neatogen/quad_prog_vpsc.c:initCMajVPSC (283-300)
|
|
335
|
+
*/
|
|
336
|
+
function clusterContainment(e: CMajEnvVPSC, opt: IpsepOptions): void {
|
|
337
|
+
const ecs = e.gcs;
|
|
338
|
+
e.gcs = [];
|
|
339
|
+
for (let i = 0; i < e.gm; i++) {
|
|
340
|
+
e.gcs[i] = ecs![i]!;
|
|
341
|
+
}
|
|
342
|
+
// C deleteConstraints(0, ecs) frees the array only.
|
|
343
|
+
for (let i = 0; i < opt.clusters.nclusters; i++) {
|
|
344
|
+
for (let j = 0; j < opt.clusters.clustersizes[i]!; j++) {
|
|
345
|
+
const v = e.vs[opt.clusters.clusters[i]![j]!]!;
|
|
346
|
+
const cl = e.vs[e.nv + 2 * i]!;
|
|
347
|
+
const cr = e.vs[e.nv + 2 * i + 1]!;
|
|
348
|
+
e.gcs[e.gm++] = newConstraint(cl, v, 0);
|
|
349
|
+
e.gcs[e.gm++] = newConstraint(v, cr, 0);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Set up the environment and the global constraints (directed-edge and
|
|
356
|
+
* cluster containment constraints). `diredges`: 0 = none, 1 = one separation
|
|
357
|
+
* constraint per edge (in the acyclic subgraph), 2 = DiG-CoLa level
|
|
358
|
+
* constraints. Returns null where C returns NULL.
|
|
359
|
+
* @see lib/neatogen/quad_prog_vpsc.c:initCMajVPSC
|
|
360
|
+
*/
|
|
361
|
+
export function initCMajVPSC(
|
|
362
|
+
n: number, packedMat: Float32Array | null, graph: DirectedVtxData[] | null,
|
|
363
|
+
opt: IpsepOptions, diredges: 0 | 1 | 2,
|
|
364
|
+
): CMajEnvVPSC | null {
|
|
365
|
+
/* if we have clusters then we'll need two constraints for each var in
|
|
366
|
+
* a cluster */
|
|
367
|
+
const nldv = 2 * opt.clusters.nclusters;
|
|
368
|
+
const e: CMajEnvVPSC = {
|
|
369
|
+
A: null, nv: n - nldv, nldv, ndv: 0, vs: [], m: 0, gm: 0, cs: null, gcs: null,
|
|
370
|
+
vpsc: null, fArray1: new Float32Array(0), fArray2: new Float32Array(0), fArray3: new Float32Array(0),
|
|
371
|
+
};
|
|
372
|
+
for (let i = 0; i < n; i++) {
|
|
373
|
+
e.vs[i] = newVariable(i, 1.0, 1.0);
|
|
374
|
+
}
|
|
375
|
+
if (diredges === 1) {
|
|
376
|
+
directedEdgeConstraints(e, graph!, opt);
|
|
377
|
+
} else if (diredges === 2) {
|
|
378
|
+
const ok = digcolaConstraints(e, n, graph!, opt);
|
|
379
|
+
// Unreachable for the same reason; kept because C returns NULL here.
|
|
380
|
+
/* v8 ignore next -- @preserve */
|
|
381
|
+
if (!ok) return null;
|
|
382
|
+
}
|
|
383
|
+
if (opt.clusters.nclusters > 0) clusterContainment(e, opt);
|
|
384
|
+
e.m = 0;
|
|
385
|
+
e.cs = null;
|
|
386
|
+
if (e.gm > 0) {
|
|
387
|
+
e.vpsc = newIncVPSC(e.vs, e.gcs!);
|
|
388
|
+
e.m = e.gm;
|
|
389
|
+
e.cs = e.gcs;
|
|
390
|
+
}
|
|
391
|
+
if (packedMat !== null) {
|
|
392
|
+
e.A = unpackMatrix(packedMat, n);
|
|
393
|
+
}
|
|
394
|
+
e.fArray1 = new Float32Array(n);
|
|
395
|
+
e.fArray2 = new Float32Array(n);
|
|
396
|
+
e.fArray3 = new Float32Array(n);
|
|
397
|
+
return e;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Release the environment: the solver, its constraints (global ones only
|
|
402
|
+
* when the array is separate) and variables.
|
|
403
|
+
* @see lib/neatogen/quad_prog_vpsc.c:deleteCMajEnvVPSC
|
|
404
|
+
*/
|
|
405
|
+
export function deleteCMajEnvVPSC(e: CMajEnvVPSC): void {
|
|
406
|
+
e.A = null;
|
|
407
|
+
if (e.m > 0) {
|
|
408
|
+
deleteVPSC(e.vpsc!);
|
|
409
|
+
// C deleteConstraints(0, e->gcs) when e->cs != e->gcs frees the array only.
|
|
410
|
+
deleteConstraints(e.cs!.slice(0, e.m));
|
|
411
|
+
for (let i = 0; i < e.nv + e.nldv + e.ndv; i++) {
|
|
412
|
+
deleteVariable(e.vs[i]!);
|
|
413
|
+
}
|
|
414
|
+
e.vs = [];
|
|
415
|
+
}
|
|
416
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EPL-2.0
|
|
2
2
|
/**
|
|
3
3
|
* Neato `start` handling (setSeed / initRegular / checkStart) and the
|
|
4
|
-
* fail-loud
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* fail-loud check for the neato init feature this port does not have (smart
|
|
5
|
+
* init for the stress path). mode=hier runs `stress_majorization_with_hierarchy`;
|
|
6
|
+
* its own unported smart-init fallback without a hierarchy is loud in
|
|
7
|
+
* constrained-majorization.ts. mode=ipsep runs `stress_majorization_cola`, which
|
|
8
|
+
* takes no smart init.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* fires only for the
|
|
10
|
+
* The loud check sits where neato's C branches into the unported code and
|
|
11
|
+
* fires only for the mode whose C path reaches it (ADR-3).
|
|
12
12
|
*
|
|
13
13
|
* @see lib/neatogen/neatoinit.c
|
|
14
14
|
*/
|
|
@@ -18,13 +18,10 @@ import { agNameOf } from '../../model/cgraph-ops.js';
|
|
|
18
18
|
import type { Graph } from '../../model/graph.js';
|
|
19
19
|
import { srand48 } from '../../common/random.js';
|
|
20
20
|
import { registerRenderState } from '../../common/render-state.js';
|
|
21
|
-
import { mapbool, isACluster } from '../dot/rank.js';
|
|
22
|
-
import { getPack } from '../pack/index.js';
|
|
23
21
|
import {
|
|
24
22
|
MODE_KK, MODE_MAJOR, MODE_HIER, MODE_IPSEP, MODE_SGD,
|
|
25
|
-
MODEL_CIRCUIT, MODEL_SUBSET,
|
|
26
23
|
} from './init.js';
|
|
27
|
-
import {
|
|
24
|
+
import { agwarningf } from '../../common/agerr.js';
|
|
28
25
|
|
|
29
26
|
/** @see lib/neatogen/neato.h:INIT_SELF */
|
|
30
27
|
export const INIT_SELF = 0;
|
|
@@ -53,8 +50,13 @@ const WARN_SELF_IGNORED = 'start=0 not supported with mode=self - ignored';
|
|
|
53
50
|
*/
|
|
54
51
|
const selfOnce = { warned: false };
|
|
55
52
|
registerRenderState(() => { selfOnce.warned = false; });
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
|
|
54
|
+
/** KK and SGD warn once and ignore start=self. @see lib/neatogen/stuff.c:330 */
|
|
55
|
+
export function warnStartSelfOnce(): void {
|
|
56
|
+
if (selfOnce.warned) return;
|
|
57
|
+
selfOnce.warned = true;
|
|
58
|
+
agwarningf(WARN_SELF_IGNORED);
|
|
59
|
+
}
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* Classify the `start` attribute: keyword prefix, digit-led (random), else the
|
|
@@ -103,7 +105,7 @@ export function checkStart(
|
|
|
103
105
|
): number {
|
|
104
106
|
const { init, seed } = parseStart(g.root.attrs.get('start'), dflt);
|
|
105
107
|
if (init !== INIT_RANDOM && [...g.nodes.values()].some((n) => n.attrs.has('pos'))) {
|
|
106
|
-
|
|
108
|
+
agwarningf(WARN_POS_IGNORED);
|
|
107
109
|
}
|
|
108
110
|
if (init === INIT_REGULAR) initRegular(g, nG);
|
|
109
111
|
srand48(seed);
|
|
@@ -114,14 +116,6 @@ function unsupported(attr: string, value: string, what: string): never {
|
|
|
114
116
|
throw new RenderError(`${attr}=${value}: ${what} is not supported yet`, 'UNSUPPORTED_FEATURE');
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
/** Does C's ipsep branch build constraints? @see neatoinit.c:1132-1150 */
|
|
118
|
-
function ipsepHasConstraints(g: Graph): boolean {
|
|
119
|
-
const dir = g.root.attrs.get('diredgeconstraints') ?? '';
|
|
120
|
-
if (mapbool(dir) || /^hier/i.test(dir)) return true;
|
|
121
|
-
if ((g.root.attrs.get('overlap') ?? '').toLowerCase() === 'ipsep') return true;
|
|
122
|
-
return [...g.root.subgraphs.values()].some((s) => s !== g.root && isACluster(s));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
119
|
/** @see lib/neatogen/neatoinit.c:1290 (MaxIter < 0 returns before any solver) */
|
|
126
120
|
function maxIterNegative(g: Graph): boolean {
|
|
127
121
|
const v = g.attrs.get('maxiter') ?? g.root.attrs.get('maxiter');
|
|
@@ -152,77 +146,23 @@ export function neatoMode(g: Graph): number {
|
|
|
152
146
|
return MODE_MAJOR;
|
|
153
147
|
}
|
|
154
148
|
|
|
155
|
-
function checkMode(g: Graph, mode: number): void {
|
|
156
|
-
const value = g.root.attrs.get('mode') || 'ipsep';
|
|
157
|
-
// @see lib/neatogen/neatoinit.c:1121-1170 (stress_majorization_cola)
|
|
158
|
-
if (mode === MODE_IPSEP && ipsepHasConstraints(g)) {
|
|
159
|
-
unsupported('mode', value, 'constrained (ipsep) majorization');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
149
|
function checkStartAttr(g: Graph, mode: number): void {
|
|
164
150
|
const value = g.root.attrs.get('start');
|
|
165
151
|
if (parseStart(value, INIT_RANDOM).init !== INIT_SELF) return;
|
|
166
|
-
// @see lib/neatogen/neatoinit.c:1095, lib/neatogen/stress.c:884 (smart_ini)
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function isConnected(g: Graph): boolean {
|
|
176
|
-
const nodes = [...g.nodes.values()];
|
|
177
|
-
if (nodes.length === 0) return true;
|
|
178
|
-
const adj = new Map<unknown, unknown[]>(nodes.map((n) => [n, []]));
|
|
179
|
-
for (const e of g.edges) { adj.get(e.tail)?.push(e.head); adj.get(e.head)?.push(e.tail); }
|
|
180
|
-
const seen = new Set<unknown>([nodes[0]]);
|
|
181
|
-
const stack: unknown[] = [nodes[0]];
|
|
182
|
-
for (let n = stack.pop(); n !== undefined; n = stack.pop()) {
|
|
183
|
-
for (const m of adj.get(n) ?? []) if (!seen.has(m)) { seen.add(m); stack.push(m); }
|
|
184
|
-
}
|
|
185
|
-
return seen.size === nodes.length;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/** KK runs unpacked unless `pack` or `packmode` is set. @see neatoinit.c:1380-1389 */
|
|
189
|
-
function kkCircuitFallsBack(g: Graph): boolean {
|
|
190
|
-
const packed = getPack(g.root, -1, 0) >= 0 || (g.root.attrs.get('packmode') ?? '') !== '';
|
|
191
|
-
return !packed && !isConnected(g.root);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function warnCircuitDisconnected(g: Graph): void {
|
|
195
|
-
if (circuitWarned.has(g.root)) return;
|
|
196
|
-
circuitWarned.add(g.root);
|
|
197
|
-
agerrLineOn(
|
|
198
|
-
'warn',
|
|
199
|
-
`graph ${agNameOf(g.root)} is disconnected. Hence, the circuit model\n`
|
|
200
|
-
+ 'is undefined. Reverting to the shortest path model.\n'
|
|
201
|
-
+ 'Alternatively, consider running neato using -Gpack=true or decomposing\n'
|
|
202
|
-
+ 'the graph into connected components.',
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function checkModel(g: Graph, mode: number, model: number): void {
|
|
207
|
-
const value = g.root.attrs.get('model') ?? '';
|
|
208
|
-
const stressPath = mode === MODE_MAJOR || mode === MODE_KK;
|
|
209
|
-
// @see lib/neatogen/stress.c:846, lib/neatogen/neatoinit.c:1246
|
|
210
|
-
if (model === MODEL_SUBSET && stressPath) unsupported('model', value, 'the subset distance model');
|
|
211
|
-
if (model !== MODEL_CIRCUIT || !stressPath) return;
|
|
212
|
-
// @see lib/neatogen/neatoinit.c:1248-1257 (disconnected: warn + shortpath)
|
|
213
|
-
if (mode === MODE_KK && kkCircuitFallsBack(g)) { warnCircuitDisconnected(g); return; }
|
|
214
|
-
// @see lib/neatogen/stress.c:851, lib/neatogen/circuit.c:circuit_model
|
|
215
|
-
unsupported('model', value, 'the circuit distance model');
|
|
152
|
+
// @see lib/neatogen/neatoinit.c:1095, lib/neatogen/stress.c:884 (smart_ini).
|
|
153
|
+
// mode=ipsep is not here: stress_majorization_cola takes no `opts`, so C
|
|
154
|
+
// lays start=self out from the random init, silently (T0 start-self fixtures).
|
|
155
|
+
if (mode === MODE_MAJOR) unsupported('start', value ?? '', 'smart initialisation');
|
|
156
|
+
// KK warns at kk.ts:initialPositions, after its distance model, as C does.
|
|
157
|
+
if (mode === MODE_SGD) warnStartSelfOnce();
|
|
216
158
|
}
|
|
217
159
|
|
|
218
160
|
/**
|
|
219
161
|
* Throw UNSUPPORTED_FEATURE where neato's C would run unported init code for
|
|
220
|
-
* this mode/
|
|
162
|
+
* this mode/start. Call after the nG < 2 guard.
|
|
221
163
|
* @see lib/neatogen/neatoinit.c:neatoLayout
|
|
222
164
|
*/
|
|
223
|
-
export function assertSupported(g: Graph, mode: number
|
|
165
|
+
export function assertSupported(g: Graph, mode: number): void {
|
|
224
166
|
if (maxIterNegative(g)) return;
|
|
225
|
-
checkMode(g, mode);
|
|
226
167
|
checkStartAttr(g, mode);
|
|
227
|
-
checkModel(g, mode, model);
|
|
228
168
|
}
|