@knowvah/dot-engine 2.9.0 → 2.10.1

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 (597) hide show
  1. package/dist/common/graph-init.d.ts.map +1 -1
  2. package/dist/common/htmltable.d.ts +1 -1
  3. package/dist/common/htmltable.d.ts.map +1 -1
  4. package/dist/common/poly-init.d.ts +8 -8
  5. package/dist/common/poly-init.d.ts.map +1 -1
  6. package/dist/common/safefile.d.ts +15 -0
  7. package/dist/common/safefile.d.ts.map +1 -1
  8. package/dist/gvc/context.d.ts +7 -1
  9. package/dist/gvc/context.d.ts.map +1 -1
  10. package/dist/gvc/device.d.ts +2 -3
  11. package/dist/gvc/device.d.ts.map +1 -1
  12. package/dist/gvc/emit-xdot.d.ts +11 -0
  13. package/dist/gvc/emit-xdot.d.ts.map +1 -0
  14. package/dist/gvc/image-resolver.d.ts +5 -0
  15. package/dist/gvc/image-resolver.d.ts.map +1 -1
  16. package/dist/gvc/init-xdot.d.ts +7 -0
  17. package/dist/gvc/init-xdot.d.ts.map +1 -0
  18. package/dist/gvc/landscape.d.ts +11 -0
  19. package/dist/gvc/landscape.d.ts.map +1 -0
  20. package/dist/gvc/layout-bb.d.ts +17 -0
  21. package/dist/gvc/layout-bb.d.ts.map +1 -0
  22. package/dist/gvc/layout-reset.d.ts +26 -0
  23. package/dist/gvc/layout-reset.d.ts.map +1 -0
  24. package/dist/gvc/viewport.d.ts +1 -10
  25. package/dist/gvc/viewport.d.ts.map +1 -1
  26. package/dist/index.js +2497 -1650
  27. package/dist/index.js.map +4 -4
  28. package/dist/layout/circo/blocks.d.ts +2 -0
  29. package/dist/layout/circo/blocks.d.ts.map +1 -1
  30. package/dist/layout/circo/blocktree.d.ts +6 -0
  31. package/dist/layout/circo/blocktree.d.ts.map +1 -1
  32. package/dist/layout/circo/circular.d.ts +6 -0
  33. package/dist/layout/circo/circular.d.ts.map +1 -1
  34. package/dist/layout/dot/edge-route-rank.d.ts +34 -0
  35. package/dist/layout/dot/edge-route-rank.d.ts.map +1 -1
  36. package/dist/layout/dot/index.d.ts.map +1 -1
  37. package/dist/layout/dot/init.d.ts.map +1 -1
  38. package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
  39. package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
  40. package/dist/layout/dot/splines-flat.d.ts +1 -2
  41. package/dist/layout/dot/splines-flat.d.ts.map +1 -1
  42. package/dist/layout/dot/splines.d.ts +2 -2
  43. package/dist/layout/dot/splines.d.ts.map +1 -1
  44. package/dist/layout/neato/__fixtures__/kk-models.d.ts +59 -0
  45. package/dist/layout/neato/__fixtures__/kk-models.d.ts.map +1 -0
  46. package/dist/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.d.ts +12 -0
  47. package/dist/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.d.ts.map +1 -0
  48. package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts +6 -0
  49. package/dist/layout/neato/__fixtures__/quad-prog-vpsc.d.ts.map +1 -1
  50. package/dist/layout/neato/circuit.d.ts +38 -0
  51. package/dist/layout/neato/circuit.d.ts.map +1 -1
  52. package/dist/layout/neato/constrained-majorization.d.ts.map +1 -1
  53. package/dist/layout/neato/dijkstra.d.ts +7 -0
  54. package/dist/layout/neato/dijkstra.d.ts.map +1 -1
  55. package/dist/layout/neato/index.d.ts +6 -3
  56. package/dist/layout/neato/index.d.ts.map +1 -1
  57. package/dist/layout/neato/init.d.ts.map +1 -1
  58. package/dist/layout/neato/kk-paths.d.ts +11 -1
  59. package/dist/layout/neato/kk-paths.d.ts.map +1 -1
  60. package/dist/layout/neato/kk-solve.d.ts.map +1 -1
  61. package/dist/layout/neato/kk.d.ts +5 -3
  62. package/dist/layout/neato/kk.d.ts.map +1 -1
  63. package/dist/layout/neato/kkutils.d.ts +45 -0
  64. package/dist/layout/neato/kkutils.d.ts.map +1 -1
  65. package/dist/layout/neato/splines.d.ts +7 -3
  66. package/dist/layout/neato/splines.d.ts.map +1 -1
  67. package/dist/layout/neato/start.d.ts +11 -10
  68. package/dist/layout/neato/start.d.ts.map +1 -1
  69. package/dist/layout/neato/stress-models.d.ts +25 -19
  70. package/dist/layout/neato/stress-models.d.ts.map +1 -1
  71. package/dist/layout/pack/ccomps.d.ts +32 -0
  72. package/dist/layout/pack/ccomps.d.ts.map +1 -0
  73. package/dist/layout/pack/index.d.ts +1 -24
  74. package/dist/layout/pack/index.d.ts.map +1 -1
  75. package/dist/layout/sfdp/init.d.ts.map +1 -1
  76. package/dist/render/dot/write-back.d.ts +37 -0
  77. package/dist/render/dot/write-back.d.ts.map +1 -0
  78. package/dist/render/dot.d.ts +5 -7
  79. package/dist/render/dot.d.ts.map +1 -1
  80. package/dist/render/json.d.ts +16 -21
  81. package/dist/render/json.d.ts.map +1 -1
  82. package/dist/render.js +2899 -2052
  83. package/dist/render.js.map +4 -4
  84. package/dist/util/libcxx-sort.d.ts +7 -0
  85. package/dist/util/libcxx-sort.d.ts.map +1 -0
  86. package/dist/vpsc/SweepLine.d.ts +23 -10
  87. package/dist/vpsc/SweepLine.d.ts.map +1 -1
  88. package/dist/vpsc/sweepTypes.d.ts +12 -2
  89. package/dist/vpsc/sweepTypes.d.ts.map +1 -1
  90. package/package.json +1 -1
  91. package/src/common/graph-init.ts +5 -1
  92. package/src/common/htmltable.ts +6 -4
  93. package/src/common/poly-init.ts +35 -15
  94. package/src/common/safefile.ts +20 -2
  95. package/src/gvc/__fixtures__/p8/bad.png +1 -0
  96. package/src/gvc/__fixtures__/p8/d/r.png +0 -0
  97. package/src/gvc/__fixtures__/p8/html-img-bad.gv +1 -0
  98. package/src/gvc/__fixtures__/p8/html-img-bad.svg +19 -0
  99. package/src/gvc/__fixtures__/p8/html-img-bad.svg.stderr +3 -0
  100. package/src/gvc/__fixtures__/p8/html-img-bad.xdot +13 -0
  101. package/src/gvc/__fixtures__/p8/html-img-bad.xdot.stderr +3 -0
  102. package/src/gvc/__fixtures__/p8/ip-shapefile.gv +1 -0
  103. package/src/gvc/__fixtures__/p8/ip-shapefile.svg +19 -0
  104. package/src/gvc/__fixtures__/p8/ip-shapefile.svg.stderr +0 -0
  105. package/src/gvc/__fixtures__/p8/ip-shapefile.xdot +15 -0
  106. package/src/gvc/__fixtures__/p8/ip-shapefile.xdot.stderr +0 -0
  107. package/src/gvc/__fixtures__/p8/regen.sh +13 -0
  108. package/src/gvc/__fixtures__/replay-native.json +422 -0
  109. package/src/gvc/__fixtures__/rerender/background.dot.seq-xdot-svg.1 +25 -0
  110. package/src/gvc/__fixtures__/rerender/background.dot.seq-xdot-svg.2 +37 -0
  111. package/src/gvc/__fixtures__/rerender/background.gv +1 -0
  112. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.plain.1 +5 -0
  113. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.plain.2 +5 -0
  114. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.xdot.1 +25 -0
  115. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.xdot.2 +25 -0
  116. package/src/gvc/__fixtures__/rerender/cluster-lrvn.gv +1 -0
  117. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.plain.1 +7 -0
  118. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.plain.2 +7 -0
  119. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-dot-dot.1 +18 -0
  120. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-dot-dot.2 +18 -0
  121. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-plain-xdot.1 +7 -0
  122. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-plain-xdot.2 +33 -0
  123. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-dot.1 +33 -0
  124. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-dot.2 +33 -0
  125. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-plain.1 +33 -0
  126. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-plain.2 +7 -0
  127. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-svg.1 +33 -0
  128. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-svg.2 +46 -0
  129. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-then-svg.1 +33 -0
  130. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-then-svg.2 +47 -0
  131. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-xdot.1 +33 -0
  132. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-xdot.2 +33 -0
  133. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.xdot.1 +33 -0
  134. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.xdot.2 +33 -0
  135. package/src/gvc/__fixtures__/rerender/cluster-skeleton.gv +1 -0
  136. package/src/gvc/__fixtures__/rerender/filing.circo.plain.1 +5 -0
  137. package/src/gvc/__fixtures__/rerender/filing.circo.plain.2 +5 -0
  138. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.1 +5 -0
  139. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.2 +5 -0
  140. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.3 +5 -0
  141. package/src/gvc/__fixtures__/rerender/filing.circo.xdot.1 +20 -0
  142. package/src/gvc/__fixtures__/rerender/filing.circo.xdot.2 +20 -0
  143. package/src/gvc/__fixtures__/rerender/filing.dot.plain.1 +5 -0
  144. package/src/gvc/__fixtures__/rerender/filing.dot.plain.2 +5 -0
  145. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.1 +5 -0
  146. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.2 +5 -0
  147. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.3 +5 -0
  148. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-circo.2 +5 -0
  149. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-fdp.2 +5 -0
  150. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-neato.2 +5 -0
  151. package/src/gvc/__fixtures__/rerender/filing.dot.seq-dot-dot.1 +11 -0
  152. package/src/gvc/__fixtures__/rerender/filing.dot.seq-dot-dot.2 +11 -0
  153. package/src/gvc/__fixtures__/rerender/filing.dot.seq-json-json.1 +148 -0
  154. package/src/gvc/__fixtures__/rerender/filing.dot.seq-json-json.2 +162 -0
  155. package/src/gvc/__fixtures__/rerender/filing.dot.seq-plain-xdot.1 +5 -0
  156. package/src/gvc/__fixtures__/rerender/filing.dot.seq-plain-xdot.2 +20 -0
  157. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-dot.1 +20 -0
  158. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-dot.2 +20 -0
  159. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-plain.1 +20 -0
  160. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-plain.2 +5 -0
  161. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-svg.1 +20 -0
  162. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-svg.2 +30 -0
  163. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-then-svg.1 +20 -0
  164. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-then-svg.2 +31 -0
  165. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-xdot.1 +20 -0
  166. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-xdot.2 +20 -0
  167. package/src/gvc/__fixtures__/rerender/filing.dot.xdot.1 +20 -0
  168. package/src/gvc/__fixtures__/rerender/filing.dot.xdot.2 +20 -0
  169. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.1 +5 -0
  170. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.2 +5 -0
  171. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.1 +5 -0
  172. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.2 +5 -0
  173. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.3 +5 -0
  174. package/src/gvc/__fixtures__/rerender/filing.fdp.xdot.1 +20 -0
  175. package/src/gvc/__fixtures__/rerender/filing.fdp.xdot.2 +21 -0
  176. package/src/gvc/__fixtures__/rerender/filing.gv +1 -0
  177. package/src/gvc/__fixtures__/rerender/filing.neato.plain.1 +5 -0
  178. package/src/gvc/__fixtures__/rerender/filing.neato.plain.2 +5 -0
  179. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.1 +5 -0
  180. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.2 +5 -0
  181. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.3 +5 -0
  182. package/src/gvc/__fixtures__/rerender/filing.neato.seq-xdot-then-svg.1 +20 -0
  183. package/src/gvc/__fixtures__/rerender/filing.neato.seq-xdot-then-svg.2 +31 -0
  184. package/src/gvc/__fixtures__/rerender/filing.neato.xdot.1 +20 -0
  185. package/src/gvc/__fixtures__/rerender/filing.neato.xdot.2 +21 -0
  186. package/src/gvc/__fixtures__/rerender/filing.osage.plain.1 +5 -0
  187. package/src/gvc/__fixtures__/rerender/filing.osage.plain.2 +5 -0
  188. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.1 +5 -0
  189. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.2 +5 -0
  190. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.3 +5 -0
  191. package/src/gvc/__fixtures__/rerender/filing.osage.xdot.1 +20 -0
  192. package/src/gvc/__fixtures__/rerender/filing.osage.xdot.2 +20 -0
  193. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.1 +5 -0
  194. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.2 +5 -0
  195. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.1 +5 -0
  196. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.2 +5 -0
  197. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.3 +5 -0
  198. package/src/gvc/__fixtures__/rerender/filing.patchwork.xdot.1 +20 -0
  199. package/src/gvc/__fixtures__/rerender/filing.patchwork.xdot.2 +20 -0
  200. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.1 +5 -0
  201. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.2 +5 -0
  202. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.1 +5 -0
  203. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.2 +5 -0
  204. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.3 +5 -0
  205. package/src/gvc/__fixtures__/rerender/filing.sfdp.xdot.1 +20 -0
  206. package/src/gvc/__fixtures__/rerender/filing.sfdp.xdot.2 +20 -0
  207. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.1 +5 -0
  208. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.2 +5 -0
  209. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.1 +5 -0
  210. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.2 +5 -0
  211. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.3 +5 -0
  212. package/src/gvc/__fixtures__/rerender/filing.twopi.xdot.1 +20 -0
  213. package/src/gvc/__fixtures__/rerender/filing.twopi.xdot.2 +20 -0
  214. package/src/gvc/__fixtures__/rerender/mixed.circo.plain.1 +18 -0
  215. package/src/gvc/__fixtures__/rerender/mixed.circo.plain.2 +18 -0
  216. package/src/gvc/__fixtures__/rerender/mixed.circo.xdot.1 +103 -0
  217. package/src/gvc/__fixtures__/rerender/mixed.circo.xdot.2 +104 -0
  218. package/src/gvc/__fixtures__/rerender/mixed.dot.plain.1 +18 -0
  219. package/src/gvc/__fixtures__/rerender/mixed.dot.plain.2 +18 -0
  220. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-dot-dot.1 +75 -0
  221. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-dot-dot.2 +75 -0
  222. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-plain-xdot.1 +18 -0
  223. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-plain-xdot.2 +119 -0
  224. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-dot.1 +119 -0
  225. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-dot.2 +119 -0
  226. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-plain.1 +119 -0
  227. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-plain.2 +18 -0
  228. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-svg.1 +119 -0
  229. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-svg.2 +127 -0
  230. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-then-svg.1 +119 -0
  231. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-then-svg.2 +128 -0
  232. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-xdot.1 +119 -0
  233. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-xdot.2 +119 -0
  234. package/src/gvc/__fixtures__/rerender/mixed.dot.xdot.1 +119 -0
  235. package/src/gvc/__fixtures__/rerender/mixed.dot.xdot.2 +119 -0
  236. package/src/gvc/__fixtures__/rerender/mixed.fdp.plain.1 +18 -0
  237. package/src/gvc/__fixtures__/rerender/mixed.fdp.xdot.1 +117 -0
  238. package/src/gvc/__fixtures__/rerender/mixed.gv +8 -0
  239. package/src/gvc/__fixtures__/rerender/mixed.neato.plain.1 +18 -0
  240. package/src/gvc/__fixtures__/rerender/mixed.neato.plain.2 +18 -0
  241. package/src/gvc/__fixtures__/rerender/mixed.neato.xdot.1 +117 -0
  242. package/src/gvc/__fixtures__/rerender/mixed.neato.xdot.2 +118 -0
  243. package/src/gvc/__fixtures__/rerender/mixed.osage.plain.1 +18 -0
  244. package/src/gvc/__fixtures__/rerender/mixed.osage.plain.2 +18 -0
  245. package/src/gvc/__fixtures__/rerender/mixed.osage.xdot.1 +117 -0
  246. package/src/gvc/__fixtures__/rerender/mixed.osage.xdot.2 +117 -0
  247. package/src/gvc/__fixtures__/rerender/mixed.patchwork.plain.1 +18 -0
  248. package/src/gvc/__fixtures__/rerender/mixed.patchwork.plain.2 +18 -0
  249. package/src/gvc/__fixtures__/rerender/mixed.patchwork.xdot.1 +78 -0
  250. package/src/gvc/__fixtures__/rerender/mixed.patchwork.xdot.2 +79 -0
  251. package/src/gvc/__fixtures__/rerender/mixed.sfdp.plain.1 +18 -0
  252. package/src/gvc/__fixtures__/rerender/mixed.sfdp.xdot.1 +103 -0
  253. package/src/gvc/__fixtures__/rerender/mixed.twopi.plain.1 +18 -0
  254. package/src/gvc/__fixtures__/rerender/mixed.twopi.plain.2 +18 -0
  255. package/src/gvc/__fixtures__/rerender/mixed.twopi.xdot.1 +103 -0
  256. package/src/gvc/__fixtures__/rerender/mixed.twopi.xdot.2 +103 -0
  257. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +29 -0
  258. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +29 -0
  259. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +29 -0
  260. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.1 +29 -0
  261. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.2 +29 -0
  262. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.3 +29 -0
  263. package/src/gvc/__fixtures__/rerender/multi-edge.gv +16 -0
  264. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.1 +29 -0
  265. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.2 +29 -0
  266. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.3 +29 -0
  267. package/src/gvc/__fixtures__/rerender/neato-pos.gv +1 -0
  268. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-dot-plain.1 +34 -0
  269. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-dot-plain.2 +18 -0
  270. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json-plain.1 +471 -0
  271. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json-plain.2 +18 -0
  272. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json0-plain.1 +121 -0
  273. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json0-plain.2 +18 -0
  274. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-xdot-plain.1 +60 -0
  275. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-xdot-plain.2 +18 -0
  276. package/src/gvc/__fixtures__/rerender/regen.sh +81 -0
  277. package/src/gvc/__fixtures__/rerender/sized-clip.gv +18 -0
  278. package/src/gvc/__fixtures__/rerender/sized-clip.neato.xdot.1 +86 -0
  279. package/src/gvc/__fixtures__/rerender/sized-clip.neato.xdot.2 +86 -0
  280. package/src/gvc/context.ts +13 -1
  281. package/src/gvc/device.ts +6 -6
  282. package/src/gvc/emit-xdot.ts +208 -0
  283. package/src/gvc/image-resolver.ts +8 -0
  284. package/src/gvc/init-xdot.ts +36 -0
  285. package/src/gvc/landscape.ts +36 -0
  286. package/src/gvc/layout-bb.ts +43 -0
  287. package/src/gvc/layout-reset.ts +62 -0
  288. package/src/gvc/viewport.ts +1 -32
  289. package/src/layout/circo/__fixtures__/root/both-connected.gv +11 -0
  290. package/src/layout/circo/__fixtures__/root/both-connected.xdot +53 -0
  291. package/src/layout/circo/__fixtures__/root/both-connected.xdot.stderr +0 -0
  292. package/src/layout/circo/__fixtures__/root/both-per-component.gv +18 -0
  293. package/src/layout/circo/__fixtures__/root/both-per-component.xdot +97 -0
  294. package/src/layout/circo/__fixtures__/root/both-per-component.xdot.stderr +0 -0
  295. package/src/layout/circo/__fixtures__/root/graph-none-node.gv +11 -0
  296. package/src/layout/circo/__fixtures__/root/graph-none-node.xdot +53 -0
  297. package/src/layout/circo/__fixtures__/root/graph-none-node.xdot.stderr +0 -0
  298. package/src/layout/circo/__fixtures__/root/graph-root-first.gv +17 -0
  299. package/src/layout/circo/__fixtures__/root/graph-root-first.xdot +96 -0
  300. package/src/layout/circo/__fixtures__/root/graph-root-first.xdot.stderr +0 -0
  301. package/src/layout/circo/__fixtures__/root/graph-root-later.gv +17 -0
  302. package/src/layout/circo/__fixtures__/root/graph-root-later.xdot +96 -0
  303. package/src/layout/circo/__fixtures__/root/graph-root-later.xdot.stderr +0 -0
  304. package/src/layout/circo/__fixtures__/root/graph-root-none.gv +17 -0
  305. package/src/layout/circo/__fixtures__/root/graph-root-none.xdot +96 -0
  306. package/src/layout/circo/__fixtures__/root/graph-root-none.xdot.stderr +0 -0
  307. package/src/layout/circo/__fixtures__/root/graph-root-paths.gv +7 -0
  308. package/src/layout/circo/__fixtures__/root/graph-root-paths.xdot +46 -0
  309. package/src/layout/circo/__fixtures__/root/graph-root-paths.xdot.stderr +0 -0
  310. package/src/layout/circo/__fixtures__/root/no-root-connected.gv +9 -0
  311. package/src/layout/circo/__fixtures__/root/no-root-connected.xdot +51 -0
  312. package/src/layout/circo/__fixtures__/root/no-root-connected.xdot.stderr +0 -0
  313. package/src/layout/circo/__fixtures__/root/no-root.gv +16 -0
  314. package/src/layout/circo/__fixtures__/root/no-root.xdot +95 -0
  315. package/src/layout/circo/__fixtures__/root/no-root.xdot.stderr +0 -0
  316. package/src/layout/circo/__fixtures__/root/node-root-connected.gv +10 -0
  317. package/src/layout/circo/__fixtures__/root/node-root-connected.xdot +52 -0
  318. package/src/layout/circo/__fixtures__/root/node-root-connected.xdot.stderr +0 -0
  319. package/src/layout/circo/__fixtures__/root/node-root-false.gv +10 -0
  320. package/src/layout/circo/__fixtures__/root/node-root-false.xdot +52 -0
  321. package/src/layout/circo/__fixtures__/root/node-root-false.xdot.stderr +0 -0
  322. package/src/layout/circo/__fixtures__/root/node-root-later.gv +17 -0
  323. package/src/layout/circo/__fixtures__/root/node-root-later.xdot +96 -0
  324. package/src/layout/circo/__fixtures__/root/node-root-later.xdot.stderr +0 -0
  325. package/src/layout/circo/__fixtures__/root/node-root-two.gv +11 -0
  326. package/src/layout/circo/__fixtures__/root/node-root-two.xdot +53 -0
  327. package/src/layout/circo/__fixtures__/root/node-root-two.xdot.stderr +0 -0
  328. package/src/layout/circo/__fixtures__/root/regen.sh +16 -0
  329. package/src/layout/circo/blocks.ts +3 -0
  330. package/src/layout/circo/blocktree.ts +17 -3
  331. package/src/layout/circo/circular.ts +13 -1
  332. package/src/layout/dot/edge-route-rank.ts +72 -0
  333. package/src/layout/dot/edge-route.ts +6 -6
  334. package/src/layout/dot/index.ts +2 -0
  335. package/src/layout/dot/init.ts +17 -5
  336. package/src/layout/dot/splines-flat-labeled.ts +2 -1
  337. package/src/layout/dot/splines-flat-multi.ts +2 -1
  338. package/src/layout/dot/splines-flat.ts +3 -3
  339. package/src/layout/dot/splines.ts +9 -9
  340. package/src/layout/neato/__fixtures__/kk-models.ts +82 -0
  341. package/src/layout/neato/__fixtures__/models/hier-circuit.gv +15 -0
  342. package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +92 -0
  343. package/src/layout/neato/__fixtures__/models/hier-circuit.xdot.stderr +0 -0
  344. package/src/layout/neato/__fixtures__/models/hier-default.gv +14 -0
  345. package/src/layout/neato/__fixtures__/models/hier-default.xdot +91 -0
  346. package/src/layout/neato/__fixtures__/models/hier-default.xdot.stderr +0 -0
  347. package/src/layout/neato/__fixtures__/models/hier-disc-circuit.gv +9 -0
  348. package/src/layout/neato/__fixtures__/models/hier-disc-circuit.xdot +54 -0
  349. package/src/layout/neato/__fixtures__/models/hier-disc-circuit.xdot.stderr +0 -0
  350. package/src/layout/neato/__fixtures__/models/hier-len-circuit.gv +15 -0
  351. package/src/layout/neato/__fixtures__/models/hier-len-circuit.xdot +97 -0
  352. package/src/layout/neato/__fixtures__/models/hier-len-circuit.xdot.stderr +0 -0
  353. package/src/layout/neato/__fixtures__/models/hier-len-mds.gv +15 -0
  354. package/src/layout/neato/__fixtures__/models/hier-len-mds.xdot +97 -0
  355. package/src/layout/neato/__fixtures__/models/hier-len-mds.xdot.stderr +0 -0
  356. package/src/layout/neato/__fixtures__/models/hier-len-subset.gv +15 -0
  357. package/src/layout/neato/__fixtures__/models/hier-len-subset.xdot +97 -0
  358. package/src/layout/neato/__fixtures__/models/hier-len-subset.xdot.stderr +0 -0
  359. package/src/layout/neato/__fixtures__/models/hier-long-mds.gv +15 -0
  360. package/src/layout/neato/__fixtures__/models/hier-long-mds.xdot +95 -0
  361. package/src/layout/neato/__fixtures__/models/hier-long-mds.xdot.stderr +0 -0
  362. package/src/layout/neato/__fixtures__/models/hier-mds-nolen.gv +15 -0
  363. package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +92 -0
  364. package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot.stderr +2 -0
  365. package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.gv +10 -0
  366. package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +54 -0
  367. package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot.stderr +3 -0
  368. package/src/layout/neato/__fixtures__/models/hier-shortpath.gv +15 -0
  369. package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +92 -0
  370. package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot.stderr +0 -0
  371. package/src/layout/neato/__fixtures__/models/hier-subset.gv +15 -0
  372. package/src/layout/neato/__fixtures__/models/hier-subset.xdot +92 -0
  373. package/src/layout/neato/__fixtures__/models/hier-subset.xdot.stderr +0 -0
  374. package/src/layout/neato/__fixtures__/models/kk-circuit.gv +15 -0
  375. package/src/layout/neato/__fixtures__/models/kk-circuit.xdot +81 -0
  376. package/src/layout/neato/__fixtures__/models/kk-circuit.xdot.stderr +4 -0
  377. package/src/layout/neato/__fixtures__/models/kk-default.gv +14 -0
  378. package/src/layout/neato/__fixtures__/models/kk-default.xdot +80 -0
  379. package/src/layout/neato/__fixtures__/models/kk-default.xdot.stderr +0 -0
  380. package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.gv +10 -0
  381. package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.native-crash +1 -0
  382. package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.xdot +0 -0
  383. package/src/layout/neato/__fixtures__/models/kk-disc-circuit-pack.xdot.stderr +0 -0
  384. package/src/layout/neato/__fixtures__/models/kk-disc-circuit.gv +9 -0
  385. package/src/layout/neato/__fixtures__/models/kk-disc-circuit.xdot +49 -0
  386. package/src/layout/neato/__fixtures__/models/kk-disc-circuit.xdot.stderr +4 -0
  387. package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.gv +10 -0
  388. package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.xdot +50 -0
  389. package/src/layout/neato/__fixtures__/models/kk-disc-shortpath-pack.xdot.stderr +0 -0
  390. package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.gv +13 -0
  391. package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.native-crash +1 -0
  392. package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.xdot +0 -0
  393. package/src/layout/neato/__fixtures__/models/kk-disc4-circuit-pack.xdot.stderr +4 -0
  394. package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.gv +13 -0
  395. package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.xdot +66 -0
  396. package/src/layout/neato/__fixtures__/models/kk-disc4-shortpath-pack.xdot.stderr +0 -0
  397. package/src/layout/neato/__fixtures__/models/kk-iso-circuit.gv +11 -0
  398. package/src/layout/neato/__fixtures__/models/kk-iso-circuit.xdot +51 -0
  399. package/src/layout/neato/__fixtures__/models/kk-iso-circuit.xdot.stderr +4 -0
  400. package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.gv +11 -0
  401. package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.xdot +57 -0
  402. package/src/layout/neato/__fixtures__/models/kk-iso-len-circuit.xdot.stderr +4 -0
  403. package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.gv +11 -0
  404. package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.xdot +57 -0
  405. package/src/layout/neato/__fixtures__/models/kk-iso-len-mds.xdot.stderr +0 -0
  406. package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.gv +11 -0
  407. package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.xdot +57 -0
  408. package/src/layout/neato/__fixtures__/models/kk-iso-long-mds.xdot.stderr +0 -0
  409. package/src/layout/neato/__fixtures__/models/kk-large.gv +203 -0
  410. package/src/layout/neato/__fixtures__/models/kk-large.pow.json +1088 -0
  411. package/src/layout/neato/__fixtures__/models/kk-large.xdot +1208 -0
  412. package/src/layout/neato/__fixtures__/models/kk-large.xdot.stderr +0 -0
  413. package/src/layout/neato/__fixtures__/models/kk-len-circuit.gv +15 -0
  414. package/src/layout/neato/__fixtures__/models/kk-len-circuit.xdot +86 -0
  415. package/src/layout/neato/__fixtures__/models/kk-len-circuit.xdot.stderr +4 -0
  416. package/src/layout/neato/__fixtures__/models/kk-len-mds.gv +15 -0
  417. package/src/layout/neato/__fixtures__/models/kk-len-mds.xdot +86 -0
  418. package/src/layout/neato/__fixtures__/models/kk-len-mds.xdot.stderr +0 -0
  419. package/src/layout/neato/__fixtures__/models/kk-len-subset.gv +15 -0
  420. package/src/layout/neato/__fixtures__/models/kk-len-subset.xdot +86 -0
  421. package/src/layout/neato/__fixtures__/models/kk-len-subset.xdot.stderr +0 -0
  422. package/src/layout/neato/__fixtures__/models/kk-mds-nolen.gv +15 -0
  423. package/src/layout/neato/__fixtures__/models/kk-mds-nolen.xdot +81 -0
  424. package/src/layout/neato/__fixtures__/models/kk-mds-nolen.xdot.stderr +2 -0
  425. package/src/layout/neato/__fixtures__/models/kk-shortpath.gv +15 -0
  426. package/src/layout/neato/__fixtures__/models/kk-shortpath.xdot +81 -0
  427. package/src/layout/neato/__fixtures__/models/kk-shortpath.xdot.stderr +0 -0
  428. package/src/layout/neato/__fixtures__/models/kk-subset.gv +15 -0
  429. package/src/layout/neato/__fixtures__/models/kk-subset.xdot +81 -0
  430. package/src/layout/neato/__fixtures__/models/kk-subset.xdot.stderr +0 -0
  431. package/src/layout/neato/__fixtures__/models/large-circuit.gv +203 -0
  432. package/src/layout/neato/__fixtures__/models/large-circuit.xdot +1208 -0
  433. package/src/layout/neato/__fixtures__/models/large-circuit.xdot.stderr +0 -0
  434. package/src/layout/neato/__fixtures__/models/major-circuit.gv +14 -0
  435. package/src/layout/neato/__fixtures__/models/major-circuit.xdot +80 -0
  436. package/src/layout/neato/__fixtures__/models/major-circuit.xdot.stderr +0 -0
  437. package/src/layout/neato/__fixtures__/models/major-default.gv +13 -0
  438. package/src/layout/neato/__fixtures__/models/major-default.xdot +79 -0
  439. package/src/layout/neato/__fixtures__/models/major-default.xdot.stderr +0 -0
  440. package/src/layout/neato/__fixtures__/models/major-disc-circuit.gv +8 -0
  441. package/src/layout/neato/__fixtures__/models/major-disc-circuit.xdot +48 -0
  442. package/src/layout/neato/__fixtures__/models/major-disc-circuit.xdot.stderr +0 -0
  443. package/src/layout/neato/__fixtures__/models/major-len-circuit.gv +14 -0
  444. package/src/layout/neato/__fixtures__/models/major-len-circuit.xdot +85 -0
  445. package/src/layout/neato/__fixtures__/models/major-len-circuit.xdot.stderr +0 -0
  446. package/src/layout/neato/__fixtures__/models/major-len-mds.gv +14 -0
  447. package/src/layout/neato/__fixtures__/models/major-len-mds.xdot +85 -0
  448. package/src/layout/neato/__fixtures__/models/major-len-mds.xdot.stderr +0 -0
  449. package/src/layout/neato/__fixtures__/models/major-len-subset.gv +14 -0
  450. package/src/layout/neato/__fixtures__/models/major-len-subset.xdot +85 -0
  451. package/src/layout/neato/__fixtures__/models/major-len-subset.xdot.stderr +0 -0
  452. package/src/layout/neato/__fixtures__/models/major-long-mds.gv +14 -0
  453. package/src/layout/neato/__fixtures__/models/major-long-mds.xdot +83 -0
  454. package/src/layout/neato/__fixtures__/models/major-long-mds.xdot.stderr +0 -0
  455. package/src/layout/neato/__fixtures__/models/major-long-shortpath.gv +14 -0
  456. package/src/layout/neato/__fixtures__/models/major-long-shortpath.xdot +83 -0
  457. package/src/layout/neato/__fixtures__/models/major-long-shortpath.xdot.stderr +0 -0
  458. package/src/layout/neato/__fixtures__/models/major-mds-edge-default.gv +15 -0
  459. package/src/layout/neato/__fixtures__/models/major-mds-edge-default.xdot +81 -0
  460. package/src/layout/neato/__fixtures__/models/major-mds-edge-default.xdot.stderr +0 -0
  461. package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.gv +14 -0
  462. package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.xdot +80 -0
  463. package/src/layout/neato/__fixtures__/models/major-mds-nolen-anon.xdot.stderr +2 -0
  464. package/src/layout/neato/__fixtures__/models/major-mds-nolen.gv +14 -0
  465. package/src/layout/neato/__fixtures__/models/major-mds-nolen.xdot +80 -0
  466. package/src/layout/neato/__fixtures__/models/major-mds-nolen.xdot.stderr +2 -0
  467. package/src/layout/neato/__fixtures__/models/major-model-Subset.gv +14 -0
  468. package/src/layout/neato/__fixtures__/models/major-model-Subset.xdot +80 -0
  469. package/src/layout/neato/__fixtures__/models/major-model-Subset.xdot.stderr +1 -0
  470. package/src/layout/neato/__fixtures__/models/major-model-foo-anon.gv +14 -0
  471. package/src/layout/neato/__fixtures__/models/major-model-foo-anon.xdot +80 -0
  472. package/src/layout/neato/__fixtures__/models/major-model-foo-anon.xdot.stderr +1 -0
  473. package/src/layout/neato/__fixtures__/models/major-model-foo.gv +14 -0
  474. package/src/layout/neato/__fixtures__/models/major-model-foo.xdot +80 -0
  475. package/src/layout/neato/__fixtures__/models/major-model-foo.xdot.stderr +1 -0
  476. package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.gv +9 -0
  477. package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.xdot +48 -0
  478. package/src/layout/neato/__fixtures__/models/major-pin-disc-circuit.xdot.stderr +2 -0
  479. package/src/layout/neato/__fixtures__/models/major-shortpath.gv +14 -0
  480. package/src/layout/neato/__fixtures__/models/major-shortpath.xdot +80 -0
  481. package/src/layout/neato/__fixtures__/models/major-shortpath.xdot.stderr +0 -0
  482. package/src/layout/neato/__fixtures__/models/major-subset.gv +14 -0
  483. package/src/layout/neato/__fixtures__/models/major-subset.xdot +80 -0
  484. package/src/layout/neato/__fixtures__/models/major-subset.xdot.stderr +0 -0
  485. package/src/layout/neato/__fixtures__/models/regen.sh +46 -0
  486. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.gv +17 -0
  487. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.xdot +115 -0
  488. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.xdot.stderr +0 -0
  489. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.gv +18 -0
  490. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.xdot +116 -0
  491. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.xdot.stderr +0 -0
  492. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.gv +18 -0
  493. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.xdot +116 -0
  494. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.xdot.stderr +0 -0
  495. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.gv +18 -0
  496. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.xdot +116 -0
  497. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.xdot.stderr +0 -0
  498. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.gv +18 -0
  499. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.xdot +116 -0
  500. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.xdot.stderr +0 -0
  501. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.gv +18 -0
  502. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.xdot +102 -0
  503. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.xdot.stderr +0 -0
  504. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.gv +19 -0
  505. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.xdot +103 -0
  506. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.xdot.stderr +0 -0
  507. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.gv +19 -0
  508. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.xdot +103 -0
  509. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.xdot.stderr +3 -0
  510. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.gv +19 -0
  511. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.xdot +103 -0
  512. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.xdot.stderr +0 -0
  513. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.gv +19 -0
  514. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.xdot +103 -0
  515. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.xdot.stderr +0 -0
  516. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.gv +16 -0
  517. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.xdot +100 -0
  518. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.xdot.stderr +0 -0
  519. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.gv +17 -0
  520. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.xdot +101 -0
  521. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.xdot.stderr +0 -0
  522. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.gv +18 -0
  523. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.xdot +106 -0
  524. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.xdot.stderr +0 -0
  525. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.gv +18 -0
  526. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.xdot +101 -0
  527. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.xdot.stderr +0 -0
  528. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.gv +17 -0
  529. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.xdot +101 -0
  530. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.xdot.stderr +0 -0
  531. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.gv +17 -0
  532. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.xdot +101 -0
  533. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.xdot.stderr +0 -0
  534. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.gv +17 -0
  535. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.xdot +101 -0
  536. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.xdot.stderr +0 -0
  537. package/src/layout/neato/__fixtures__/multi-component-attrs/regen.sh +16 -0
  538. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.gv +17 -0
  539. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.xdot +101 -0
  540. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.xdot.stderr +0 -0
  541. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.gv +18 -0
  542. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.xdot +102 -0
  543. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.xdot.stderr +0 -0
  544. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.gv +18 -0
  545. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.xdot +102 -0
  546. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.xdot.stderr +0 -0
  547. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.gv +18 -0
  548. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.xdot +102 -0
  549. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.xdot.stderr +0 -0
  550. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.gv +18 -0
  551. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.xdot +102 -0
  552. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.xdot.stderr +0 -0
  553. package/src/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.ts +14 -0
  554. package/src/layout/neato/__fixtures__/quad-prog-vpsc.ts +7 -1
  555. package/src/layout/neato/circuit.ts +67 -2
  556. package/src/layout/neato/constrained-majorization.ts +5 -22
  557. package/src/layout/neato/dijkstra.ts +12 -3
  558. package/src/layout/neato/index.ts +41 -14
  559. package/src/layout/neato/init.ts +9 -13
  560. package/src/layout/neato/kk-paths.ts +23 -1
  561. package/src/layout/neato/kk-solve.ts +5 -3
  562. package/src/layout/neato/kk.ts +53 -21
  563. package/src/layout/neato/kkutils.ts +108 -3
  564. package/src/layout/neato/splines.ts +18 -18
  565. package/src/layout/neato/start.ts +20 -65
  566. package/src/layout/neato/stress-models.ts +55 -59
  567. package/src/layout/pack/ccomps.ts +131 -0
  568. package/src/layout/pack/index.ts +1 -95
  569. package/src/layout/sfdp/__fixtures__/start-warning/regen.sh +16 -0
  570. package/src/layout/sfdp/__fixtures__/start-warning/start-5.gv +15 -0
  571. package/src/layout/sfdp/__fixtures__/start-warning/start-5.xdot +77 -0
  572. package/src/layout/sfdp/__fixtures__/start-warning/start-5.xdot.stderr +0 -0
  573. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.gv +15 -0
  574. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.xdot +77 -0
  575. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.xdot.stderr +0 -0
  576. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.gv +15 -0
  577. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.xdot +77 -0
  578. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.xdot.stderr +1 -0
  579. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.gv +16 -0
  580. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.xdot +78 -0
  581. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.xdot.stderr +2 -0
  582. package/src/layout/sfdp/__fixtures__/start-warning/start-self.gv +15 -0
  583. package/src/layout/sfdp/__fixtures__/start-warning/start-self.xdot +77 -0
  584. package/src/layout/sfdp/__fixtures__/start-warning/start-self.xdot.stderr +1 -0
  585. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.gv +14 -0
  586. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.xdot +76 -0
  587. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.xdot.stderr +0 -0
  588. package/src/layout/sfdp/index.ts +1 -1
  589. package/src/layout/sfdp/init.ts +9 -1
  590. package/src/layout/twopi/index.ts +1 -1
  591. package/src/render/dot/agwrite.ts +1 -1
  592. package/src/render/dot/write-back.ts +137 -0
  593. package/src/render/dot.ts +12 -12
  594. package/src/render/json.ts +34 -34
  595. package/src/util/libcxx-sort.ts +461 -0
  596. package/src/vpsc/SweepLine.ts +50 -38
  597. package/src/vpsc/sweepTypes.ts +13 -2
