@knowvah/dot-engine 2.8.1 → 2.9.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.
Files changed (335) hide show
  1. package/dist/common/graph-init.d.ts.map +1 -1
  2. package/dist/common/poly-gencode.d.ts.map +1 -1
  3. package/dist/common/poly-init.d.ts +3 -2
  4. package/dist/common/poly-init.d.ts.map +1 -1
  5. package/dist/common/safefile.d.ts +23 -0
  6. package/dist/common/safefile.d.ts.map +1 -0
  7. package/dist/common/shapes.d.ts +6 -6
  8. package/dist/common/shapes.d.ts.map +1 -1
  9. package/dist/gvc/device.d.ts.map +1 -1
  10. package/dist/gvc/image-type.d.ts +41 -0
  11. package/dist/gvc/image-type.d.ts.map +1 -0
  12. package/dist/gvc/render-usershape.d.ts +8 -0
  13. package/dist/gvc/render-usershape.d.ts.map +1 -1
  14. package/dist/gvc/usershape.d.ts +23 -1
  15. package/dist/gvc/usershape.d.ts.map +1 -1
  16. package/dist/index.js +8328 -6979
  17. package/dist/index.js.map +4 -4
  18. package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts +118 -0
  19. package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts.map +1 -0
  20. package/dist/layout/neato/__fixtures__/stress-models.d.ts +39 -0
  21. package/dist/layout/neato/__fixtures__/stress-models.d.ts.map +1 -0
  22. package/dist/layout/neato/circuit.d.ts +10 -0
  23. package/dist/layout/neato/circuit.d.ts.map +1 -0
  24. package/dist/layout/neato/init.d.ts +3 -2
  25. package/dist/layout/neato/init.d.ts.map +1 -1
  26. package/dist/layout/neato/ipsep-opts.d.ts +19 -0
  27. package/dist/layout/neato/ipsep-opts.d.ts.map +1 -0
  28. package/dist/layout/neato/lu.d.ts +35 -0
  29. package/dist/layout/neato/lu.d.ts.map +1 -0
  30. package/dist/layout/neato/matinv.d.ts +8 -0
  31. package/dist/layout/neato/matinv.d.ts.map +1 -0
  32. package/dist/layout/neato/quad-prog-vpsc-overlap.d.ts +35 -0
  33. package/dist/layout/neato/quad-prog-vpsc-overlap.d.ts.map +1 -0
  34. package/dist/layout/neato/quad-prog-vpsc.d.ts +110 -0
  35. package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -0
  36. package/dist/layout/neato/start.d.ts +5 -4
  37. package/dist/layout/neato/start.d.ts.map +1 -1
  38. package/dist/layout/neato/stress-cola.d.ts +65 -0
  39. package/dist/layout/neato/stress-cola.d.ts.map +1 -0
  40. package/dist/layout/neato/stress-kernel.d.ts +0 -2
  41. package/dist/layout/neato/stress-kernel.d.ts.map +1 -1
  42. package/dist/layout/neato/stress-models.d.ts +48 -0
  43. package/dist/layout/neato/stress-models.d.ts.map +1 -0
  44. package/dist/layout/neato/vpsc-adjust.d.ts +7 -8
  45. package/dist/layout/neato/vpsc-adjust.d.ts.map +1 -1
  46. package/dist/render/color-resolve.d.ts +14 -0
  47. package/dist/render/color-resolve.d.ts.map +1 -1
  48. package/dist/render/dot/edge-draw.d.ts.map +1 -1
  49. package/dist/render/svg-arrow-ops.d.ts +21 -4
  50. package/dist/render/svg-arrow-ops.d.ts.map +1 -1
  51. package/dist/render/svg-edge-arrows.d.ts +3 -3
  52. package/dist/render/svg-edge-arrows.d.ts.map +1 -1
  53. package/dist/render/svg-helpers.d.ts +1 -1
  54. package/dist/render/svg-helpers.d.ts.map +1 -1
  55. package/dist/render/svg.d.ts.map +1 -1
  56. package/dist/render.js +8318 -6969
  57. package/dist/render.js.map +4 -4
  58. package/package.json +1 -1
  59. package/src/common/graph-init.ts +4 -2
  60. package/src/common/poly-gencode.ts +2 -1
  61. package/src/common/poly-init.ts +21 -12
  62. package/src/common/safefile.ts +74 -0
  63. package/src/common/shapes.ts +43 -22
  64. package/src/gvc/__fixtures__/p7/colors/98-point.gv +1 -0
  65. package/src/gvc/__fixtures__/p7/colors/98-point.json +54 -0
  66. package/src/gvc/__fixtures__/p7/colors/98-point.json.stderr +1 -0
  67. package/src/gvc/__fixtures__/p7/colors/98-point.svg +17 -0
  68. package/src/gvc/__fixtures__/p7/colors/98-point.svg.stderr +1 -0
  69. package/src/gvc/__fixtures__/p7/colors/98-point.xdot +13 -0
  70. package/src/gvc/__fixtures__/p7/colors/98-point.xdot.stderr +1 -0
  71. package/src/gvc/__fixtures__/p7/colors/99-edge-color.gv +1 -0
  72. package/src/gvc/__fixtures__/p7/colors/99-edge-color.json +150 -0
  73. package/src/gvc/__fixtures__/p7/colors/99-edge-color.json.stderr +1 -0
  74. package/src/gvc/__fixtures__/p7/colors/99-edge-color.svg +30 -0
  75. package/src/gvc/__fixtures__/p7/colors/99-edge-color.svg.stderr +1 -0
  76. package/src/gvc/__fixtures__/p7/colors/99-edge-color.xdot +22 -0
  77. package/src/gvc/__fixtures__/p7/colors/99-edge-color.xdot.stderr +1 -0
  78. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.gv +1 -0
  79. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.json +149 -0
  80. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.json.stderr +0 -0
  81. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.svg +30 -0
  82. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.svg.stderr +0 -0
  83. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.xdot +21 -0
  84. package/src/gvc/__fixtures__/p7/colors/99-edge-red-colon.xdot.stderr +0 -0
  85. package/src/gvc/__fixtures__/p7/colors/99-edge.gv +1 -0
  86. package/src/gvc/__fixtures__/p7/colors/99-edge.json +149 -0
  87. package/src/gvc/__fixtures__/p7/colors/99-edge.json.stderr +1 -0
  88. package/src/gvc/__fixtures__/p7/colors/99-edge.svg +30 -0
  89. package/src/gvc/__fixtures__/p7/colors/99-edge.svg.stderr +1 -0
  90. package/src/gvc/__fixtures__/p7/colors/99-edge.xdot +21 -0
  91. package/src/gvc/__fixtures__/p7/colors/99-edge.xdot.stderr +1 -0
  92. package/src/gvc/__fixtures__/p7/images/100-rotate.gv +1 -0
  93. package/src/gvc/__fixtures__/p7/images/100-rotate.svg +19 -0
  94. package/src/gvc/__fixtures__/p7/images/100-rotate.svg.stderr +0 -0
  95. package/src/gvc/__fixtures__/p7/images/101-bad.cmapx +2 -0
  96. package/src/gvc/__fixtures__/p7/images/101-bad.cmapx.stderr +2 -0
  97. package/src/gvc/__fixtures__/p7/images/101-bad.dot +8 -0
  98. package/src/gvc/__fixtures__/p7/images/101-bad.dot.stderr +2 -0
  99. package/src/gvc/__fixtures__/p7/images/101-bad.gv +1 -0
  100. package/src/gvc/__fixtures__/p7/images/101-bad.json +68 -0
  101. package/src/gvc/__fixtures__/p7/images/101-bad.json.stderr +2 -0
  102. package/src/gvc/__fixtures__/p7/images/101-bad.plain +3 -0
  103. package/src/gvc/__fixtures__/p7/images/101-bad.plain.stderr +2 -0
  104. package/src/gvc/__fixtures__/p7/images/101-bad.svg +18 -0
  105. package/src/gvc/__fixtures__/p7/images/101-bad.svg.stderr +2 -0
  106. package/src/gvc/__fixtures__/p7/images/101-bad.xdot +13 -0
  107. package/src/gvc/__fixtures__/p7/images/101-bad.xdot.stderr +2 -0
  108. package/src/gvc/__fixtures__/p7/images/101-gif.cmapx +2 -0
  109. package/src/gvc/__fixtures__/p7/images/101-gif.cmapx.stderr +0 -0
  110. package/src/gvc/__fixtures__/p7/images/101-gif.dot +8 -0
  111. package/src/gvc/__fixtures__/p7/images/101-gif.dot.stderr +0 -0
  112. package/src/gvc/__fixtures__/p7/images/101-gif.gv +1 -0
  113. package/src/gvc/__fixtures__/p7/images/101-gif.json +70 -0
  114. package/src/gvc/__fixtures__/p7/images/101-gif.json.stderr +1 -0
  115. package/src/gvc/__fixtures__/p7/images/101-gif.plain +3 -0
  116. package/src/gvc/__fixtures__/p7/images/101-gif.plain.stderr +0 -0
  117. package/src/gvc/__fixtures__/p7/images/101-gif.svg +19 -0
  118. package/src/gvc/__fixtures__/p7/images/101-gif.svg.stderr +0 -0
  119. package/src/gvc/__fixtures__/p7/images/101-gif.xdot +13 -0
  120. package/src/gvc/__fixtures__/p7/images/101-gif.xdot.stderr +0 -0
  121. package/src/gvc/__fixtures__/p7/images/101-jpg.cmapx +2 -0
  122. package/src/gvc/__fixtures__/p7/images/101-jpg.cmapx.stderr +0 -0
  123. package/src/gvc/__fixtures__/p7/images/101-jpg.dot +8 -0
  124. package/src/gvc/__fixtures__/p7/images/101-jpg.dot.stderr +0 -0
  125. package/src/gvc/__fixtures__/p7/images/101-jpg.gv +1 -0
  126. package/src/gvc/__fixtures__/p7/images/101-jpg.json +70 -0
  127. package/src/gvc/__fixtures__/p7/images/101-jpg.json.stderr +1 -0
  128. package/src/gvc/__fixtures__/p7/images/101-jpg.plain +3 -0
  129. package/src/gvc/__fixtures__/p7/images/101-jpg.plain.stderr +0 -0
  130. package/src/gvc/__fixtures__/p7/images/101-jpg.svg +19 -0
  131. package/src/gvc/__fixtures__/p7/images/101-jpg.svg.stderr +0 -0
  132. package/src/gvc/__fixtures__/p7/images/101-jpg.xdot +13 -0
  133. package/src/gvc/__fixtures__/p7/images/101-jpg.xdot.stderr +0 -0
  134. package/src/gvc/__fixtures__/p7/images/101-png.cmapx +2 -0
  135. package/src/gvc/__fixtures__/p7/images/101-png.cmapx.stderr +0 -0
  136. package/src/gvc/__fixtures__/p7/images/101-png.dot +8 -0
  137. package/src/gvc/__fixtures__/p7/images/101-png.dot.stderr +0 -0
  138. package/src/gvc/__fixtures__/p7/images/101-png.gv +1 -0
  139. package/src/gvc/__fixtures__/p7/images/101-png.json +70 -0
  140. package/src/gvc/__fixtures__/p7/images/101-png.json.stderr +1 -0
  141. package/src/gvc/__fixtures__/p7/images/101-png.plain +3 -0
  142. package/src/gvc/__fixtures__/p7/images/101-png.plain.stderr +0 -0
  143. package/src/gvc/__fixtures__/p7/images/101-png.svg +19 -0
  144. package/src/gvc/__fixtures__/p7/images/101-png.svg.stderr +0 -0
  145. package/src/gvc/__fixtures__/p7/images/101-png.xdot +13 -0
  146. package/src/gvc/__fixtures__/p7/images/101-png.xdot.stderr +0 -0
  147. package/src/gvc/__fixtures__/p7/images/101-svg.cmapx +2 -0
  148. package/src/gvc/__fixtures__/p7/images/101-svg.cmapx.stderr +0 -0
  149. package/src/gvc/__fixtures__/p7/images/101-svg.dot +8 -0
  150. package/src/gvc/__fixtures__/p7/images/101-svg.dot.stderr +0 -0
  151. package/src/gvc/__fixtures__/p7/images/101-svg.gv +1 -0
  152. package/src/gvc/__fixtures__/p7/images/101-svg.json +70 -0
  153. package/src/gvc/__fixtures__/p7/images/101-svg.json.stderr +1 -0
  154. package/src/gvc/__fixtures__/p7/images/101-svg.plain +3 -0
  155. package/src/gvc/__fixtures__/p7/images/101-svg.plain.stderr +0 -0
  156. package/src/gvc/__fixtures__/p7/images/101-svg.svg +19 -0
  157. package/src/gvc/__fixtures__/p7/images/101-svg.svg.stderr +0 -0
  158. package/src/gvc/__fixtures__/p7/images/101-svg.xdot +13 -0
  159. package/src/gvc/__fixtures__/p7/images/101-svg.xdot.stderr +0 -0
  160. package/src/gvc/__fixtures__/p7/images/101-svgbare.cmapx +2 -0
  161. package/src/gvc/__fixtures__/p7/images/101-svgbare.cmapx.stderr +2 -0
  162. package/src/gvc/__fixtures__/p7/images/101-svgbare.dot +8 -0
  163. package/src/gvc/__fixtures__/p7/images/101-svgbare.dot.stderr +2 -0
  164. package/src/gvc/__fixtures__/p7/images/101-svgbare.gv +1 -0
  165. package/src/gvc/__fixtures__/p7/images/101-svgbare.json +68 -0
  166. package/src/gvc/__fixtures__/p7/images/101-svgbare.json.stderr +2 -0
  167. package/src/gvc/__fixtures__/p7/images/101-svgbare.plain +3 -0
  168. package/src/gvc/__fixtures__/p7/images/101-svgbare.plain.stderr +2 -0
  169. package/src/gvc/__fixtures__/p7/images/101-svgbare.svg +18 -0
  170. package/src/gvc/__fixtures__/p7/images/101-svgbare.svg.stderr +2 -0
  171. package/src/gvc/__fixtures__/p7/images/101-svgbare.xdot +13 -0
  172. package/src/gvc/__fixtures__/p7/images/101-svgbare.xdot.stderr +2 -0
  173. package/src/gvc/__fixtures__/p7/images/102-ip-abs.gv +1 -0
  174. package/src/gvc/__fixtures__/p7/images/102-ip-abs.svg +18 -0
  175. package/src/gvc/__fixtures__/p7/images/102-ip-abs.svg.stderr +2 -0
  176. package/src/gvc/__fixtures__/p7/images/102-ip-abs.xdot +14 -0
  177. package/src/gvc/__fixtures__/p7/images/102-ip-abs.xdot.stderr +2 -0
  178. package/src/gvc/__fixtures__/p7/images/102-ip-found.gv +1 -0
  179. package/src/gvc/__fixtures__/p7/images/102-ip-found.svg +19 -0
  180. package/src/gvc/__fixtures__/p7/images/102-ip-found.svg.stderr +0 -0
  181. package/src/gvc/__fixtures__/p7/images/102-ip-found.xdot +14 -0
  182. package/src/gvc/__fixtures__/p7/images/102-ip-found.xdot.stderr +0 -0
  183. package/src/gvc/__fixtures__/p7/images/102-ip-missing.gv +1 -0
  184. package/src/gvc/__fixtures__/p7/images/102-ip-missing.svg +18 -0
  185. package/src/gvc/__fixtures__/p7/images/102-ip-missing.svg.stderr +2 -0
  186. package/src/gvc/__fixtures__/p7/images/102-ip-missing.xdot +14 -0
  187. package/src/gvc/__fixtures__/p7/images/102-ip-missing.xdot.stderr +2 -0
  188. package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.gv +1 -0
  189. package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.svg +18 -0
  190. package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.svg.stderr +2 -0
  191. package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.xdot +15 -0
  192. package/src/gvc/__fixtures__/p7/images/102-ip-shapefile.xdot.stderr +2 -0
  193. package/src/gvc/__fixtures__/p7/images/102-ip-two.gv +1 -0
  194. package/src/gvc/__fixtures__/p7/images/102-ip-two.svg +19 -0
  195. package/src/gvc/__fixtures__/p7/images/102-ip-two.svg.stderr +0 -0
  196. package/src/gvc/__fixtures__/p7/images/102-ip-two.xdot +14 -0
  197. package/src/gvc/__fixtures__/p7/images/102-ip-two.xdot.stderr +0 -0
  198. package/src/gvc/__fixtures__/p7/images/97-custom.gv +1 -0
  199. package/src/gvc/__fixtures__/p7/images/97-custom.svg +18 -0
  200. package/src/gvc/__fixtures__/p7/images/97-custom.svg.stderr +1 -0
  201. package/src/gvc/__fixtures__/p7/images/97-custom.xdot +13 -0
  202. package/src/gvc/__fixtures__/p7/images/97-custom.xdot.stderr +1 -0
  203. package/src/gvc/__fixtures__/p7/images/97-nosuch-image.gv +1 -0
  204. package/src/gvc/__fixtures__/p7/images/97-nosuch-image.svg +19 -0
  205. package/src/gvc/__fixtures__/p7/images/97-nosuch-image.svg.stderr +1 -0
  206. package/src/gvc/__fixtures__/p7/images/97-nosuch-image.xdot +14 -0
  207. package/src/gvc/__fixtures__/p7/images/97-nosuch-image.xdot.stderr +1 -0
  208. package/src/gvc/__fixtures__/p7/images/bad.png +1 -0
  209. package/src/gvc/__fixtures__/p7/images/d/r.png +0 -0
  210. package/src/gvc/__fixtures__/p7/images/d2/r.png +0 -0
  211. package/src/gvc/__fixtures__/p7/images/g.gif +0 -0
  212. package/src/gvc/__fixtures__/p7/images/graphs-val_val.gv +10 -0
  213. package/src/gvc/__fixtures__/p7/images/graphs-val_val.svg +25 -0
  214. package/src/gvc/__fixtures__/p7/images/graphs-val_val.svg.stderr +3 -0
  215. package/src/gvc/__fixtures__/p7/images/graphs-val_val.xdot +30 -0
  216. package/src/gvc/__fixtures__/p7/images/graphs-val_val.xdot.stderr +3 -0
  217. package/src/gvc/__fixtures__/p7/images/j.jpg +0 -0
  218. package/src/gvc/__fixtures__/p7/images/r.png +0 -0
  219. package/src/gvc/__fixtures__/p7/images/s.svg +2 -0
  220. package/src/gvc/__fixtures__/p7/images/sb.svg +1 -0
  221. package/src/gvc/__fixtures__/p7/images/t.png +0 -0
  222. package/src/gvc/__fixtures__/p7/regen.sh +23 -0
  223. package/src/gvc/device.ts +11 -4
  224. package/src/gvc/image-type.ts +122 -0
  225. package/src/gvc/render-usershape.ts +52 -1
  226. package/src/gvc/usershape.ts +40 -1
  227. package/src/layout/neato/__fixtures__/ipsep/big-dired.gv +243 -0
  228. package/src/layout/neato/__fixtures__/ipsep/big-dired.trace +55 -0
  229. package/src/layout/neato/__fixtures__/ipsep/big-dired.xdot +1832 -0
  230. package/src/layout/neato/__fixtures__/ipsep/big-dired.xdot.stderr +0 -0
  231. package/src/layout/neato/__fixtures__/ipsep/cluster.gv +1 -0
  232. package/src/layout/neato/__fixtures__/ipsep/cluster.trace +95 -0
  233. package/src/layout/neato/__fixtures__/ipsep/cluster.xdot +58 -0
  234. package/src/layout/neato/__fixtures__/ipsep/cluster.xdot.stderr +0 -0
  235. package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.gv +1 -0
  236. package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.trace +40 -0
  237. package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.xdot +72 -0
  238. package/src/layout/neato/__fixtures__/ipsep/dired-hier-levelsgap.xdot.stderr +0 -0
  239. package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.gv +1 -0
  240. package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.trace +43 -0
  241. package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.xdot +72 -0
  242. package/src/layout/neato/__fixtures__/ipsep/dired-hier-sep.xdot.stderr +0 -0
  243. package/src/layout/neato/__fixtures__/ipsep/dired-hier.gv +1 -0
  244. package/src/layout/neato/__fixtures__/ipsep/dired-hier.trace +43 -0
  245. package/src/layout/neato/__fixtures__/ipsep/dired-hier.xdot +71 -0
  246. package/src/layout/neato/__fixtures__/ipsep/dired-hier.xdot.stderr +0 -0
  247. package/src/layout/neato/__fixtures__/ipsep/dired-true.gv +1 -0
  248. package/src/layout/neato/__fixtures__/ipsep/dired-true.trace +51 -0
  249. package/src/layout/neato/__fixtures__/ipsep/dired-true.xdot +71 -0
  250. package/src/layout/neato/__fixtures__/ipsep/dired-true.xdot.stderr +0 -0
  251. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.gv +1 -0
  252. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.trace +41 -0
  253. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +77 -0
  254. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot.stderr +0 -0
  255. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.gv +1 -0
  256. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.trace +41 -0
  257. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +68 -0
  258. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot.stderr +0 -0
  259. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.gv +1 -0
  260. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.trace +42 -0
  261. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +110 -0
  262. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot.stderr +0 -0
  263. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.gv +1 -0
  264. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.trace +49 -0
  265. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +108 -0
  266. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot.stderr +0 -0
  267. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.gv +1 -0
  268. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.trace +43 -0
  269. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +83 -0
  270. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot.stderr +0 -0
  271. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.gv +1 -0
  272. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.trace +49 -0
  273. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +48 -0
  274. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot.stderr +0 -0
  275. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.gv +1 -0
  276. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.trace +45 -0
  277. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +47 -0
  278. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot.stderr +0 -0
  279. package/src/layout/neato/__fixtures__/ipsep/len-dired.gv +1 -0
  280. package/src/layout/neato/__fixtures__/ipsep/len-dired.trace +44 -0
  281. package/src/layout/neato/__fixtures__/ipsep/len-dired.xdot +66 -0
  282. package/src/layout/neato/__fixtures__/ipsep/len-dired.xdot.stderr +0 -0
  283. package/src/layout/neato/__fixtures__/ipsep/model-circuit.gv +1 -0
  284. package/src/layout/neato/__fixtures__/ipsep/model-circuit.trace +46 -0
  285. package/src/layout/neato/__fixtures__/ipsep/model-circuit.xdot +83 -0
  286. package/src/layout/neato/__fixtures__/ipsep/model-circuit.xdot.stderr +0 -0
  287. package/src/layout/neato/__fixtures__/ipsep/model-mds-len.gv +1 -0
  288. package/src/layout/neato/__fixtures__/ipsep/model-mds-len.trace +52 -0
  289. package/src/layout/neato/__fixtures__/ipsep/model-mds-len.xdot +72 -0
  290. package/src/layout/neato/__fixtures__/ipsep/model-mds-len.xdot.stderr +0 -0
  291. package/src/layout/neato/__fixtures__/ipsep/model-mds.gv +1 -0
  292. package/src/layout/neato/__fixtures__/ipsep/model-mds.trace +52 -0
  293. package/src/layout/neato/__fixtures__/ipsep/model-mds.xdot +83 -0
  294. package/src/layout/neato/__fixtures__/ipsep/model-mds.xdot.stderr +2 -0
  295. package/src/layout/neato/__fixtures__/ipsep/model-subset.gv +1 -0
  296. package/src/layout/neato/__fixtures__/ipsep/model-subset.trace +49 -0
  297. package/src/layout/neato/__fixtures__/ipsep/model-subset.xdot +83 -0
  298. package/src/layout/neato/__fixtures__/ipsep/model-subset.xdot.stderr +0 -0
  299. package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.gv +1 -0
  300. package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.trace +211 -0
  301. package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.xdot +60 -0
  302. package/src/layout/neato/__fixtures__/ipsep/overlap-ipsep.xdot.stderr +0 -0
  303. package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.gv +1 -0
  304. package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.trace +50 -0
  305. package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.xdot +60 -0
  306. package/src/layout/neato/__fixtures__/ipsep/overlap-vpsc.xdot.stderr +0 -0
  307. package/src/layout/neato/__fixtures__/ipsep/start-self-dired.gv +1 -0
  308. package/src/layout/neato/__fixtures__/ipsep/start-self-dired.trace +51 -0
  309. package/src/layout/neato/__fixtures__/ipsep/start-self-dired.xdot +72 -0
  310. package/src/layout/neato/__fixtures__/ipsep/start-self-dired.xdot.stderr +0 -0
  311. package/src/layout/neato/__fixtures__/ipsep/start-self.gv +1 -0
  312. package/src/layout/neato/__fixtures__/ipsep/start-self.trace +43 -0
  313. package/src/layout/neato/__fixtures__/ipsep/start-self.xdot +84 -0
  314. package/src/layout/neato/__fixtures__/ipsep/start-self.xdot.stderr +0 -0
  315. package/src/layout/neato/__fixtures__/quad-prog-vpsc.ts +109 -0
  316. package/src/layout/neato/__fixtures__/stress-models.ts +64 -0
  317. package/src/layout/neato/circuit.ts +31 -0
  318. package/src/layout/neato/index.ts +2 -2
  319. package/src/layout/neato/init.ts +25 -34
  320. package/src/layout/neato/ipsep-opts.ts +158 -0
  321. package/src/layout/neato/lu.ts +189 -0
  322. package/src/layout/neato/matinv.ts +37 -0
  323. package/src/layout/neato/quad-prog-vpsc-overlap.ts +365 -0
  324. package/src/layout/neato/quad-prog-vpsc.ts +416 -0
  325. package/src/layout/neato/start.ts +9 -24
  326. package/src/layout/neato/stress-cola.ts +497 -0
  327. package/src/layout/neato/stress-kernel.ts +1 -17
  328. package/src/layout/neato/stress-models.ts +212 -0
  329. package/src/layout/neato/vpsc-adjust.ts +35 -66
  330. package/src/render/color-resolve.ts +25 -2
  331. package/src/render/dot/edge-draw.ts +7 -4
  332. package/src/render/svg-arrow-ops.ts +35 -19
  333. package/src/render/svg-edge-arrows.ts +7 -6
  334. package/src/render/svg-helpers.ts +19 -11
  335. package/src/render/svg.ts +15 -3
