@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
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
MODEL_MDS,
|
|
26
26
|
} from './init.js';
|
|
27
27
|
import { neatoMode } from './start.js';
|
|
28
|
+
import { agerr, agwarningf } from '../../common/agerr.js';
|
|
29
|
+
import { agNameOf } from '../../model/cgraph-ops.js';
|
|
28
30
|
import { removeOverlapWith, graphAdjustMode, type AdjustData } from './fdp-adjust.js';
|
|
29
31
|
import { splineEdgesShifted, EDGETYPE_LINE } from './splines.js';
|
|
30
32
|
import { setEdgeTypeFromAttr } from '../dot/index.js';
|
|
@@ -74,25 +76,50 @@ export function parseMode(g: Graph): number {
|
|
|
74
76
|
// Model parsing
|
|
75
77
|
// ---------------------------------------------------------------------------
|
|
76
78
|
|
|
77
|
-
/**
|
|
78
|
-
const
|
|
79
|
-
shortpath: MODEL_SHORTPATH,
|
|
80
|
-
circuit: MODEL_CIRCUIT,
|
|
81
|
-
subset: MODEL_SUBSET,
|
|
82
|
-
mds: MODEL_MDS,
|
|
83
|
-
};
|
|
79
|
+
/** Edge attribute whose declaration lets `model=mds` stand. @see lib/neatogen/neatoinit.c:neatoModel */
|
|
80
|
+
const EDGE_LEN_ATTR = 'len';
|
|
84
81
|
|
|
85
82
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
83
|
+
* C's `agattr_text(g, AGEDGE, "len", 0)` lookup: true when the edge attribute
|
|
84
|
+
* `len` has been declared anywhere in the root graph's dictionary. cgraph
|
|
85
|
+
* declares it by an `edge [len=...]` default in the root or any subgraph (even
|
|
86
|
+
* with no edge to use it) and by any edge carrying `len=`; the port keeps those
|
|
87
|
+
* three places apart, so this walks all of them. Native-verified: an
|
|
88
|
+
* `edge [len=2]` in a subgraph with no edges, or in a graph with no edges at
|
|
89
|
+
* all, suppresses the warning; `node [len=2]` does not.
|
|
88
90
|
*
|
|
89
|
-
* @see lib/neatogen/
|
|
91
|
+
* @see lib/neatogen/neatoinit.c:neatoModel (agattr_text lookup)
|
|
92
|
+
*/
|
|
93
|
+
function edgeLenDeclared(g: Graph): boolean {
|
|
94
|
+
if (g.edgeDefaults.has(EDGE_LEN_ATTR)) return true;
|
|
95
|
+
for (const e of g.edges) if (e.attrs.has(EDGE_LEN_ATTR)) return true;
|
|
96
|
+
for (const sub of g.subgraphs.values()) if (edgeLenDeclared(sub)) return true;
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Parse the root `model` attribute into a numeric model constant (init.ts
|
|
102
|
+
* numbering). Unset or empty is MODEL_SHORTPATH; `circuit`, `subset` and
|
|
103
|
+
* `shortpath` match case-sensitively. `mds` stands only when the edge attribute
|
|
104
|
+
* `len` is declared, else it warns and reverts to MODEL_SHORTPATH; any other
|
|
105
|
+
* value warns and is ignored. Call once, where neato_layout does.
|
|
106
|
+
*
|
|
107
|
+
* @see lib/neatogen/neatoinit.c:neatoModel (605-627)
|
|
90
108
|
*/
|
|
91
109
|
export function parseModel(g: Graph): number {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
110
|
+
const p = g.attrs.get('model');
|
|
111
|
+
if (p === undefined || p === '') return MODEL_SHORTPATH;
|
|
112
|
+
if (p === 'circuit') return MODEL_CIRCUIT;
|
|
113
|
+
if (p === 'subset') return MODEL_SUBSET;
|
|
114
|
+
if (p === 'shortpath') return MODEL_SHORTPATH;
|
|
115
|
+
if (p === 'mds') {
|
|
116
|
+
if (edgeLenDeclared(g)) return MODEL_MDS;
|
|
117
|
+
agwarningf(`edges in graph ${agNameOf(g.root)} have no len attribute. Hence, the mds model`);
|
|
118
|
+
agerr('prev', 'is inappropriate. Reverting to the shortest path model.');
|
|
119
|
+
return MODEL_SHORTPATH;
|
|
120
|
+
}
|
|
121
|
+
agwarningf(`Unknown value ${p} for attribute "model" in graph ${agNameOf(g.root)} - ignored`);
|
|
122
|
+
return MODEL_SHORTPATH;
|
|
96
123
|
}
|
|
97
124
|
|
|
98
125
|
// ---------------------------------------------------------------------------
|
|
@@ -175,7 +202,7 @@ export function neatoLayout(g: Graph): void {
|
|
|
175
202
|
if (comps.length > 1) {
|
|
176
203
|
layoutComponents(g, comps, { mode, model, am }, pinned);
|
|
177
204
|
} else {
|
|
178
|
-
solveModel(g, mode, model); // srand48 happens inside (C checkStart)
|
|
205
|
+
solveModel(g, mode, model, am); // srand48 happens inside (C checkStart)
|
|
179
206
|
maybeRemoveOverlap(g, am);
|
|
180
207
|
// C: spline_edges shifts pos to the origin, syncs coord, routes.
|
|
181
208
|
splineEdgesShifted(g);
|
|
@@ -242,7 +269,7 @@ function layoutComponents(
|
|
|
242
269
|
for (const gc of comps) {
|
|
243
270
|
// @see lib/neatogen/neatoinit.c:1398 (setEdgeType FUNCTION, per component)
|
|
244
271
|
setEdgeTypeFromAttr(gc, EDGETYPE_LINE);
|
|
245
|
-
solveModel(gc, solve.mode, solve.model);
|
|
272
|
+
solveModel(gc, solve.mode, solve.model, solve.am);
|
|
246
273
|
maybeRemoveOverlap(gc, solve.am);
|
|
247
274
|
splineEdgesShifted(gc);
|
|
248
275
|
}
|
package/src/layout/neato/init.ts
CHANGED
|
@@ -32,15 +32,15 @@ import { setEdgeLen } from './edge-len.js';
|
|
|
32
32
|
import { makeGraphDataC, graphHasLen } from './make-graph-data.js';
|
|
33
33
|
import type { DirectedVtxData } from './opt-arrangement.js';
|
|
34
34
|
import { stressMajorizationWithHierarchy } from './constrained-majorization.js';
|
|
35
|
+
import { stressMajorizationCola } from './stress-cola.js';
|
|
36
|
+
import { ipsepOptions } from './ipsep-opts.js';
|
|
37
|
+
import { AM_NONE, type AdjustData } from './fdp-adjust.js';
|
|
35
38
|
import { agerr } from '../../common/agerr.js';
|
|
36
39
|
|
|
37
40
|
export { makeGraphDataC, graphHasLen, checkStart };
|
|
38
41
|
import { mapbool } from '../dot/rank.js';
|
|
39
|
-
import {
|
|
40
|
-
|
|
41
|
-
computeWeightedApspPacked,
|
|
42
|
-
stressMajorizationKDMkernel,
|
|
43
|
-
} from './stress-kernel.js';
|
|
42
|
+
import { stressMajorizationKDMkernel } from './stress-kernel.js';
|
|
43
|
+
import { stressModelDij } from './stress-models.js';
|
|
44
44
|
import { lateDouble } from '../../common/nodeinit.js';
|
|
45
45
|
import { inputscaleDivisor } from '../../common/utils-inputscale.js';
|
|
46
46
|
import { parseNeatoDrawing, neatoSetAspectRatio } from './set-aspect.js';
|
|
@@ -108,10 +108,6 @@ export function neatoInitNode(n: Node, dim = DFLT_DIM): void {
|
|
|
108
108
|
if (!n.info.height && !plainShaped) n.info.height = 0.5;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
// ---------------------------------------------------------------------------
|
|
112
|
-
// userPos
|
|
113
|
-
// ---------------------------------------------------------------------------
|
|
114
|
-
|
|
115
111
|
/**
|
|
116
112
|
* Seed a node's initial position from its `pos=` attribute (C's P_SET),
|
|
117
113
|
* mirroring user_pos. Sets info.pos + info.posSet so hasPos is true and neato
|
|
@@ -137,10 +133,6 @@ export function userPos(n: Node): boolean {
|
|
|
137
133
|
return true;
|
|
138
134
|
}
|
|
139
135
|
|
|
140
|
-
// ---------------------------------------------------------------------------
|
|
141
|
-
// setSeed helpers
|
|
142
|
-
// ---------------------------------------------------------------------------
|
|
143
|
-
|
|
144
136
|
/**
|
|
145
137
|
* Classify the first character of `p` as 'alpha', 'digit', or 'other'.
|
|
146
138
|
*
|
|
@@ -203,10 +195,6 @@ export function setSeed(
|
|
|
203
195
|
return defaultMode;
|
|
204
196
|
}
|
|
205
197
|
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
|
-
// buildVtxData helpers
|
|
208
|
-
// ---------------------------------------------------------------------------
|
|
209
|
-
|
|
210
198
|
/**
|
|
211
199
|
* Assign sequential IDs to all nodes and return them in insertion order.
|
|
212
200
|
*
|
|
@@ -279,10 +267,6 @@ export function buildVtxData(g: Graph): VtxData[] {
|
|
|
279
267
|
return vtx;
|
|
280
268
|
}
|
|
281
269
|
|
|
282
|
-
// ---------------------------------------------------------------------------
|
|
283
|
-
// buildDCoords / writeBackCoords
|
|
284
|
-
// ---------------------------------------------------------------------------
|
|
285
|
-
|
|
286
270
|
/**
|
|
287
271
|
* Copy node positions from `n.info.pos` into per-axis Float64Array.
|
|
288
272
|
*
|
|
@@ -312,10 +296,6 @@ export function writeBackCoords(nodeList: Node[], dCoords: Float64Array[], dim:
|
|
|
312
296
|
}
|
|
313
297
|
}
|
|
314
298
|
|
|
315
|
-
// ---------------------------------------------------------------------------
|
|
316
|
-
// mapModelToStress
|
|
317
|
-
// ---------------------------------------------------------------------------
|
|
318
|
-
|
|
319
299
|
/**
|
|
320
300
|
* Map init.ts model constants to stress.ts model constants.
|
|
321
301
|
* Both use the same numeric values but are distinct exports.
|
|
@@ -327,10 +307,6 @@ export function mapModelToStress(model: number): number {
|
|
|
327
307
|
return 0;
|
|
328
308
|
}
|
|
329
309
|
|
|
330
|
-
// ---------------------------------------------------------------------------
|
|
331
|
-
// solveModel helpers
|
|
332
|
-
// ---------------------------------------------------------------------------
|
|
333
|
-
|
|
334
310
|
/** `MaxIter` per mode; `maxiter` goes through C `atoi` (no digits -> 0). @see neatoinit.c:1280-1287 */
|
|
335
311
|
export function neatoMaxIter(maxiter: string | undefined, mode: number, n: number): number {
|
|
336
312
|
if (maxiter !== undefined) return parseInt(maxiter, 10) || 0;
|
|
@@ -347,21 +323,22 @@ interface MajorizationCtx {
|
|
|
347
323
|
readonly g: Graph;
|
|
348
324
|
readonly mode: number;
|
|
349
325
|
readonly model: number;
|
|
350
|
-
readonly haveLen: boolean;
|
|
351
326
|
/** `opt_*` bits from `checkExp` and `checkStart`. */
|
|
352
327
|
readonly opts: number;
|
|
328
|
+
/** The layout's resolved overlap mode (C's `am`). */
|
|
329
|
+
readonly am: AdjustData;
|
|
353
330
|
}
|
|
354
331
|
|
|
355
332
|
/**
|
|
356
333
|
* The solver step of `majorization`: `stress_majorization_with_hierarchy` for
|
|
357
|
-
* MODE_HIER,
|
|
334
|
+
* MODE_HIER, `stress_majorization_cola` for MODE_IPSEP, else the kD_mkernel.
|
|
358
335
|
* Returns C's `rv`; the coordinates are left in `dCoords`.
|
|
359
336
|
* @see lib/neatogen/neatoinit.c:majorization
|
|
360
337
|
*/
|
|
361
338
|
function solveStress(
|
|
362
339
|
c: MajorizationCtx, vtx: DirectedVtxData[], dCoords: Float64Array[], nodeList: Node[],
|
|
363
340
|
): number {
|
|
364
|
-
const { g, mode, model,
|
|
341
|
+
const { g, mode, model, opts } = c;
|
|
365
342
|
const n = nodeList.length;
|
|
366
343
|
const maxi = neatoMaxIter(g.attrs.get('maxiter'), mode, n);
|
|
367
344
|
const epsilon = lateDouble(g.attrs.get('epsilon'), 1e-4, 0); // DFLT_TOLERANCE
|
|
@@ -370,28 +347,32 @@ function solveStress(
|
|
|
370
347
|
dim: DFLT_DIM, opts, model, maxi, epsilon, levelsGap: levelsGapOf(g),
|
|
371
348
|
});
|
|
372
349
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
350
|
+
if (mode === MODE_IPSEP) {
|
|
351
|
+
// mg is the root graph, g the component. @see neatoinit.c:1121-1170
|
|
352
|
+
const opt = ipsepOptions(g.root, g, nodeList, c.am);
|
|
353
|
+
return stressMajorizationCola(vtx, n, dCoords, nodeList, {
|
|
354
|
+
dim: DFLT_DIM, model, maxi, epsilon, opt,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
const Dij = stressModelDij(vtx, n, model); // inside kD_mkernel in C (AD-2)
|
|
377
358
|
return stressMajorizationKDMkernel(Dij, n, dCoords, nodeList, {
|
|
378
|
-
dim: DFLT_DIM, opts, maxi, epsilon,
|
|
359
|
+
dim: DFLT_DIM, opts, maxi, epsilon,
|
|
379
360
|
});
|
|
380
361
|
}
|
|
381
362
|
|
|
382
363
|
/** Run stress majorization and write positions back. @see lib/neatogen/neatoinit.c:majorization */
|
|
383
|
-
export function runMajorization(g: Graph, mode: number, model: number): void {
|
|
364
|
+
export function runMajorization(g: Graph, mode: number, model: number, am: AdjustData): void {
|
|
384
365
|
const nodeList = assignNodeIds(g);
|
|
385
366
|
setEdgeLen(g); // scan_graph_mode else-branch: ED_dist for major/hier/ipsep
|
|
386
367
|
const n = nodeList.length;
|
|
387
|
-
const haveLen = graphHasLen(g);
|
|
368
|
+
const haveLen = model !== MODEL_SUBSET && graphHasLen(g); // unused in reweight model, neatoinit.c:763
|
|
388
369
|
// C: srand48(seed) immediately before initLayout draws; hier starts from self
|
|
389
370
|
const init = checkStart(g, n, mode === MODE_HIER ? INIT_SELF : INIT_RANDOM);
|
|
390
371
|
const opts = checkExp(g) | (init === INIT_SELF ? STRESS_OPT_SMART_INIT : 0);
|
|
391
372
|
const haveDir = mode === MODE_HIER || mode === MODE_IPSEP;
|
|
392
373
|
const vtx = makeGraphDataC(g, nodeList, haveLen, haveDir, mode);
|
|
393
374
|
const dCoords = [new Float64Array(n), new Float64Array(n)];
|
|
394
|
-
if (solveStress({ g, mode, model,
|
|
375
|
+
if (solveStress({ g, mode, model, opts, am }, vtx, dCoords, nodeList) < 0) {
|
|
395
376
|
agerr('prev', 'layout aborted');
|
|
396
377
|
return;
|
|
397
378
|
}
|
|
@@ -400,10 +381,16 @@ export function runMajorization(g: Graph, mode: number, model: number): void {
|
|
|
400
381
|
}
|
|
401
382
|
}
|
|
402
383
|
|
|
384
|
+
/** The overlap mode when the caller has none to pass (AM_NONE). @see lib/neatogen/adjust.h */
|
|
385
|
+
const NO_ADJUST: AdjustData = { mode: AM_NONE, print: 'none', value: 0 };
|
|
386
|
+
|
|
403
387
|
/** Dispatch to the layout solver for the mode. @see lib/neatogen/neatoinit.c:neatoLayout */
|
|
404
|
-
export function solveModel(
|
|
405
|
-
|
|
406
|
-
|
|
388
|
+
export function solveModel(
|
|
389
|
+
g: Graph, mode: number, model: number, am: AdjustData = NO_ADJUST,
|
|
390
|
+
): void {
|
|
391
|
+
const nG = g.nodes.size;
|
|
392
|
+
if (nG < 2 || neatoMaxIter(g.attrs.get('maxiter'), mode, nG) < 0) return; // neatoinit.c:1290
|
|
393
|
+
assertSupported(g, mode);
|
|
407
394
|
if (mode === MODE_KK) return kkNeato(g, g.nodes.size, model);
|
|
408
395
|
if (mode === MODE_SGD) {
|
|
409
396
|
// C initial_positions -> checkStart: regular positions are kept
|
|
@@ -411,7 +398,7 @@ export function solveModel(g: Graph, mode: number, model: number): void {
|
|
|
411
398
|
sgdLayout(g, model);
|
|
412
399
|
return;
|
|
413
400
|
}
|
|
414
|
-
runMajorization(g, mode, model);
|
|
401
|
+
runMajorization(g, mode, model, am);
|
|
415
402
|
}
|
|
416
403
|
|
|
417
404
|
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `ipsep_options` `majorization` builds for `stress_majorization_cola`
|
|
5
|
+
* (mode=ipsep), and the cluster membership it carries.
|
|
6
|
+
*
|
|
7
|
+
* Inputs reuse the port's existing parsers: the overlap mode is the
|
|
8
|
+
* `AdjustData` that `graphAdjustMode` / `getAdjustMode` (`fdp-adjust.ts`,
|
|
9
|
+
* C `adjust.c:graphAdjustMode`) resolved once per layout, passed in as C
|
|
10
|
+
* passes `am`, so an unrecognized `overlap` value does not warn twice; the gap
|
|
11
|
+
* comes from `sepFactor` (`sep-factor.ts`, C `adjust.c:sepFactor`); `levelsgap`
|
|
12
|
+
* goes through `lateDouble` (C `late_double`) and `diredgeconstraints` through
|
|
13
|
+
* `mapbool`. The `Verbose` lines of the C block are not ported (the port has
|
|
14
|
+
* no Verbose), nor the `DEBUG_COLA` dump.
|
|
15
|
+
*
|
|
16
|
+
* Node indices follow `nodes` (C `ND_id`, assigned in `agfstnode(g)` order),
|
|
17
|
+
* which is the order of the layout's coordinate arrays.
|
|
18
|
+
*
|
|
19
|
+
* @see lib/neatogen/neatoinit.c:majorization (1121-1170)
|
|
20
|
+
* @see lib/neatogen/neatoinit.c:cluster_map
|
|
21
|
+
* @see lib/neatogen/digcola.h:ipsep_options
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { Box, Point } from '../../model/geom.js';
|
|
25
|
+
import type { Graph } from '../../model/graph.js';
|
|
26
|
+
import type { Node } from '../../model/node.js';
|
|
27
|
+
import { lateDouble } from '../../common/nodeinit.js';
|
|
28
|
+
import { mapbool, isACluster } from '../dot/rank.js';
|
|
29
|
+
import { nodesInSeq } from '../dot/decomp.js';
|
|
30
|
+
import { aggetGraph } from '../fdp/fdp-model.js';
|
|
31
|
+
import { AM_IPSEP, AM_VPSC, type AdjustData } from './fdp-adjust.js';
|
|
32
|
+
import { DFLT_MARGIN, sepFactor } from './sep-factor.js';
|
|
33
|
+
import type { ClusterData, IpsepOptions } from './quad-prog-vpsc.js';
|
|
34
|
+
|
|
35
|
+
/** `POINTS_PER_INCH`, the divisor of C's `PS2INCH` macro. @see lib/common/geom.h:PS2INCH */
|
|
36
|
+
const POINTS_PER_INCH = 72;
|
|
37
|
+
/** `strncasecmp(str, "hier", 4)`: the DiG-CoLa prefix of `diredgeconstraints`. */
|
|
38
|
+
const HIER_PREFIX = 'hier';
|
|
39
|
+
|
|
40
|
+
/** C `PS2INCH(a_points)`: `(a_points)/(double)POINTS_PER_INCH` (a divide, not `* 1/72`). */
|
|
41
|
+
const ps2inch = (points: number): number => points / POINTS_PER_INCH;
|
|
42
|
+
|
|
43
|
+
/** C `boxf` zero-initialised by `gv_calloc`. */
|
|
44
|
+
const zeroBox = (): Box => ({ ll: { x: 0, y: 0 }, ur: { x: 0, y: 0 } });
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Indices (in `agfstnode(g)` order) of a cluster's members. A member that is
|
|
48
|
+
* not in `g` gets C's fall-through index `agnnodes(g)`.
|
|
49
|
+
* @see lib/neatogen/neatoinit.c:cluster_map (inner loops)
|
|
50
|
+
*/
|
|
51
|
+
function memberIndices(subg: Graph, nodes: readonly Node[]): Int32Array {
|
|
52
|
+
const members = nodesInSeq(subg);
|
|
53
|
+
const c = new Int32Array(members.length);
|
|
54
|
+
members.forEach((n, k) => {
|
|
55
|
+
let ind = 0;
|
|
56
|
+
for (const gn of nodes) {
|
|
57
|
+
if (gn.id === n.id) break;
|
|
58
|
+
ind++;
|
|
59
|
+
}
|
|
60
|
+
c[k] = ind;
|
|
61
|
+
});
|
|
62
|
+
return c;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The top-level clusters of `mg`, in `agfstsubg` order. @see lib/common/utils.c:is_a_cluster */
|
|
66
|
+
function topClusters(mg: Graph): Graph[] {
|
|
67
|
+
return [...mg.subgraphs.values()].filter((s) => s !== mg.root && isACluster(s));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cluster membership of `g`'s nodes: one index array per top-level cluster of
|
|
72
|
+
* the master graph, the nodes in no cluster (`toplevel`), and a zeroed
|
|
73
|
+
* bounding box per cluster.
|
|
74
|
+
* @see lib/neatogen/neatoinit.c:cluster_map
|
|
75
|
+
*/
|
|
76
|
+
export function clusterMap(mg: Graph, g: Graph, nodes: readonly Node[]): ClusterData {
|
|
77
|
+
const nnodes = nodes.length;
|
|
78
|
+
// C bitarray_t of agnnodes(g) bits; an out-of-range set (a member not in g) is dropped.
|
|
79
|
+
const assigned = new Uint8Array(nnodes);
|
|
80
|
+
const clusters = topClusters(mg);
|
|
81
|
+
let ntoplevel = nnodes;
|
|
82
|
+
let nvars = 0;
|
|
83
|
+
const cs: Int32Array[] = [];
|
|
84
|
+
const cn = new Int32Array(clusters.length);
|
|
85
|
+
clusters.forEach((subg, i) => {
|
|
86
|
+
/* clusters are processed by separate calls to ordered_edges */
|
|
87
|
+
const c = memberIndices(subg, nodes);
|
|
88
|
+
cn[i] = c.length;
|
|
89
|
+
nvars += c.length;
|
|
90
|
+
cs.push(c);
|
|
91
|
+
for (const ind of c) {
|
|
92
|
+
assigned[ind] = 1;
|
|
93
|
+
ntoplevel--;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const toplevel = new Int32Array(ntoplevel);
|
|
97
|
+
let j = 0;
|
|
98
|
+
for (let i = 0; i < nnodes; i++) {
|
|
99
|
+
if (assigned[i] === 0) toplevel[j++] = i;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
nvars, nclusters: clusters.length, clustersizes: cn, clusters: cs,
|
|
103
|
+
ntoplevel, toplevel, bb: clusters.map(zeroBox),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* `diredgeconstraints`: true-ish -> 1 (directed edge constraints), a `hier`
|
|
109
|
+
* prefix (any case) -> 2 (DiG-CoLa level constraints), else 0.
|
|
110
|
+
* @see lib/neatogen/neatoinit.c:majorization (1130-1140)
|
|
111
|
+
*/
|
|
112
|
+
function diredgesOf(str: string | undefined): 0 | 1 | 2 {
|
|
113
|
+
if (mapbool(str)) return 1;
|
|
114
|
+
if (str !== undefined && str.slice(0, HIER_PREFIX.length).toLowerCase() === HIER_PREFIX) return 2;
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `overlap=ipsep` -> 1 (non-overlap constraints), `overlap=vpsc` -> 2 (remove
|
|
120
|
+
* overlaps after layout), else 0.
|
|
121
|
+
* @see lib/neatogen/neatoinit.c:majorization (1141-1150)
|
|
122
|
+
*/
|
|
123
|
+
function noverlapOf(am: AdjustData): 0 | 1 | 2 {
|
|
124
|
+
if (am.mode === AM_IPSEP) return 1;
|
|
125
|
+
if (am.mode === AM_VPSC) return 2;
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The gap enforced when removing overlap: twice the additive `sep` margin
|
|
131
|
+
* (`opt.gap` is the gap size, not the margin), else twice `DFLT_MARGIN`.
|
|
132
|
+
* @see lib/neatogen/neatoinit.c:majorization (1151-1157)
|
|
133
|
+
*/
|
|
134
|
+
function gapOf(g: Graph): Point {
|
|
135
|
+
const margin = sepFactor(g);
|
|
136
|
+
/* Multiply by 2 since opt.gap is the gap size, not the margin */
|
|
137
|
+
if (margin.doAdd) {
|
|
138
|
+
return { x: 2.0 * ps2inch(margin.x), y: 2.0 * ps2inch(margin.y) };
|
|
139
|
+
}
|
|
140
|
+
const gap = 2.0 * ps2inch(DFLT_MARGIN);
|
|
141
|
+
return { x: gap, y: gap };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The options `majorization` hands `stress_majorization_cola` for one
|
|
146
|
+
* component `g` of the master graph `mg`; `am` is the layout's resolved
|
|
147
|
+
* overlap mode.
|
|
148
|
+
* @see lib/neatogen/neatoinit.c:majorization (1121-1170)
|
|
149
|
+
*/
|
|
150
|
+
export function ipsepOptions(mg: Graph, g: Graph, nodes: readonly Node[], am: AdjustData): IpsepOptions {
|
|
151
|
+
const clusters = clusterMap(mg, g, nodes);
|
|
152
|
+
const edgeGap = lateDouble(aggetGraph(g, 'levelsgap'), 0.0, -Number.MAX_VALUE);
|
|
153
|
+
const diredges = diredgesOf(aggetGraph(g, 'diredgeconstraints'));
|
|
154
|
+
const noverlap = noverlapOf(am);
|
|
155
|
+
const gap = gapOf(g);
|
|
156
|
+
const nsize = nodes.map((v) => ({ x: v.info.width, y: v.info.height }));
|
|
157
|
+
return { diredges, edgeGap, noverlap, gap, nsize, clusters };
|
|
158
|
+
}
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Kamada-Kawai ideal-distance setup: Dijkstra over edge lengths with C's
|
|
4
4
|
* binary heap (`neato_enqueue`/`neato_dequeue`, `shortest_path`, `s1`,
|
|
5
|
-
* `make_spring`) and `mds_model`.
|
|
5
|
+
* `make_spring`), `subset_model` and `mds_model`.
|
|
6
6
|
*
|
|
7
7
|
* The C keeps the heap, its size and the source node in file-statics and the
|
|
8
8
|
* per-node `ND_dist`/`ND_hops`/`ND_heapindex` in node records; here they live
|
|
9
9
|
* in one {@link PathState} per run (no module state), indexed by `ND_id`.
|
|
10
10
|
*
|
|
11
11
|
* @see lib/neatogen/stuff.c
|
|
12
|
+
* @see lib/neatogen/neatoinit.c
|
|
12
13
|
*/
|
|
13
14
|
|
|
15
|
+
import type { Graph } from '../../model/graph.js';
|
|
16
|
+
import { computeApspArtificialWeights } from './kkutils.js';
|
|
17
|
+
import { makeGraphDataC } from './make-graph-data.js';
|
|
18
|
+
|
|
14
19
|
/** One neighbour of a node: its id and the edge's `ED_dist`. */
|
|
15
20
|
export interface Neighbour {
|
|
16
21
|
readonly id: number;
|
|
@@ -130,6 +135,23 @@ export function shortestPath(s: PathState): void {
|
|
|
130
135
|
for (let v = 0; v < s.n; v++) s1(s, v);
|
|
131
136
|
}
|
|
132
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Overwrite `GD_dist` (flat, nG*nG) with the artificial-weight distances.
|
|
140
|
+
* `makeGraphDataC` with neither `len` nor direction builds the rows of C's
|
|
141
|
+
* `makeGraphData(MODE_KK, MODEL_SUBSET)`; it reads `ND_id`, which
|
|
142
|
+
* `scan_graph_mode` has set.
|
|
143
|
+
* @see lib/neatogen/neatoinit.c:subset_model
|
|
144
|
+
*/
|
|
145
|
+
export function subsetModel(g: Graph, nG: number, dist: Float64Array): void {
|
|
146
|
+
const gp = makeGraphDataC(g, [...g.nodes.values()], false, false);
|
|
147
|
+
const Dij = computeApspArtificialWeights(gp, nG);
|
|
148
|
+
for (let i = 0; i < nG; i++) {
|
|
149
|
+
for (let j = 0; j < nG; j++) {
|
|
150
|
+
dist[i * nG + j] = Dij[i]![j]!;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
133
155
|
/**
|
|
134
156
|
* Overwrite `GD_dist` with edge lengths. C indexes the matrix with `AGSEQ`
|
|
135
157
|
* (1-based), so the last node's row falls outside the n*n allocation (heap
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* @see lib/neatogen/solve.c
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { fms } from '../../common/fma.js';
|
|
10
|
+
|
|
9
11
|
/** Pivots below this make the system ill-conditioned. @see solve.c:solve */
|
|
10
12
|
const MIN_PIVOT = 1.0e-10;
|
|
11
13
|
|
|
@@ -31,8 +33,8 @@ function eliminate(a: Float64Array, c: Float64Array, n: number, i: number): bool
|
|
|
31
33
|
swap(c, istar, i);
|
|
32
34
|
for (let ii = i + 1; ii < n; ii++) {
|
|
33
35
|
const pivot = a[ii * n + i]! / a[i * n + i]!;
|
|
34
|
-
c[ii]
|
|
35
|
-
for (let j = 0; j < n; j++) a[ii * n + j] = a[
|
|
36
|
+
c[ii] = fms(pivot, c[i]!, c[ii]!);
|
|
37
|
+
for (let j = 0; j < n; j++) a[ii * n + j] = fms(pivot, a[i * n + j]!, a[ii * n + j]!);
|
|
36
38
|
}
|
|
37
39
|
return true;
|
|
38
40
|
}
|
|
@@ -56,7 +58,7 @@ export function solve(a: Float64Array, b: Float64Array, c: Float64Array, n: numb
|
|
|
56
58
|
for (let k = 0; k < n - 1; k++) {
|
|
57
59
|
const m = n - k - 2;
|
|
58
60
|
b[m] = c[m]!;
|
|
59
|
-
for (let j = m + 1; j < n; j++) b[m]
|
|
61
|
+
for (let j = m + 1; j < n; j++) b[m] = fms(a[m * n + j]!, b[j]!, b[m]!);
|
|
60
62
|
b[m]! /= a[m * n + m]!;
|
|
61
63
|
}
|
|
62
64
|
c.set(csave);
|
package/src/layout/neato/kk.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* typed arrays here; the file-statics (`Epsilon`, `Damping`, `MaxIter`,
|
|
10
10
|
* `Initial_dist`) are fields of one {@link KkState} per run.
|
|
11
11
|
*
|
|
12
|
+
* The oracle's clang contracts `a + b*c` within one statement
|
|
13
|
+
* (`-ffp-contract=on`), so those sites go through `fma`/`fms`. The Newton step's
|
|
14
|
+
* iteration count depends on these last bits.
|
|
15
|
+
*
|
|
12
16
|
* Not ported: `Verbose` output (`total_e`, timers), `test_toggle` tracing,
|
|
13
17
|
* and `Reduce` (`-x`, a command-line flag this library has no counterpart for).
|
|
14
18
|
*
|
|
@@ -23,12 +27,14 @@ import type { Edge } from '../../model/edge.js';
|
|
|
23
27
|
import { buildOutEdgeIndex } from '../../model/node.js';
|
|
24
28
|
import { drand48 } from '../../common/random.js';
|
|
25
29
|
import { lateDouble } from '../../common/nodeinit.js';
|
|
26
|
-
import { checkStart, INIT_RANDOM, INIT_REGULAR } from './start.js';
|
|
27
|
-
import { MODEL_MDS } from './init.js';
|
|
30
|
+
import { checkStart, INIT_RANDOM, INIT_REGULAR, INIT_SELF, warnStartSelfOnce } from './start.js';
|
|
31
|
+
import { MODEL_CIRCUIT, MODEL_MDS, MODEL_SUBSET } from './init.js';
|
|
32
|
+
import { circuitModel } from './circuit.js';
|
|
28
33
|
import { solve } from './kk-solve.js';
|
|
29
34
|
import { lenattr } from './edge-len.js';
|
|
30
|
-
import { newPathState, shortestPath, mdsModel, type Neighbour } from './kk-paths.js';
|
|
31
|
-
import { agwarningf } from '../../common/agerr.js';
|
|
35
|
+
import { newPathState, shortestPath, mdsModel, subsetModel, type Neighbour } from './kk-paths.js';
|
|
36
|
+
import { agerr, agwarningf } from '../../common/agerr.js';
|
|
37
|
+
import { fma, fms } from '../../common/fma.js';
|
|
32
38
|
|
|
33
39
|
/** `Ndim`: layout dimension (this port lays out in 2-D only). */
|
|
34
40
|
const NDIM = 2;
|
|
@@ -89,7 +95,7 @@ function initialDist(g: Graph, total: number, epsilon: number): number {
|
|
|
89
95
|
const str = g.attrs.get('defaultdist');
|
|
90
96
|
if (str !== undefined && str !== '') return Math.max(epsilon, parseFloat(str) || 0);
|
|
91
97
|
const nE = g.edges.length;
|
|
92
|
-
return (total / (nE > 0 ? nE : 1)
|
|
98
|
+
return fma(total / (nE > 0 ? nE : 1), Math.sqrt(g.nodes.size), 1);
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
/** `getdouble(G, "epsilon", &Epsilon)`. @see lib/common/utils.c:getdouble */
|
|
@@ -146,7 +152,7 @@ function randompos(np: Node): void {
|
|
|
146
152
|
function initialPositions(g: Graph, st: KkState): void {
|
|
147
153
|
const init = checkStart(g, st.n, INIT_RANDOM);
|
|
148
154
|
if (init === INIT_REGULAR) return;
|
|
149
|
-
|
|
155
|
+
if (init === INIT_SELF) warnStartSelfOnce();
|
|
150
156
|
for (const np of st.nodes) {
|
|
151
157
|
if (np.info.posSet === true || np.info.pinned === true) continue;
|
|
152
158
|
randompos(np);
|
|
@@ -158,7 +164,7 @@ function distvec(p0: number[], p1: number[], del: Float64Array): number {
|
|
|
158
164
|
let dist = 0.0;
|
|
159
165
|
for (let k = 0; k < NDIM; k++) {
|
|
160
166
|
del[k] = p0[k]! - p1[k]!;
|
|
161
|
-
dist
|
|
167
|
+
dist = fma(del[k]!, del[k]!, dist);
|
|
162
168
|
}
|
|
163
169
|
return Math.sqrt(dist);
|
|
164
170
|
}
|
|
@@ -241,14 +247,15 @@ function d2e(st: KkState, m: number, M: Float64Array): void {
|
|
|
241
247
|
let sq = 0.0;
|
|
242
248
|
for (let k = 0; k < NDIM; k++) {
|
|
243
249
|
t[k] = vn.info.pos![k]! - vi.info.pos![k]!;
|
|
244
|
-
sq
|
|
250
|
+
sq = fma(t[k]!, t[k]!, sq);
|
|
245
251
|
}
|
|
246
252
|
const scale = 1 / Math.pow(sq, 1.5);
|
|
247
253
|
const K = st.spring[m * n + i]!;
|
|
248
254
|
const D = st.dist[m * n + i]!;
|
|
249
255
|
for (let k = 0; k < NDIM; k++) {
|
|
250
|
-
for (let l = 0; l < k; l++) M[l * NDIM + k]
|
|
251
|
-
|
|
256
|
+
for (let l = 0; l < k; l++) M[l * NDIM + k] = fma(K * D * t[k]! * t[l]!, scale, M[l * NDIM + k]!);
|
|
257
|
+
const inner = fms(D * fms(t[k]!, t[k]!, sq), scale, 1.0);
|
|
258
|
+
M[k * NDIM + k] = fma(K, inner, M[k * NDIM + k]!);
|
|
252
259
|
}
|
|
253
260
|
}
|
|
254
261
|
for (let k = 1; k < NDIM; k++) {
|
|
@@ -264,7 +271,7 @@ function chooseNode(st: KkState): number {
|
|
|
264
271
|
for (let i = 0; i < st.n; i++) {
|
|
265
272
|
if (st.nodes[i]!.info.pinned === true) continue;
|
|
266
273
|
let m = 0.0;
|
|
267
|
-
for (let k = 0; k < NDIM; k++) m
|
|
274
|
+
for (let k = 0; k < NDIM; k++) m = fma(st.sumT[i * NDIM + k]!, st.sumT[i * NDIM + k]!, m);
|
|
268
275
|
if (m > max) { choice = i; max = m; }
|
|
269
276
|
}
|
|
270
277
|
return max < st.epsilon * st.epsilon ? -1 : choice;
|
|
@@ -280,7 +287,7 @@ function moveNode(st: KkState, m: number): void {
|
|
|
280
287
|
solve(a, b, c, NDIM);
|
|
281
288
|
const pos = st.nodes[m]!.info.pos!;
|
|
282
289
|
for (let i = 0; i < NDIM; i++) {
|
|
283
|
-
b[i] = (
|
|
290
|
+
b[i] = fma(2 * (1 - st.damping), drand48(), st.damping) * b[i]!;
|
|
284
291
|
pos[i]! += b[i]!;
|
|
285
292
|
}
|
|
286
293
|
st.move++;
|
|
@@ -306,19 +313,44 @@ function mdsEdges(
|
|
|
306
313
|
}
|
|
307
314
|
|
|
308
315
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
316
|
+
* The distance-model dispatch at the head of `kkNeato`. The warning comes from
|
|
317
|
+
* `circuit_model`'s failure, which on the 1-based `AGSEQ` is every graph (see
|
|
318
|
+
* `circuit.ts`), so a connected graph prints "is disconnected" too; and under
|
|
319
|
+
* `pack` it prints once per component, under the component's own name.
|
|
320
|
+
* @see lib/neatogen/neatoinit.c:kkNeato (neatoinit.c:1243-1261)
|
|
321
|
+
*/
|
|
322
|
+
function kkModel(g: Graph, nG: number, model: number, run: ReturnType<typeof scanGraphMode>): void {
|
|
323
|
+
const { st, adj, ini, lens } = run;
|
|
324
|
+
const shortest = (): void => shortestPath(newPathState(st.n, st.dist, adj, ini));
|
|
325
|
+
if (model === MODEL_SUBSET) {
|
|
326
|
+
subsetModel(g, nG, st.dist);
|
|
327
|
+
} else if (model === MODEL_CIRCUIT) {
|
|
328
|
+
if (!circuitModel(g, nG, st.dist, lens)) {
|
|
329
|
+
agwarningf(`graph ${agNameOf(g)} is disconnected. Hence, the circuit model`);
|
|
330
|
+
agerr('prev', 'is undefined. Reverting to the shortest path model.');
|
|
331
|
+
agerr('prev', 'Alternatively, consider running neato using -Gpack=true or decomposing');
|
|
332
|
+
agerr('prev', 'the graph into connected components.');
|
|
333
|
+
shortest();
|
|
334
|
+
}
|
|
335
|
+
} else if (model === MODEL_MDS) {
|
|
336
|
+
shortest();
|
|
337
|
+
mdsModel(st.dist, st.n, mdsEdges(g, st.nodes, lens));
|
|
338
|
+
} else {
|
|
339
|
+
shortest();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Solve the layout with Kamada-Kawai gradient descent.
|
|
312
345
|
* @see lib/neatogen/neatoinit.c:kkNeato
|
|
313
346
|
*/
|
|
314
347
|
export function kkNeato(g: Graph, nG: number, model: number): void {
|
|
315
348
|
const maxiter = g.attrs.get('maxiter');
|
|
316
349
|
const maxIter = maxiter !== undefined ? atoi(maxiter) : ITERATIONS_PER_NODE * g.nodes.size;
|
|
317
350
|
if (nG < 2 || maxIter < 0) return;
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
solveModel(g, st);
|
|
351
|
+
const run = scanGraphMode(g, maxIter);
|
|
352
|
+
kkModel(g, nG, model, run);
|
|
353
|
+
initialPositions(g, run.st);
|
|
354
|
+
diffeqModel(g, run.st);
|
|
355
|
+
solveModel(g, run.st);
|
|
324
356
|
}
|