@@ -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)) * Math.sqrt(g.nodes.size) + 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
- // C: start=self warns once per process; start.ts:checkStartAttr already did.
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 += del[k]! * del[k]!;
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 += t[k]! * t[k]!;
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]! += K * D * t[k]! * t[l]! * scale;
251
- M[k * NDIM + k]! += K * (1.0 - D * (sq - t[k]! * t[k]!) * scale);
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 += st.sumT[i * NDIM + k]! * st.sumT[i * NDIM + k]!;
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] = (st.damping + 2 * (1 - st.damping) * drand48()) * 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
- * Solve the layout with Kamada-Kawai gradient descent. The subset and (connected)
310
- * circuit distance models stay loud in `start.ts:assertSupported`; a
311
- * disconnected circuit falls back to shortest paths there too.
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 { st, adj, ini, lens } = scanGraphMode(g, maxIter);
319
- shortestPath(newPathState(st.n, st.dist, adj, ini));
320
- if (model === MODEL_MDS) mdsModel(st.dist, st.n, mdsEdges(g, st.nodes, lens));
321
- initialPositions(g, st);
322
- diffeqModel(g, st);
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
  }
@@ -1,9 +1,10 @@
1
1
  // SPDX-License-Identifier: EPL-2.0
2
2
 
3
3
  /**
4
- * Helpers of neatogen/kkutils.c: the all-pairs shortest-path matrix
5
- * (`compute_apsp`) and the index sorts `quicksort_place` and
6
- * `quicksort_placef`. The sorts go through `gv_sort`, i.e. libc `qsort`, which is
4
+ * Helpers of neatogen/kkutils.c: the neighbour-vector helpers, the all-pairs
5
+ * shortest-path matrices (`compute_apsp`, `compute_apsp_artificial_weights`),
6
+ * the reweighting they use (`compute_new_weights`, `restore_old_weights`) and
7
+ * the index sorts `quicksort_place` and `quicksort_placef`. The sorts go through `gv_sort`, i.e. libc `qsort`, which is
7
8
  * not stable: tied keys keep the permutation the BSD/Apple qsort gives, so the
8
9
  * sort runs through `gvQsort` (the reproduction of that algorithm).
9
10
  *
@@ -16,6 +17,46 @@ import { bfs } from './bfs.js';
16
17
  import { ngdijkstra } from './dijkstra.js';
17
18
  import type { VtxData } from './dijkstra.js';
18
19
 
20
+ /** 2^64: C `size_t` arithmetic wraps modulo this. */
21
+ const SIZE_T_MODULUS = 2 ** 64;
22
+
23
+ /**
24
+ * Count the neighbours of `u` marked in `vVector`.
25
+ * @see lib/neatogen/kkutils.c:common_neighbors
26
+ */
27
+ export function commonNeighbors(graph: readonly VtxData[], u: number, vVector: Int32Array): number {
28
+ // count number of common neighbors of 'v_vector' and 'u'
29
+ let numSharedNeighbors = 0;
30
+ for (let j = 1; j < graph[u]!.nedges; j++) {
31
+ const neighbor = graph[u]!.edges[j]!;
32
+ if (vVector[neighbor]! > 0) {
33
+ // a shared neighbor
34
+ numSharedNeighbors++;
35
+ }
36
+ }
37
+ return numSharedNeighbors;
38
+ }
39
+
40
+ /**
41
+ * Mark the neighbours of `vtx` (a node is NOT a neighbour of itself).
42
+ * @see lib/neatogen/kkutils.c:fill_neighbors_vec_unweighted
43
+ */
44
+ export function fillNeighborsVecUnweighted(graph: readonly VtxData[], vtx: number, vtxVec: Int32Array): void {
45
+ for (let j = 1; j < graph[vtx]!.nedges; j++) {
46
+ vtxVec[graph[vtx]!.edges[j]!] = 1;
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Clear the marks set by `fillNeighborsVecUnweighted`.
52
+ * @see lib/neatogen/kkutils.c:empty_neighbors_vec
53
+ */
54
+ export function emptyNeighborsVec(graph: readonly VtxData[], vtx: number, vtxVec: Int32Array): void {
55
+ for (let j = 1; j < graph[vtx]!.nedges; j++) {
56
+ vtxVec[graph[vtx]!.edges[j]!] = 0;
57
+ }
58
+ }
59
+
19
60
  /** Three-way compare of two keys; 0 on tie or NaN, as C's `<`/`>` chain. */
20
61
  function compareKeys(a: number, b: number): number {
21
62
  if (a < b) return -1;
@@ -94,3 +135,67 @@ function computeApspSimple(graph: VtxData[], n: number): Int32Array[] {
94
135
  export function computeApsp(graph: VtxData[], n: number): Int32Array[] {
95
136
  return graph[0]!.ewgts.length > 0 ? computeApspDijkstra(graph, n) : computeApspSimple(graph, n);
96
137
  }
138
+
139
+ /**
140
+ * The artificial weight of edge (i, neighbor): `deg_i + deg_j - 2 * common`
141
+ * in C `size_t`, so a negative value (only possible with duplicate
142
+ * neighbours) wraps modulo 2^64 before the (float) cast.
143
+ * @see lib/neatogen/kkutils.c:compute_new_weights (kkutils.c:186-188)
144
+ * @see lib/neatogen/stress.c:compute_apsp_artificial_weights_packed (stress.c:735-736, 752-753)
145
+ */
146
+ export function artificialWeight(graph: readonly VtxData[], degI: number, neighbor: number, vtxVec: Int32Array): number {
147
+ const degJ = graph[neighbor]!.nedges - 1;
148
+ const w = degI + degJ - 2 * commonNeighbors(graph, neighbor, vtxVec);
149
+ return Math.fround(w < 0 ? w + SIZE_T_MODULUS : w);
150
+ }
151
+
152
+ /**
153
+ * Reweight the graph so that high degree nodes will be separated. C walks a
154
+ * pointer through one buffer of sum(nedges) floats; the port allocates each
155
+ * vertex's slice.
156
+ * @see lib/neatogen/kkutils.c:compute_new_weights
157
+ */
158
+ export function computeNewWeights(graph: VtxData[], n: number): void {
159
+ const vtxVec = new Int32Array(n);
160
+ for (let i = 0; i < n; i++) {
161
+ const weights = new Array<number>(graph[i]!.nedges).fill(0);
162
+ graph[i]!.ewgts = weights;
163
+ fillNeighborsVecUnweighted(graph, i, vtxVec);
164
+ const degI = graph[i]!.nedges - 1;
165
+ for (let j = 1; j <= degI; j++) {
166
+ const neighbor = graph[i]!.edges[j]!;
167
+ weights[j] = artificialWeight(graph, degI, neighbor, vtxVec);
168
+ }
169
+ emptyNeighborsVec(graph, i, vtxVec);
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Drop the new weights and give the caller's back. C's `old_weights` is the one
175
+ * block it walks by `nedges`; the port's is one array per vertex, `null` for C
176
+ * `NULL`. With `null` only graph[0].ewgts is cleared, so graph[1..n-1].ewgts
177
+ * keep the new weights (C: dangling pointers into the freed buffer).
178
+ * @see lib/neatogen/kkutils.c:restore_old_weights
179
+ */
180
+ export function restoreOldWeights(graph: VtxData[], n: number, oldWeights: readonly number[][] | null): void {
181
+ graph[0]!.ewgts = []; // free(graph[0].ewgts); graph[0].ewgts = NULL
182
+ if (oldWeights !== null) {
183
+ for (let i = 0; i < n; i++) {
184
+ graph[i]!.ewgts = oldWeights[i]!;
185
+ }
186
+ }
187
+ }
188
+
189
+ /**
190
+ * All-pairs shortest-path lengths as `DistType` (int) rows while weighting the
191
+ * graph so high-degree nodes are distantly located: always Dijkstra, over the
192
+ * int-truncated new weights.
193
+ * @see lib/neatogen/kkutils.c:compute_apsp_artificial_weights
194
+ */
195
+ export function computeApspArtificialWeights(graph: VtxData[], n: number): Int32Array[] {
196
+ const oldWeights = graph[0]!.ewgts.length === 0 ? null : graph.slice(0, n).map((v) => v.ewgts);
197
+ computeNewWeights(graph, n);
198
+ const Dij = computeApspDijkstra(graph, n);
199
+ restoreOldWeights(graph, n, oldWeights);
200
+ return Dij;
201
+ }
@@ -834,25 +834,29 @@ export function splineEdges(g: Graph): void {
834
834
  // ---------------------------------------------------------------------------
835
835
 
836
836
  /**
837
- * Graph bounding box in points derived from node pos (inches) and node
838
- * sizes, expanded by any existing edge splines. xlabels are not ported
839
- * (no engine sets them yet).
837
+ * Graph bounding box in points from node pos (inches) and sizes, expanded by
838
+ * the beziers on the edges: none on a first layout, the stale ones on a layout
839
+ * with no gvFreeLayout. xlabels are not ported (no engine sets them yet).
840
840
  * @see lib/common/utils.c:compute_bb
841
841
  */
842
842
  export function computeBBFromPos(g: Graph): { ll: Point; ur: Point } {
843
- const bb = {
844
- ll: { x: Infinity, y: Infinity },
845
- ur: { x: -Infinity, y: -Infinity },
843
+ const bb = { ll: { x: Infinity, y: Infinity }, ur: { x: -Infinity, y: -Infinity } };
844
+ const expandbp = (x: number, y: number): void => {
845
+ bb.ll = { x: Math.min(bb.ll.x, x), y: Math.min(bb.ll.y, y) };
846
+ bb.ur = { x: Math.max(bb.ur.x, x), y: Math.max(bb.ur.y, y) };
846
847
  };
847
848
  for (const n of g.nodes.values()) {
848
849
  const px = (n.info.pos?.[0] ?? 0) * 72;
849
850
  const py = (n.info.pos?.[1] ?? 0) * 72;
850
851
  const sx = (n.info.lw + n.info.rw) / 2;
851
852
  const sy = n.info.ht / 2;
852
- bb.ll.x = Math.min(bb.ll.x, px - sx);
853
- bb.ll.y = Math.min(bb.ll.y, py - sy);
854
- bb.ur.x = Math.max(bb.ur.x, px + sx);
855
- bb.ur.y = Math.max(bb.ur.y, py + sy);
853
+ expandbp(px - sx, py - sy);
854
+ expandbp(px + sx, py + sy);
855
+ }
856
+ for (const e of g.edges) {
857
+ for (const bz of e.info.spl?.list ?? []) {
858
+ for (let j = 0; j < bz.size; j++) expandbp(bz.list[j].x, bz.list[j].y);
859
+ }
856
860
  }
857
861
  // C compute_bb: an empty graph keeps bb = {0,0,0,0}. @see utils.c:641
858
862
  if (!Number.isFinite(bb.ll.x)) {
@@ -861,14 +865,6 @@ export function computeBBFromPos(g: Graph): { ll: Point; ur: Point } {
861
865
  return bb;
862
866
  }
863
867
 
864
- /**
865
- * The C spline_edges wrapper: translate pos so the drawing's lower
866
- * left corner is the origin, shift cluster bbs along, sync coord from
867
- * pos (neato_set_aspect), then route edges by edge type.
868
- * @see lib/neatogen/neatosplines.c:spline_edges
869
- * @see lib/neatogen/neatosplines.c:spline_edges0
870
- * @see lib/neatogen/neatosplines.c:shiftClusters
871
- */
872
868
  /** Shift every node pos (inches) by the given offset. */
873
869
  function shiftAllPos(g: Graph, ox: number, oy: number): void {
874
870
  for (const n of g.nodes.values()) {
@@ -984,6 +980,10 @@ export function injectOraclePositions(g: Graph): void {
984
980
  }
985
981
  }
986
982
 
983
+ /**
984
+ * The C spline_edges wrapper: translate pos so the lower left corner is the origin,
985
+ * shift clusters, sync coord from pos, route. @see lib/neatogen/neatosplines.c:spline_edges
986
+ */
987
987
  export function splineEdgesShifted(g: Graph): void {
988
988
  injectOraclePositions(g);
989
989
  const bb = computeBBFromPos(g);
@@ -1,15 +1,14 @@
1
1
  // SPDX-License-Identifier: EPL-2.0
2
2
  /**
3
3
  * Neato `start` handling (setSeed / initRegular / checkStart) and the
4
- * fail-loud checks for the neato init features this port does not have
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.
4
+ * fail-loud check for the neato init feature this port does not have (smart
5
+ * init for the stress path). mode=hier runs `stress_majorization_with_hierarchy`;
6
+ * its own unported smart-init fallback without a hierarchy is loud in
7
+ * constrained-majorization.ts. mode=ipsep runs `stress_majorization_cola`, which
8
+ * takes no smart init.
10
9
  *
11
- * Each loud check sits where neato's C branches into the unported code and
12
- * fires only for the modes whose C path reaches it (ADR-3).
10
+ * The loud check sits where neato's C branches into the unported code and
11
+ * fires only for the mode whose C path reaches it (ADR-3).
13
12
  *
14
13
  * @see lib/neatogen/neatoinit.c
15
14
  */
@@ -19,12 +18,10 @@ import { agNameOf } from '../../model/cgraph-ops.js';
19
18
  import type { Graph } from '../../model/graph.js';
20
19
  import { srand48 } from '../../common/random.js';
21
20
  import { registerRenderState } from '../../common/render-state.js';
22
- import { getPack } from '../pack/index.js';
23
21
  import {
24
22
  MODE_KK, MODE_MAJOR, MODE_HIER, MODE_IPSEP, MODE_SGD,
25
- MODEL_CIRCUIT, MODEL_SUBSET,
26
23
  } from './init.js';
27
- import { agerrLineOn, agwarningf } from '../../common/agerr.js';
24
+ import { agwarningf } from '../../common/agerr.js';
28
25
 
29
26
  /** @see lib/neatogen/neato.h:INIT_SELF */
30
27
  export const INIT_SELF = 0;
@@ -53,8 +50,13 @@ const WARN_SELF_IGNORED = 'start=0 not supported with mode=self - ignored';
53
50
  */
54
51
  const selfOnce = { warned: false };
55
52
  registerRenderState(() => { selfOnce.warned = false; });
56
- /** Roots already warned about the KK circuit fallback (one warning per graph). */
57
- const circuitWarned = new WeakSet<object>();
53
+
54
+ /** KK and SGD warn once and ignore start=self. @see lib/neatogen/stuff.c:330 */
55
+ export function warnStartSelfOnce(): void {
56
+ if (selfOnce.warned) return;
57
+ selfOnce.warned = true;
58
+ agwarningf(WARN_SELF_IGNORED);
59
+ }
58
60
 
59
61
  /**
60
62
  * Classify the `start` attribute: keyword prefix, digit-led (random), else the
@@ -103,7 +105,7 @@ export function checkStart(
103
105
  ): number {
104
106
  const { init, seed } = parseStart(g.root.attrs.get('start'), dflt);
105
107
  if (init !== INIT_RANDOM && [...g.nodes.values()].some((n) => n.attrs.has('pos'))) {
106
- agerrLineOn('warn', WARN_POS_IGNORED);
108
+ agwarningf(WARN_POS_IGNORED);
107
109
  }
108
110
  if (init === INIT_REGULAR) initRegular(g, nG);
109
111
  srand48(seed);
@@ -151,63 +153,16 @@ function checkStartAttr(g: Graph, mode: number): void {
151
153
  // mode=ipsep is not here: stress_majorization_cola takes no `opts`, so C
152
154
  // lays start=self out from the random init, silently (T0 start-self fixtures).
153
155
  if (mode === MODE_MAJOR) unsupported('start', value ?? '', 'smart initialisation');
154
- // @see lib/neatogen/stuff.c:330 (KK and SGD warn once and ignore it)
155
- if ((mode === MODE_KK || mode === MODE_SGD) && !selfOnce.warned) {
156
- selfOnce.warned = true;
157
- agerrLineOn('warn', WARN_SELF_IGNORED);
158
- }
159
- }
160
-
161
- function isConnected(g: Graph): boolean {
162
- const nodes = [...g.nodes.values()];
163
- if (nodes.length === 0) return true;
164
- const adj = new Map<unknown, unknown[]>(nodes.map((n) => [n, []]));
165
- for (const e of g.edges) { adj.get(e.tail)?.push(e.head); adj.get(e.head)?.push(e.tail); }
166
- const seen = new Set<unknown>([nodes[0]]);
167
- const stack: unknown[] = [nodes[0]];
168
- for (let n = stack.pop(); n !== undefined; n = stack.pop()) {
169
- for (const m of adj.get(n) ?? []) if (!seen.has(m)) { seen.add(m); stack.push(m); }
170
- }
171
- return seen.size === nodes.length;
172
- }
173
-
174
- /** KK runs unpacked unless `pack` or `packmode` is set. @see neatoinit.c:1380-1389 */
175
- function kkCircuitFallsBack(g: Graph): boolean {
176
- const packed = getPack(g.root, -1, 0) >= 0 || (g.root.attrs.get('packmode') ?? '') !== '';
177
- return !packed && !isConnected(g.root);
178
- }
179
-
180
- function warnCircuitDisconnected(g: Graph): void {
181
- if (circuitWarned.has(g.root)) return;
182
- circuitWarned.add(g.root);
183
- agerrLineOn(
184
- 'warn',
185
- `graph ${agNameOf(g.root)} is disconnected. Hence, the circuit model\n`
186
- + 'is undefined. Reverting to the shortest path model.\n'
187
- + 'Alternatively, consider running neato using -Gpack=true or decomposing\n'
188
- + 'the graph into connected components.',
189
- );
190
- }
191
-
192
- function checkModel(g: Graph, mode: number, model: number): void {
193
- const value = g.root.attrs.get('model') ?? '';
194
- const stressPath = mode === MODE_MAJOR || mode === MODE_KK;
195
- // @see lib/neatogen/stress.c:846, lib/neatogen/neatoinit.c:1246
196
- if (model === MODEL_SUBSET && stressPath) unsupported('model', value, 'the subset distance model');
197
- if (model !== MODEL_CIRCUIT || !stressPath) return;
198
- // @see lib/neatogen/neatoinit.c:1248-1257 (disconnected: warn + shortpath)
199
- if (mode === MODE_KK && kkCircuitFallsBack(g)) { warnCircuitDisconnected(g); return; }
200
- // @see lib/neatogen/stress.c:851, lib/neatogen/circuit.c:circuit_model
201
- unsupported('model', value, 'the circuit distance model');
156
+ // KK warns at kk.ts:initialPositions, after its distance model, as C does.
157
+ if (mode === MODE_SGD) warnStartSelfOnce();
202
158
  }
203
159
 
204
160
  /**
205
161
  * Throw UNSUPPORTED_FEATURE where neato's C would run unported init code for
206
- * this mode/model/start. Call after the nG < 2 guard.
162
+ * this mode/start. Call after the nG < 2 guard.
207
163
  * @see lib/neatogen/neatoinit.c:neatoLayout
208
164
  */
209
- export function assertSupported(g: Graph, mode: number, model: number): void {
165
+ export function assertSupported(g: Graph, mode: number): void {
210
166
  if (maxIterNegative(g)) return;
211
167
  checkStartAttr(g, mode);
212
- checkModel(g, mode, model);
213
168
  }
@@ -1,66 +1,29 @@
1
1
  // SPDX-License-Identifier: EPL-2.0
2
2
 
3
3
  /**
4
- * The subset and circuit distance models of stress majorization, plus the
5
- * three kkutils.c neighbour-vector helpers they use (kept here because
6
- * kkutils.ts is outside the porting task that added them).
4
+ * The subset and circuit distance models of stress majorization, and the choice
5
+ * of `Dij` among them. The kkutils.c neighbour-vector helpers they use live in
6
+ * kkutils.ts, re-exported here.
7
+ * `circuitModel` here is stress.c's (float `Dij` from `vtx_data`); `circuit.ts`'s
8
+ * `circuitModel` is circuit.c's `circuit_model` (`GD_dist` from a graph, KK path).
7
9
  *
8
10
  * `Dij` is C `float` (Float32Array); the circuit matrices are C `double`.
9
11
  * C `NULL` ewgts is the port's empty array.
10
12
  *
11
13
  * @see lib/neatogen/stress.c
12
- * @see lib/neatogen/kkutils.c
13
14
  */
14
15
 
15
16
  import type { VtxData } from './dijkstra.js';
17
+ import { agerr, agwarningf } from '../../common/agerr.js';
16
18
  import { computeApspPacked, computeWeightedApspPacked } from './bfs.js';
17
19
  import { solveCircuit } from './circuit.js';
20
+ import { MODEL_CIRCUIT, MODEL_MDS, MODEL_SUBSET } from './init.js';
21
+ import { artificialWeight, emptyNeighborsVec, fillNeighborsVecUnweighted } from './kkutils.js';
18
22
  import { newArray } from './lu.js';
19
23
  import { fmaxf } from './quad-prog-solve.js';
24
+ import { mdsModel } from './stress.js';
20
25
 
21
- /** 2^64: C `size_t` arithmetic wraps modulo this. */
22
- const SIZE_T_MODULUS = 2 ** 64;
23
-
24
- // ---------------------------------------------------------------------------
25
- // kkutils.c helpers
26
- // ---------------------------------------------------------------------------
27
-
28
- /**
29
- * Count the neighbours of `u` marked in `vVector`.
30
- * @see lib/neatogen/kkutils.c:common_neighbors
31
- */
32
- export function commonNeighbors(graph: readonly VtxData[], u: number, vVector: Int32Array): number {
33
- // count number of common neighbors of 'v_vector' and 'u'
34
- let numSharedNeighbors = 0;
35
- for (let j = 1; j < graph[u]!.nedges; j++) {
36
- const neighbor = graph[u]!.edges[j]!;
37
- if (vVector[neighbor]! > 0) {
38
- // a shared neighbor
39
- numSharedNeighbors++;
40
- }
41
- }
42
- return numSharedNeighbors;
43
- }
44
-
45
- /**
46
- * Mark the neighbours of `vtx` (a node is NOT a neighbour of itself).
47
- * @see lib/neatogen/kkutils.c:fill_neighbors_vec_unweighted
48
- */
49
- export function fillNeighborsVecUnweighted(graph: readonly VtxData[], vtx: number, vtxVec: Int32Array): void {
50
- for (let j = 1; j < graph[vtx]!.nedges; j++) {
51
- vtxVec[graph[vtx]!.edges[j]!] = 1;
52
- }
53
- }
54
-
55
- /**
56
- * Clear the marks set by `fillNeighborsVecUnweighted`.
57
- * @see lib/neatogen/kkutils.c:empty_neighbors_vec
58
- */
59
- export function emptyNeighborsVec(graph: readonly VtxData[], vtx: number, vtxVec: Int32Array): void {
60
- for (let j = 1; j < graph[vtx]!.nedges; j++) {
61
- vtxVec[graph[vtx]!.edges[j]!] = 0;
62
- }
63
- }
26
+ export { commonNeighbors, emptyNeighborsVec, fillNeighborsVecUnweighted } from './kkutils.js';
64
27
 
65
28
  // ---------------------------------------------------------------------------
66
29
  // circuitModel
@@ -124,18 +87,6 @@ function circuitDistances(GmInv: readonly Float64Array[], nG: number, Dij: Float
124
87
  // compute_apsp_artificial_weights_packed
125
88
  // ---------------------------------------------------------------------------
126
89
 
127
- /**
128
- * The artificial weight of edge (i, neighbor): `deg_i + deg_j - 2 * common`
129
- * in C `size_t`, so a negative value (only possible with duplicate
130
- * neighbours) wraps modulo 2^64 before the (float) cast.
131
- * @see lib/neatogen/stress.c:compute_apsp_artificial_weights_packed (stress.c:735-736, 752-753)
132
- */
133
- function artificialWeight(graph: readonly VtxData[], degI: number, neighbor: number, vtxVec: Int32Array): number {
134
- const degJ = graph[neighbor]!.nedges - 1;
135
- const w = degI + degJ - 2 * commonNeighbors(graph, neighbor, vtxVec);
136
- return Math.fround(w < 0 ? w + SIZE_T_MODULUS : w);
137
- }
138
-
139
90
  /**
140
91
  * Weighted branch: each weight is fmaxf(artificial, the caller's ewgts[j]),
141
92
  * read from graph[i].ewgts before graph[i].ewgts is reassigned.
@@ -210,3 +161,48 @@ export function computeApspArtificialWeightsPacked(graph: VtxData[], n: number):
210
161
  }
211
162
  return Dij;
212
163
  }
164
+
165
+ // ---------------------------------------------------------------------------
166
+ // Dij selection
167
+ // ---------------------------------------------------------------------------
168
+
169
+ /**
170
+ * The model branches C writes twice, with the same shape: subset, circuit
171
+ * (warning when it fails), mds. `null` is C's `Dij` still NULL, where each
172
+ * caller picks its own shortest paths. `model` is the defs.h numbering of
173
+ * init.ts, not stress.ts's.
174
+ * @see lib/neatogen/stress.c:stress_majorization_kD_mkernel (stress.c:837-852)
175
+ * @see lib/neatogen/constrained_majorization.c:stress_majorization_with_hierarchy (173-186)
176
+ */
177
+ export function modelDistances(graph: VtxData[], n: number, model: number): Float32Array | null {
178
+ let Dij: Float32Array | null = null;
179
+ if (model === MODEL_SUBSET) {
180
+ /* weight graph to separate high-degree nodes */
181
+ /* and perform slower Dijkstra-based computation */
182
+ Dij = computeApspArtificialWeightsPacked(graph, n);
183
+ } else if (model === MODEL_CIRCUIT) {
184
+ Dij = circuitModel(graph, n);
185
+ if (Dij === null) {
186
+ agwarningf('graph is disconnected. Hence, the circuit model');
187
+ agerr('prev', 'is undefined. Reverting to the shortest path model.');
188
+ }
189
+ } else if (model === MODEL_MDS) {
190
+ Dij = mdsModel(graph, n);
191
+ }
192
+ return Dij;
193
+ }
194
+
195
+ /**
196
+ * The all-pairs-shortest-distances block of `stress_majorization_kD_mkernel`:
197
+ * the model's matrix, else shortest paths, weighted iff `graph->ewgts`.
198
+ *
199
+ * Boundary deviation: C computes this inside the kernel, after its `maxi < 0`
200
+ * return. The port's fused kernel takes `Dij` as a parameter, so the caller runs
201
+ * this first and owns that check (part-8 AD-2).
202
+ * @see lib/neatogen/stress.c:stress_majorization_kD_mkernel (stress.c:833-859)
203
+ */
204
+ export function stressModelDij(graph: VtxData[], n: number, model: number): Float32Array {
205
+ const Dij = modelDistances(graph, n, model);
206
+ if (Dij !== null) return Dij;
207
+ return graph[0]!.ewgts.length !== 0 ? computeWeightedApspPacked(graph, n) : computeApspPacked(graph, n);
208
+ }