@@ -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
+ }
@@ -2,10 +2,11 @@
2
2
  /**
3
3
  * Neato `start` handling (setSeed / initRegular / checkStart) and the
4
4
  * fail-loud checks for the neato init features this port does not have
5
- * (smart init for the stress path, the subset/circuit distance models, ipsep
6
- * with constraints). mode=hier runs `stress_majorization_with_hierarchy`; its
7
- * own unported branches (subset/circuit models, the smart-init fallback
8
- * without a hierarchy) are loud in constrained-majorization.ts.
5
+ * (smart init for the stress path, the subset/circuit distance models).
6
+ * mode=hier runs `stress_majorization_with_hierarchy`; its own unported
7
+ * branches (subset/circuit models, the smart-init fallback without a
8
+ * hierarchy) are loud in constrained-majorization.ts. mode=ipsep runs
9
+ * `stress_majorization_cola`, which ports both models and takes no smart init.
9
10
  *
10
11
  * Each loud check sits where neato's C branches into the unported code and
11
12
  * fires only for the modes whose C path reaches it (ADR-3).
@@ -18,7 +19,6 @@ import { agNameOf } from '../../model/cgraph-ops.js';
18
19
  import type { Graph } from '../../model/graph.js';
19
20
  import { srand48 } from '../../common/random.js';
20
21
  import { registerRenderState } from '../../common/render-state.js';
21
- import { mapbool, isACluster } from '../dot/rank.js';
22
22
  import { getPack } from '../pack/index.js';
23
23
  import {
24
24
  MODE_KK, MODE_MAJOR, MODE_HIER, MODE_IPSEP, MODE_SGD,
@@ -114,14 +114,6 @@ function unsupported(attr: string, value: string, what: string): never {
114
114
  throw new RenderError(`${attr}=${value}: ${what} is not supported yet`, 'UNSUPPORTED_FEATURE');
115
115
  }
116
116
 
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
117
  /** @see lib/neatogen/neatoinit.c:1290 (MaxIter < 0 returns before any solver) */
126
118
  function maxIterNegative(g: Graph): boolean {
127
119
  const v = g.attrs.get('maxiter') ?? g.root.attrs.get('maxiter');
@@ -152,19 +144,13 @@ export function neatoMode(g: Graph): number {
152
144
  return MODE_MAJOR;
153
145
  }
154
146
 
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
147
  function checkStartAttr(g: Graph, mode: number): void {
164
148
  const value = g.root.attrs.get('start');
165
149
  if (parseStart(value, INIT_RANDOM).init !== INIT_SELF) return;
166
- // @see lib/neatogen/neatoinit.c:1095, lib/neatogen/stress.c:884 (smart_ini)
167
- if (mode === MODE_MAJOR || mode === MODE_IPSEP) unsupported('start', value ?? '', 'smart initialisation');
150
+ // @see lib/neatogen/neatoinit.c:1095, lib/neatogen/stress.c:884 (smart_ini).
151
+ // mode=ipsep is not here: stress_majorization_cola takes no `opts`, so C
152
+ // lays start=self out from the random init, silently (T0 start-self fixtures).
153
+ if (mode === MODE_MAJOR) unsupported('start', value ?? '', 'smart initialisation');
168
154
  // @see lib/neatogen/stuff.c:330 (KK and SGD warn once and ignore it)
169
155
  if ((mode === MODE_KK || mode === MODE_SGD) && !selfOnce.warned) {
170
156
  selfOnce.warned = true;
@@ -222,7 +208,6 @@ function checkModel(g: Graph, mode: number, model: number): void {
222
208
  */
223
209
  export function assertSupported(g: Graph, mode: number, model: number): void {
224
210
  if (maxIterNegative(g)) return;
225
- checkMode(g, mode);
226
211
  checkStartAttr(g, mode);
227
212
  checkModel(g, mode, model);
228
213
  }