@knowvah/dot-engine 2.10.3 → 2.12.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 (342) hide show
  1. package/dist/common/agerr.d.ts +12 -0
  2. package/dist/common/agerr.d.ts.map +1 -1
  3. package/dist/gvc/context.d.ts.map +1 -1
  4. package/dist/gvc/emit-xdot.d.ts.map +1 -1
  5. package/dist/gvc/layout-reset.d.ts +38 -1
  6. package/dist/gvc/layout-reset.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1260 -387
  10. package/dist/index.js.map +4 -4
  11. package/dist/layout/circo/circular.d.ts.map +1 -1
  12. package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
  13. package/dist/layout/dot/edge-route-helpers.d.ts +6 -1
  14. package/dist/layout/dot/edge-route-helpers.d.ts.map +1 -1
  15. package/dist/layout/dot/edge-route-rank.d.ts +4 -1
  16. package/dist/layout/dot/edge-route-rank.d.ts.map +1 -1
  17. package/dist/layout/dot/index.d.ts.map +1 -1
  18. package/dist/layout/dot/init.d.ts.map +1 -1
  19. package/dist/layout/fdp/cluster-edges.d.ts +11 -0
  20. package/dist/layout/fdp/cluster-edges.d.ts.map +1 -1
  21. package/dist/layout/neato/closest.d.ts +20 -0
  22. package/dist/layout/neato/closest.d.ts.map +1 -0
  23. package/dist/layout/neato/constrained-majorization.d.ts +13 -0
  24. package/dist/layout/neato/constrained-majorization.d.ts.map +1 -1
  25. package/dist/layout/neato/embed-graph.d.ts +20 -0
  26. package/dist/layout/neato/embed-graph.d.ts.map +1 -0
  27. package/dist/layout/neato/fdp-adjust.d.ts.map +1 -1
  28. package/dist/layout/neato/index.d.ts.map +1 -1
  29. package/dist/layout/neato/init-dim.d.ts +54 -0
  30. package/dist/layout/neato/init-dim.d.ts.map +1 -0
  31. package/dist/layout/neato/init.d.ts +1 -11
  32. package/dist/layout/neato/init.d.ts.map +1 -1
  33. package/dist/layout/neato/kk.d.ts +4 -2
  34. package/dist/layout/neato/kk.d.ts.map +1 -1
  35. package/dist/layout/neato/matrix-ops-dense.d.ts +34 -0
  36. package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -0
  37. package/dist/layout/neato/pca.d.ts +14 -0
  38. package/dist/layout/neato/pca.d.ts.map +1 -0
  39. package/dist/layout/neato/sgd.d.ts +2 -3
  40. package/dist/layout/neato/sgd.d.ts.map +1 -1
  41. package/dist/layout/neato/start.d.ts +5 -5
  42. package/dist/layout/neato/start.d.ts.map +1 -1
  43. package/dist/layout/neato/stress-kernel.d.ts +10 -2
  44. package/dist/layout/neato/stress-kernel.d.ts.map +1 -1
  45. package/dist/layout/neato/stress-subspace.d.ts +39 -0
  46. package/dist/layout/neato/stress-subspace.d.ts.map +1 -0
  47. package/dist/layout/neato/vpsc-adjust.d.ts.map +1 -1
  48. package/dist/layout/pack/ccomps.d.ts +4 -2
  49. package/dist/layout/pack/ccomps.d.ts.map +1 -1
  50. package/dist/layout/sfdp/index.d.ts.map +1 -1
  51. package/dist/layout/sfdp/init.d.ts +6 -7
  52. package/dist/layout/sfdp/init.d.ts.map +1 -1
  53. package/dist/layout/twopi/circle.d.ts.map +1 -1
  54. package/dist/layout/twopi/index.d.ts.map +1 -1
  55. package/dist/render/dot/attrs.d.ts +7 -0
  56. package/dist/render/dot/attrs.d.ts.map +1 -1
  57. package/dist/render.js +1637 -770
  58. package/dist/render.js.map +4 -4
  59. package/package.json +4 -4
  60. package/src/common/agerr.ts +49 -1
  61. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +20 -0
  62. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +20 -0
  63. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +20 -0
  64. package/src/gvc/__fixtures__/rerender/abom-shift-pack.gv +1 -0
  65. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.1 +22 -0
  66. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +22 -0
  67. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +22 -0
  68. package/src/gvc/__fixtures__/rerender/abom-shift-parity.gv +1 -0
  69. package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.1 +13 -0
  70. package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.2 +13 -0
  71. package/src/gvc/__fixtures__/rerender/abom-shift.dot.plain.nofree.3 +13 -0
  72. package/src/gvc/__fixtures__/rerender/abom-shift.gv +1 -0
  73. package/src/gvc/__fixtures__/rerender/cluster-edge-splines.fdp.plain.1 +10 -0
  74. package/src/gvc/__fixtures__/rerender/cluster-edge-splines.fdp.plain.2 +11 -0
  75. package/src/gvc/__fixtures__/rerender/cluster-edge-splines.gv +9 -0
  76. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.dot.1 +40 -0
  77. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.dot.2 +40 -0
  78. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.plain.noaddr.1 +15 -0
  79. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.plain.noaddr.2 +17 -0
  80. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-plain.1 +40 -0
  81. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-plain.2 +15 -0
  82. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-svg.1 +40 -0
  83. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-dot-svg.2 +99 -0
  84. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-json-json.1 +489 -0
  85. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-json-json.2 +503 -0
  86. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-nofree-dot-svg.1 +40 -0
  87. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.seq-nofree-dot-svg.2 +109 -0
  88. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.xdot.1 +69 -0
  89. package/src/gvc/__fixtures__/rerender/cluster-edges.fdp.xdot.2 +70 -0
  90. package/src/gvc/__fixtures__/rerender/cluster-edges.gv +15 -0
  91. package/src/gvc/__fixtures__/rerender/fdp-1581.fdp.dot.1 +104 -0
  92. package/src/gvc/__fixtures__/rerender/fdp-1581.fdp.dot.2 +104 -0
  93. package/src/gvc/__fixtures__/rerender/fdp-1581.gv +26 -0
  94. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +34 -0
  95. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +34 -0
  96. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +34 -0
  97. package/src/gvc/__fixtures__/rerender/flat-rev-stale.gv +33 -0
  98. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +181 -0
  99. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +218 -0
  100. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +255 -0
  101. package/src/gvc/__fixtures__/rerender/regen.sh +25 -0
  102. package/src/gvc/context.ts +7 -2
  103. package/src/gvc/emit-xdot.ts +37 -7
  104. package/src/gvc/layout-reset.ts +59 -1
  105. package/src/index.ts +4 -0
  106. package/src/layout/circo/circular.ts +3 -1
  107. package/src/layout/dot/edge-route-chain.ts +79 -7
  108. package/src/layout/dot/edge-route-helpers.ts +8 -2
  109. package/src/layout/dot/edge-route-rank.ts +20 -2
  110. package/src/layout/dot/index.ts +17 -2
  111. package/src/layout/dot/init.ts +9 -17
  112. package/src/layout/dot/splines-flat.ts +12 -12
  113. package/src/layout/dot/splines.ts +2 -2
  114. package/src/layout/fdp/cluster-edges.ts +0 -0
  115. package/src/layout/fdp/index.ts +2 -2
  116. package/src/layout/neato/__fixtures__/dim/circuit-dim3.dot +33 -0
  117. package/src/layout/neato/__fixtures__/dim/circuit-dim3.gv +12 -0
  118. package/src/layout/neato/__fixtures__/dim/circuit-dim3.stderr +0 -0
  119. package/src/layout/neato/__fixtures__/dim/circuit-dim3.xdot +54 -0
  120. package/src/layout/neato/__fixtures__/dim/dim11-dimen11.dot +32 -0
  121. package/src/layout/neato/__fixtures__/dim/dim11-dimen11.gv +11 -0
  122. package/src/layout/neato/__fixtures__/dim/dim11-dimen11.stderr +0 -0
  123. package/src/layout/neato/__fixtures__/dim/dim11-dimen11.xdot +53 -0
  124. package/src/layout/neato/__fixtures__/dim/dim3-dimen3.dot +32 -0
  125. package/src/layout/neato/__fixtures__/dim/dim3-dimen3.gv +11 -0
  126. package/src/layout/neato/__fixtures__/dim/dim3-dimen3.stderr +0 -0
  127. package/src/layout/neato/__fixtures__/dim/dim3-dimen3.xdot +53 -0
  128. package/src/layout/neato/__fixtures__/dim/dim3.dot +31 -0
  129. package/src/layout/neato/__fixtures__/dim/dim3.gv +10 -0
  130. package/src/layout/neato/__fixtures__/dim/dim3.stderr +0 -0
  131. package/src/layout/neato/__fixtures__/dim/dim3.xdot +52 -0
  132. package/src/layout/neato/__fixtures__/dim/dim4-dimen4.dot +32 -0
  133. package/src/layout/neato/__fixtures__/dim/dim4-dimen4.gv +11 -0
  134. package/src/layout/neato/__fixtures__/dim/dim4-dimen4.stderr +0 -0
  135. package/src/layout/neato/__fixtures__/dim/dim4-dimen4.xdot +53 -0
  136. package/src/layout/neato/__fixtures__/dim/dimen3.dot +31 -0
  137. package/src/layout/neato/__fixtures__/dim/dimen3.gv +10 -0
  138. package/src/layout/neato/__fixtures__/dim/dimen3.stderr +0 -0
  139. package/src/layout/neato/__fixtures__/dim/dimen3.xdot +52 -0
  140. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +267 -0
  141. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.gv +84 -0
  142. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.stderr +0 -0
  143. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +468 -0
  144. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +267 -0
  145. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.gv +84 -0
  146. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.stderr +0 -0
  147. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +468 -0
  148. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +268 -0
  149. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.gv +85 -0
  150. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.stderr +0 -0
  151. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +469 -0
  152. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +484 -0
  153. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.gv +151 -0
  154. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.stderr +0 -0
  155. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +852 -0
  156. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +34 -0
  157. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.gv +13 -0
  158. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.stderr +0 -0
  159. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +55 -0
  160. package/src/layout/neato/__fixtures__/dim/hier-dim3.dot +33 -0
  161. package/src/layout/neato/__fixtures__/dim/hier-dim3.gv +12 -0
  162. package/src/layout/neato/__fixtures__/dim/hier-dim3.stderr +0 -0
  163. package/src/layout/neato/__fixtures__/dim/hier-dim3.xdot +54 -0
  164. package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +33 -0
  165. package/src/layout/neato/__fixtures__/dim/hier-dim4.gv +12 -0
  166. package/src/layout/neato/__fixtures__/dim/hier-dim4.stderr +0 -0
  167. package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +54 -0
  168. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.dot +32 -0
  169. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.gv +11 -0
  170. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.stderr +0 -0
  171. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim2.xdot +53 -0
  172. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.dot +34 -0
  173. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.gv +13 -0
  174. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.stderr +0 -0
  175. package/src/layout/neato/__fixtures__/dim/hier-dirnone-dim3.xdot +55 -0
  176. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +37 -0
  177. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.gv +12 -0
  178. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.stderr +0 -0
  179. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +58 -0
  180. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +141 -0
  181. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.gv +48 -0
  182. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.stderr +1 -0
  183. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +233 -0
  184. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.dot +21 -0
  185. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.gv +8 -0
  186. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.stderr +1 -0
  187. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim2.xdot +33 -0
  188. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.dot +23 -0
  189. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.gv +10 -0
  190. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.stderr +1 -0
  191. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim3.xdot +35 -0
  192. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.dot +23 -0
  193. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.gv +10 -0
  194. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.stderr +1 -0
  195. package/src/layout/neato/__fixtures__/dim/hier-noedge-dim4.xdot +35 -0
  196. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.dot +26 -0
  197. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.gv +7 -0
  198. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.stderr +0 -0
  199. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim2.xdot +44 -0
  200. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.dot +28 -0
  201. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.gv +9 -0
  202. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.stderr +0 -0
  203. package/src/layout/neato/__fixtures__/dim/hier-nohier-dim3.xdot +46 -0
  204. package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.dot +48 -0
  205. package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.gv +15 -0
  206. package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.stderr +0 -0
  207. package/src/layout/neato/__fixtures__/dim/hier-pack-dim3.xdot +79 -0
  208. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +56 -0
  209. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.gv +17 -0
  210. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.stderr +0 -0
  211. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +94 -0
  212. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +47 -0
  213. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.gv +14 -0
  214. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.stderr +0 -0
  215. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +78 -0
  216. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.dot +34 -0
  217. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.gv +13 -0
  218. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.stderr +0 -0
  219. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim3.xdot +55 -0
  220. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +34 -0
  221. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.gv +13 -0
  222. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.stderr +0 -0
  223. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +55 -0
  224. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +34 -0
  225. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.gv +13 -0
  226. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.stderr +0 -0
  227. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +55 -0
  228. package/src/layout/neato/__fixtures__/dim/hier-two-dim3.dot +15 -0
  229. package/src/layout/neato/__fixtures__/dim/hier-two-dim3.gv +6 -0
  230. package/src/layout/neato/__fixtures__/dim/hier-two-dim3.stderr +0 -0
  231. package/src/layout/neato/__fixtures__/dim/hier-two-dim3.xdot +22 -0
  232. package/src/layout/neato/__fixtures__/dim/ipsep-dim3.dot +33 -0
  233. package/src/layout/neato/__fixtures__/dim/ipsep-dim3.gv +12 -0
  234. package/src/layout/neato/__fixtures__/dim/ipsep-dim3.stderr +0 -0
  235. package/src/layout/neato/__fixtures__/dim/ipsep-dim3.xdot +54 -0
  236. package/src/layout/neato/__fixtures__/dim/kk-dim3.dot +33 -0
  237. package/src/layout/neato/__fixtures__/dim/kk-dim3.gv +12 -0
  238. package/src/layout/neato/__fixtures__/dim/kk-dim3.stderr +0 -0
  239. package/src/layout/neato/__fixtures__/dim/kk-dim3.xdot +54 -0
  240. package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.dot +33 -0
  241. package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.gv +12 -0
  242. package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.stderr +0 -0
  243. package/src/layout/neato/__fixtures__/dim/kk-dim4-dimen4.xdot +54 -0
  244. package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.dot +39 -0
  245. package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.gv +15 -0
  246. package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.stderr +0 -0
  247. package/src/layout/neato/__fixtures__/dim/kk-pins-dim3.xdot +60 -0
  248. package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.dot +33 -0
  249. package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.gv +12 -0
  250. package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.stderr +0 -0
  251. package/src/layout/neato/__fixtures__/dim/overlap-false-dim3.xdot +54 -0
  252. package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.dot +33 -0
  253. package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.gv +12 -0
  254. package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.stderr +0 -0
  255. package/src/layout/neato/__fixtures__/dim/overlap-scale-dim3.xdot +54 -0
  256. package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.dot +33 -0
  257. package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.gv +12 -0
  258. package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.stderr +0 -0
  259. package/src/layout/neato/__fixtures__/dim/overlap-vpsc-dim3.xdot +54 -0
  260. package/src/layout/neato/__fixtures__/dim/pack-dim3.dot +47 -0
  261. package/src/layout/neato/__fixtures__/dim/pack-dim3.gv +14 -0
  262. package/src/layout/neato/__fixtures__/dim/pack-dim3.stderr +0 -0
  263. package/src/layout/neato/__fixtures__/dim/pack-dim3.xdot +78 -0
  264. package/src/layout/neato/__fixtures__/dim/pins-dim3.dot +38 -0
  265. package/src/layout/neato/__fixtures__/dim/pins-dim3.gv +14 -0
  266. package/src/layout/neato/__fixtures__/dim/pins-dim3.stderr +0 -0
  267. package/src/layout/neato/__fixtures__/dim/pins-dim3.xdot +59 -0
  268. package/src/layout/neato/__fixtures__/dim/regen.sh +24 -0
  269. package/src/layout/neato/__fixtures__/dim/regular-dim3.dot +33 -0
  270. package/src/layout/neato/__fixtures__/dim/regular-dim3.gv +12 -0
  271. package/src/layout/neato/__fixtures__/dim/regular-dim3.stderr +0 -0
  272. package/src/layout/neato/__fixtures__/dim/regular-dim3.xdot +54 -0
  273. package/src/layout/neato/__fixtures__/dim/sgd-dim3.dot +33 -0
  274. package/src/layout/neato/__fixtures__/dim/sgd-dim3.gv +12 -0
  275. package/src/layout/neato/__fixtures__/dim/sgd-dim3.stderr +0 -0
  276. package/src/layout/neato/__fixtures__/dim/sgd-dim3.xdot +54 -0
  277. package/src/layout/neato/__fixtures__/dim/smart-units.json +16 -0
  278. package/src/layout/neato/__fixtures__/dim/subset-dim3.dot +33 -0
  279. package/src/layout/neato/__fixtures__/dim/subset-dim3.gv +12 -0
  280. package/src/layout/neato/__fixtures__/dim/subset-dim3.stderr +0 -0
  281. package/src/layout/neato/__fixtures__/dim/subset-dim3.xdot +54 -0
  282. package/src/layout/neato/closest.ts +206 -0
  283. package/src/layout/neato/constrained-majorization.ts +4 -23
  284. package/src/layout/neato/embed-graph.ts +81 -0
  285. package/src/layout/neato/fdp-adjust.ts +22 -8
  286. package/src/layout/neato/index.ts +26 -17
  287. package/src/layout/neato/init-dim.ts +165 -0
  288. package/src/layout/neato/init.ts +9 -35
  289. package/src/layout/neato/kk.ts +47 -41
  290. package/src/layout/neato/matrix-ops-dense.ts +232 -0
  291. package/src/layout/neato/pca.ts +60 -0
  292. package/src/layout/neato/sgd.ts +14 -13
  293. package/src/layout/neato/start.ts +8 -5
  294. package/src/layout/neato/stress-kernel.ts +65 -5
  295. package/src/layout/neato/stress-subspace.ts +371 -0
  296. package/src/layout/neato/vpsc-adjust.ts +3 -1
  297. package/src/layout/pack/__fixtures__/cc-reuse/circo.dot +23 -0
  298. package/src/layout/pack/__fixtures__/cc-reuse/circo.gv +1 -0
  299. package/src/layout/pack/__fixtures__/cc-reuse/circo.stderr +0 -0
  300. package/src/layout/pack/__fixtures__/cc-reuse/circo.xdot +38 -0
  301. package/src/layout/pack/__fixtures__/cc-reuse/neato.dot +23 -0
  302. package/src/layout/pack/__fixtures__/cc-reuse/neato.gv +1 -0
  303. package/src/layout/pack/__fixtures__/cc-reuse/neato.stderr +0 -0
  304. package/src/layout/pack/__fixtures__/cc-reuse/neato.xdot +38 -0
  305. package/src/layout/pack/__fixtures__/cc-reuse/osage.dot +23 -0
  306. package/src/layout/pack/__fixtures__/cc-reuse/osage.gv +1 -0
  307. package/src/layout/pack/__fixtures__/cc-reuse/osage.stderr +0 -0
  308. package/src/layout/pack/__fixtures__/cc-reuse/osage.xdot +38 -0
  309. package/src/layout/pack/__fixtures__/cc-reuse/regen.sh +24 -0
  310. package/src/layout/pack/__fixtures__/cc-reuse/sfdp.dot +21 -0
  311. package/src/layout/pack/__fixtures__/cc-reuse/sfdp.gv +1 -0
  312. package/src/layout/pack/__fixtures__/cc-reuse/sfdp.stderr +0 -0
  313. package/src/layout/pack/__fixtures__/cc-reuse/sfdp.xdot +36 -0
  314. package/src/layout/pack/__fixtures__/cc-reuse/twopi.dot +21 -0
  315. package/src/layout/pack/__fixtures__/cc-reuse/twopi.gv +1 -0
  316. package/src/layout/pack/__fixtures__/cc-reuse/twopi.stderr +1 -0
  317. package/src/layout/pack/__fixtures__/cc-reuse/twopi.xdot +36 -0
  318. package/src/layout/pack/ccomps.ts +34 -6
  319. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +32 -0
  320. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.gv +11 -0
  321. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.stderr +0 -0
  322. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.xdot +53 -0
  323. package/src/layout/sfdp/__fixtures__/dim/dim3.dot +31 -0
  324. package/src/layout/sfdp/__fixtures__/dim/dim3.gv +10 -0
  325. package/src/layout/sfdp/__fixtures__/dim/dim3.stderr +0 -0
  326. package/src/layout/sfdp/__fixtures__/dim/dim3.xdot +52 -0
  327. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +32 -0
  328. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.gv +11 -0
  329. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.stderr +0 -0
  330. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.xdot +53 -0
  331. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +33 -0
  332. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.gv +12 -0
  333. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.stderr +0 -0
  334. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.xdot +54 -0
  335. package/src/layout/sfdp/__fixtures__/dim/regen.sh +24 -0
  336. package/src/layout/sfdp/index.ts +15 -10
  337. package/src/layout/sfdp/init.ts +26 -11
  338. package/src/layout/twopi/circle.ts +5 -1
  339. package/src/layout/twopi/index.ts +3 -0
  340. package/src/render/dot/agwrite.ts +2 -2
  341. package/src/render/dot/attrs.ts +16 -0
  342. package/src/render/dot/write-back.ts +2 -2
@@ -0,0 +1,255 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Generated by graphviz version 16.1.0 (20261012.1431)
5
+ -->
6
+ <!-- Title: M Pages: 1 -->
7
+ <svg width="655pt" height="368pt"
8
+ viewBox="0.00 0.00 655.00 368.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 363.6)">
10
+ <title>M</title>
11
+ <polygon fill="white" stroke="none" points="-4,4 -4,-363.6 651,-363.6 651,4 -4,4"/>
12
+ <!-- a -->
13
+ <g id="node1" class="node">
14
+ <title>a</title>
15
+ <ellipse fill="none" stroke="black" cx="205" cy="-341.6" rx="27" ry="18"/>
16
+ <text xml:space="preserve" text-anchor="middle" x="205" y="-337.4" font-family="Times,serif" font-size="14.00">a</text>
17
+ </g>
18
+ <!-- b -->
19
+ <g id="node2" class="node">
20
+ <title>b</title>
21
+ <ellipse fill="none" stroke="black" cx="205" cy="-252.8" rx="27" ry="18"/>
22
+ <text xml:space="preserve" text-anchor="middle" x="205" y="-248.6" font-family="Times,serif" font-size="14.00">b</text>
23
+ </g>
24
+ <!-- a&#45;&gt;b -->
25
+ <g id="edge1" class="edge">
26
+ <title>a&#45;&gt;b</title>
27
+ <path fill="none" stroke="black" d="M559.16,-323.77C558.32,-315.99 558.06,-306.54 558.38,-297.72"/>
28
+ <polygon fill="black" stroke="black" points="561.87,-298.03 559.07,-287.82 554.88,-297.55 561.87,-298.03"/>
29
+ <path fill="none" stroke="black" d="M256.9,-209.69C268,-214.71 281.89,-220.08 295,-222.6 321.19,-227.64 329.23,-229.44 355,-222.6 359.44,-221.42 363.9,-219.65 368.17,-217.6"/>
30
+ <polygon fill="black" stroke="black" points="369.84,-220.67 376.93,-212.8 366.48,-214.53 369.84,-220.67"/>
31
+ <path fill="none" stroke="black" d="M199.54,-323.86C198.22,-312.05 197.91,-295.94 198.62,-282.14"/>
32
+ <polygon fill="black" stroke="black" points="202.1,-282.53 199.4,-272.29 195.13,-281.99 202.1,-282.53"/>
33
+ </g>
34
+ <!-- a&#45;&gt;b -->
35
+ <g id="edge2" class="edge">
36
+ <title>a&#45;&gt;b</title>
37
+ <path fill="none" stroke="black" d="M570.84,-323.77C571.68,-315.99 571.94,-306.54 571.62,-297.72"/>
38
+ <polygon fill="black" stroke="black" points="575.12,-297.55 570.93,-287.82 568.13,-298.03 575.12,-297.55"/>
39
+ <path fill="none" stroke="black" d="M255.6,-210.73C268.24,-217.45 285.01,-225.14 301,-228.6 321.85,-233.12 328.49,-234.48 349,-228.6 356.49,-226.45 363.94,-222.76 370.67,-218.68"/>
40
+ <polygon fill="black" stroke="black" points="372.24,-221.84 378.65,-213.4 368.38,-216 372.24,-221.84"/>
41
+ <path fill="none" stroke="black" d="M210.46,-323.86C211.78,-312.05 212.09,-295.94 211.38,-282.14"/>
42
+ <polygon fill="black" stroke="black" points="214.87,-281.99 210.6,-272.29 207.9,-282.53 214.87,-281.99"/>
43
+ </g>
44
+ <!-- c -->
45
+ <g id="node3" class="node">
46
+ <title>c</title>
47
+ <ellipse fill="none" stroke="black" cx="83" cy="-252.8" rx="27" ry="18"/>
48
+ <text xml:space="preserve" text-anchor="middle" x="83" y="-248.6" font-family="Times,serif" font-size="14.00">c</text>
49
+ </g>
50
+ <!-- a&#45;&gt;c -->
51
+ <g id="edge3" class="edge">
52
+ <title>a&#45;&gt;c</title>
53
+ <path fill="none" stroke="black" d="M550.94,-326.16C510.51,-284.62 393.69,-164.62 344.86,-114.46"/>
54
+ <polygon fill="black" stroke="black" points="347.63,-112.29 338.15,-107.56 342.62,-117.17 347.63,-112.29"/>
55
+ <path fill="none" stroke="black" d="M262.49,-198.6C269.99,-198.6 278.27,-198.6 286.27,-198.6"/>
56
+ <polygon fill="black" stroke="black" points="286.16,-202.1 296.16,-198.6 286.16,-195.1 286.16,-202.1"/>
57
+ <path fill="none" stroke="black" d="M187,-327.79C166.82,-313.43 133.86,-289.98 110.45,-273.33"/>
58
+ <polygon fill="black" stroke="black" points="112.49,-270.48 102.31,-267.54 108.43,-276.19 112.49,-270.48"/>
59
+ <text xml:space="preserve" text-anchor="middle" x="160.37" y="-293" font-family="Times,serif" font-size="14.00">l1</text>
60
+ </g>
61
+ <!-- g -->
62
+ <g id="node8" class="node">
63
+ <title>g</title>
64
+ <ellipse fill="none" stroke="black" cx="287" cy="-91" rx="27" ry="18"/>
65
+ <text xml:space="preserve" text-anchor="middle" x="287" y="-86.8" font-family="Times,serif" font-size="14.00">g</text>
66
+ </g>
67
+ <!-- a&#45;&gt;g -->
68
+ <g id="edge13" class="edge">
69
+ <title>a&#45;&gt;g</title>
70
+ <path fill="none" stroke="black" d="M577.94,-325.43C588.48,-315.7 602.28,-302.01 610,-286.6 637.08,-232.5 640.09,-160.03 642.36,-120.56"/>
71
+ <polygon fill="black" stroke="black" points="645.84,-120.91 642.98,-110.71 638.86,-120.47 645.84,-120.91"/>
72
+ <path fill="none" stroke="black" d="M256.9,-209.69C268,-214.71 281.89,-220.08 295,-222.6 321.19,-227.64 508.81,-227.64 535,-222.6 544.22,-220.82 553.82,-217.65 562.57,-214.17"/>
73
+ <polygon fill="black" stroke="black" points="563.88,-217.42 571.71,-210.29 561.14,-210.98 563.88,-217.42"/>
74
+ <path fill="none" stroke="black" d="M214.11,-324.39C224.83,-311.16 241.15,-291.34 250,-270.8 271.56,-220.77 276.76,-156.48 280.67,-120.21"/>
75
+ <polygon fill="black" stroke="black" points="284.11,-120.88 281.79,-110.54 277.16,-120.07 284.11,-120.88"/>
76
+ </g>
77
+ <!-- b&#45;&gt;b -->
78
+ <g id="edge15" class="edge">
79
+ <title>b&#45;&gt;b</title>
80
+ <path fill="none" stroke="black" d="M590.44,-275.38C601.03,-275.85 610,-273.59 610,-268.6 610,-265.56 606.67,-263.53 601.67,-262.52"/>
81
+ <polygon fill="black" stroke="black" points="602.15,-259.04 591.95,-261.91 601.72,-266.03 602.15,-259.04"/>
82
+ <path fill="none" stroke="black" d="M422.44,-205.38C433.03,-205.85 442,-203.59 442,-198.6 442,-195.56 438.67,-193.53 433.67,-192.52"/>
83
+ <polygon fill="black" stroke="black" points="434.15,-189.04 423.95,-191.91 433.72,-196.03 434.15,-189.04"/>
84
+ <path fill="none" stroke="black" d="M230.44,-259.58C241.03,-260.05 250,-257.79 250,-252.8 250,-249.76 246.67,-247.73 241.67,-246.72"/>
85
+ <polygon fill="black" stroke="black" points="242.15,-243.24 231.95,-246.11 241.72,-250.23 242.15,-243.24"/>
86
+ </g>
87
+ <!-- f -->
88
+ <g id="node7" class="node">
89
+ <title>f</title>
90
+ <ellipse fill="none" stroke="black" cx="223" cy="-179.8" rx="27" ry="18"/>
91
+ <text xml:space="preserve" text-anchor="middle" x="223" y="-175.6" font-family="Times,serif" font-size="14.00">f</text>
92
+ </g>
93
+ <!-- b&#45;&gt;f -->
94
+ <g id="edge11" class="edge">
95
+ <title>b&#45;&gt;f</title>
96
+ <path fill="none" stroke="black" d="M565,-250.45C565,-238.76 565,-222.99 565,-209.42"/>
97
+ <polygon fill="black" stroke="black" points="568.5,-209.72 565,-199.72 561.5,-209.72 568.5,-209.72"/>
98
+ <path fill="none" stroke="black" d="M424.42,-198.6C438.41,-198.6 452.4,-198.6 466.4,-198.6"/>
99
+ <polygon fill="black" stroke="black" points="466.1,-202.1 476.1,-198.6 466.1,-195.1 466.1,-202.1"/>
100
+ <path fill="none" stroke="black" d="M209.36,-234.61C211.33,-226.85 213.7,-217.48 215.91,-208.75"/>
101
+ <polygon fill="black" stroke="black" points="219.25,-209.85 218.31,-199.3 212.46,-208.13 219.25,-209.85"/>
102
+ </g>
103
+ <!-- d -->
104
+ <g id="node4" class="node">
105
+ <title>d</title>
106
+ <ellipse fill="none" stroke="black" cx="99" cy="-18" rx="27" ry="18"/>
107
+ <text xml:space="preserve" text-anchor="middle" x="99" y="-13.8" font-family="Times,serif" font-size="14.00">d</text>
108
+ </g>
109
+ <!-- c&#45;&gt;d -->
110
+ <g id="edge4" class="edge">
111
+ <title>c&#45;&gt;d</title>
112
+ <path fill="none" stroke="black" d="M349.99,-88.43C357.74,-87.96 366.2,-87.7 374,-88 374.12,-88 374.24,-88.01 374.36,-88.01"/>
113
+ <polygon fill="black" stroke="black" points="374.05,-91.5 384.23,-88.55 374.43,-84.51 374.05,-91.5"/>
114
+ <path fill="none" stroke="black" d="M310.28,-183.16C306.96,-176.92 304.09,-169.49 302,-162.6 290.21,-123.67 286.14,-76.56 287.01,-47.18"/>
115
+ <polygon fill="black" stroke="black" points="290.5,-47.44 287.59,-37.26 283.51,-47.03 290.5,-47.44"/>
116
+ <path fill="none" stroke="black" d="M80.44,-234.68C79.46,-194.99 85.95,-96.36 92.44,-47.44"/>
117
+ <polygon fill="black" stroke="black" points="95.89,-48.04 93.86,-37.64 88.96,-47.03 95.89,-48.04"/>
118
+ </g>
119
+ <!-- c&#45;&gt;d -->
120
+ <g id="edge6" class="edge">
121
+ <title>c&#45;&gt;d</title>
122
+ <path fill="none" stroke="black" d="M350.49,-91C357.99,-91 366.27,-91 374.27,-91"/>
123
+ <polygon fill="black" stroke="black" points="374.16,-94.5 384.16,-91 374.16,-87.5 374.16,-94.5"/>
124
+ <path fill="none" stroke="black" d="M324.84,-180.47C324.19,-153.21 321.31,-98.49 309,-54 308.24,-51.24 307.28,-48.42 306.22,-45.64"/>
125
+ <polygon fill="black" stroke="black" points="309.54,-44.51 302.37,-36.72 303.11,-47.29 309.54,-44.51"/>
126
+ <path fill="none" stroke="black" d="M96.12,-236.69C100.56,-230.84 105.12,-223.85 108,-216.8 111.24,-208.89 110.09,-206.3 111,-197.8 117.79,-134.21 130.33,-116.32 116,-54 115.35,-51.18 114.44,-48.32 113.38,-45.51"/>
127
+ <polygon fill="black" stroke="black" points="116.64,-44.24 109.36,-36.55 110.26,-47.1 116.64,-44.24"/>
128
+ <text xml:space="preserve" text-anchor="middle" x="127.04" y="-131.2" font-family="Times,serif" font-size="14.00">f1</text>
129
+ </g>
130
+ <!-- e -->
131
+ <g id="node5" class="node">
132
+ <title>e</title>
133
+ <ellipse fill="none" stroke="black" cx="27" cy="-18" rx="27" ry="18"/>
134
+ <text xml:space="preserve" text-anchor="middle" x="27" y="-13.8" font-family="Times,serif" font-size="14.00">e</text>
135
+ </g>
136
+ <!-- c&#45;&gt;e -->
137
+ <g id="edge7" class="edge">
138
+ <title>c&#45;&gt;e</title>
139
+ <path fill="none" stroke="black" d="M340.74,-104.99C352.11,-113.04 367.58,-122.37 383,-126.6 408.72,-133.66 417.96,-135.78 443,-126.6 450.36,-123.9 457.31,-119.28 463.36,-114.25"/>
140
+ <polygon fill="black" stroke="black" points="465.41,-117.12 470.41,-107.77 460.68,-111.96 465.41,-117.12"/>
141
+ <path fill="none" stroke="black" d="M323.42,-180.32C325.09,-174.72 327.29,-168.45 329,-162.6 340.62,-122.79 349.99,-75.62 357.58,-46.5"/>
142
+ <polygon fill="black" stroke="black" points="360.91,-47.59 360.21,-37.02 354.17,-45.72 360.91,-47.59"/>
143
+ <path fill="none" stroke="black" d="M75.27,-235.06C62.06,-195.65 37.95,-96.68 29.26,-47.57"/>
144
+ <polygon fill="black" stroke="black" points="32.71,-47.01 27.64,-37.71 25.8,-48.15 32.71,-47.01"/>
145
+ </g>
146
+ <!-- c&#45;&gt;e -->
147
+ <g id="edge8" class="edge">
148
+ <title>c&#45;&gt;e</title>
149
+ <path fill="none" stroke="black" d="M336.62,-106.78C348.85,-119.62 368.04,-136.81 389,-144.2 409.12,-151.3 417.51,-152.87 437,-144.2 449.62,-138.59 460.32,-127.84 468.39,-117.46"/>
150
+ <polygon fill="black" stroke="black" points="471.18,-119.59 474.17,-109.43 465.49,-115.51 471.18,-119.59"/>
151
+ <path fill="none" stroke="black" d="M339.2,-183.11C342.32,-176.87 345,-169.44 347,-162.6 358.51,-123.18 367.8,-76.55 370.88,-47.36"/>
152
+ <polygon fill="black" stroke="black" points="374.36,-47.76 371.68,-37.51 367.38,-47.19 374.36,-47.76"/>
153
+ <path fill="none" stroke="black" d="M82.62,-234.68C76.73,-194.72 53.01,-94.98 38.14,-46.42"/>
154
+ <polygon fill="black" stroke="black" points="41.49,-45.42 35.12,-36.96 34.82,-47.55 41.49,-45.42"/>
155
+ </g>
156
+ <!-- h -->
157
+ <g id="node6" class="node">
158
+ <title>h</title>
159
+ <ellipse fill="none" stroke="black" cx="189" cy="-18" rx="27" ry="18"/>
160
+ <text xml:space="preserve" text-anchor="middle" x="189" y="-13.8" font-family="Times,serif" font-size="14.00">h</text>
161
+ </g>
162
+ <!-- c&#45;&gt;h -->
163
+ <g id="edge10" class="edge">
164
+ <title>c&#45;&gt;h</title>
165
+ <path fill="none" stroke="black" d="M338.58,-106.16C350.48,-116.63 367.89,-129.66 386,-135.4 439.38,-152.32 458.62,-152.32 512,-135.4 526.15,-130.91 539.87,-121.98 550.87,-113.29"/>
166
+ <polygon fill="black" stroke="black" points="552.82,-116.22 558.26,-107.13 548.34,-110.84 552.82,-116.22"/>
167
+ <path fill="none" stroke="black" d="M340.75,-183.59C347.31,-177.43 354.83,-169.94 361,-162.6 393.49,-123.96 425.37,-74.5 443.55,-44.86"/>
168
+ <polygon fill="black" stroke="black" points="446.4,-46.91 448.61,-36.55 440.42,-43.28 446.4,-46.91"/>
169
+ <path fill="none" stroke="black" d="M100.81,-239.11C108.22,-233.07 116.39,-225.31 122,-216.8 157.71,-162.65 176.23,-87.57 184.15,-47.27"/>
170
+ <polygon fill="black" stroke="black" points="187.55,-48.14 185.95,-37.66 180.67,-46.85 187.55,-48.14"/>
171
+ </g>
172
+ <!-- d&#45;&gt;c -->
173
+ <g id="edge5" class="edge">
174
+ <title>d&#45;&gt;c</title>
175
+ <path fill="none" stroke="black" d="M101.56,-36.14C102.53,-75.86 96.04,-174.49 89.56,-223.39"/>
176
+ <polygon fill="black" stroke="black" points="86.11,-222.78 88.13,-233.18 93.04,-223.79 86.11,-222.78"/>
177
+ <path fill="none" stroke="black" d="M394.09,-104.32C384.69,-109.39 373.04,-113.39 362.17,-110.8 359.21,-110.1 356.23,-109.13 353.29,-108"/>
178
+ <polygon fill="black" stroke="black" points="354.97,-104.92 344.42,-104 352.1,-111.3 354.97,-104.92"/>
179
+ <path fill="none" stroke="black" d="M322.29,-169.62C321.48,-167.26 320.7,-164.9 320,-162.6 306.53,-118.11 303.13,-62.93 298.88,-35.74"/>
180
+ <polygon fill="black" stroke="black" points="318.93,-170.61 325.48,-178.93 325.55,-168.34 318.93,-170.61"/>
181
+ </g>
182
+ <!-- d&#45;&gt;h -->
183
+ <g id="edge9" class="edge">
184
+ <title>d&#45;&gt;h</title>
185
+ <path fill="none" stroke="black" d="M429.35,-105.53C452.03,-123.82 494.27,-151.19 529.83,-136.4 540.08,-132.14 549.21,-124.29 556.53,-116.31"/>
186
+ <polygon fill="black" stroke="black" points="559,-118.81 562.76,-108.91 553.64,-114.3 559,-118.81"/>
187
+ <path fill="none" stroke="black" d="M304.27,-34.75C312.33,-45.15 324.21,-57.6 338.17,-63.4 370.69,-76.92 408.81,-56.73 433.41,-39.13"/>
188
+ <polygon fill="black" stroke="black" points="435.34,-42.05 441.23,-33.25 431.13,-36.46 435.34,-42.05"/>
189
+ <path fill="none" stroke="black" d="M126.49,-18C133.99,-18 142.27,-18 150.27,-18"/>
190
+ <polygon fill="black" stroke="black" points="150.16,-21.5 160.16,-18 150.16,-14.5 150.16,-21.5"/>
191
+ <text xml:space="preserve" text-anchor="middle" x="144" y="-25.2" font-family="Times,serif" font-size="14.00">f2</text>
192
+ </g>
193
+ <!-- e&#45;&gt;h -->
194
+ <g id="edge16" class="edge">
195
+ <title>e:e&#45;&gt;h:w</title>
196
+ <path fill="none" stroke="black" d="M512,-91C523.38,-91 528.68,-91 536.55,-91"/>
197
+ <polygon fill="black" stroke="black" points="536.49,-94.5 546.49,-91 536.49,-87.5 536.49,-94.5"/>
198
+ <path fill="none" stroke="black" d="M396,-18C407.38,-18 412.68,-18 420.55,-18"/>
199
+ <polygon fill="black" stroke="black" points="420.49,-21.5 430.49,-18 420.49,-14.5 420.49,-21.5"/>
200
+ <path fill="none" stroke="black" d="M54,-18C98.06,-18 111.79,-18 150.87,-18"/>
201
+ <polygon fill="black" stroke="black" points="150.49,-21.5 160.49,-18 150.49,-14.5 150.49,-21.5"/>
202
+ </g>
203
+ <!-- f&#45;&gt;h -->
204
+ <g id="edge17" class="edge">
205
+ <title>f&#45;&gt;h</title>
206
+ <path fill="none" stroke="black" d="M534.02,-162.32C520.61,-152.87 509.51,-140.27 517,-127 522.35,-117.52 531.41,-110.32 540.8,-105"/>
207
+ <polygon fill="black" stroke="black" points="531.87,-165.1 542.19,-167.51 535.63,-159.19 531.87,-165.1"/>
208
+ <polygon fill="black" stroke="black" points="542.22,-108.2 549.6,-100.6 539.09,-101.94 542.22,-108.2"/>
209
+ <path fill="none" stroke="black" d="M497.72,-169.35C489.09,-135.82 474.78,-80.25 466.18,-46.88"/>
210
+ <polygon fill="black" stroke="black" points="494.33,-170.2 500.21,-179.01 501.11,-168.45 494.33,-170.2"/>
211
+ <polygon fill="black" stroke="black" points="469.66,-46.35 463.77,-37.54 462.88,-48.1 469.66,-46.35"/>
212
+ <path fill="none" stroke="black" d="M216.98,-150.49C210.77,-121.3 201.14,-76.06 194.96,-46.99"/>
213
+ <polygon fill="black" stroke="black" points="213.54,-151.17 219.05,-160.22 220.39,-149.71 213.54,-151.17"/>
214
+ <polygon fill="black" stroke="black" points="198.43,-46.51 192.93,-37.46 191.59,-47.97 198.43,-46.51"/>
215
+ </g>
216
+ <!-- f&#45;&gt;g -->
217
+ <g id="edge12" class="edge">
218
+ <title>f&#45;&gt;g</title>
219
+ <path fill="none" stroke="black" d="M578.91,-164.08C591.63,-150.61 610.65,-130.47 625.36,-114.9"/>
220
+ <polygon fill="black" stroke="black" points="627.66,-117.57 631.98,-107.9 622.57,-112.76 627.66,-117.57"/>
221
+ <path fill="none" stroke="black" d="M532.42,-198.6C540.4,-198.6 548.37,-198.6 556.35,-198.6"/>
222
+ <polygon fill="black" stroke="black" points="556.11,-202.1 566.11,-198.6 556.11,-195.1 556.11,-202.1"/>
223
+ <path fill="none" stroke="black" d="M234.44,-163.28C243.94,-150.4 257.63,-131.84 268.65,-116.89"/>
224
+ <polygon fill="black" stroke="black" points="271.43,-119.02 274.54,-108.89 265.79,-114.87 271.43,-119.02"/>
225
+ </g>
226
+ <!-- g&#45;&gt;a -->
227
+ <g id="edge14" class="edge">
228
+ <title>g&#45;&gt;a</title>
229
+ <path fill="none" stroke="black" d="M292.25,-109.04C295.73,-141.76 292,-215.11 268,-270.8 259.94,-289.5 245.7,-307.59 232.6,-320.67"/>
230
+ <polygon fill="black" stroke="black" points="230.26,-318.08 225.35,-327.46 235.04,-323.19 230.26,-318.08"/>
231
+ <path fill="none" stroke="black" d="M652.96,-108.93C658.45,-144.07 658.03,-226.63 628,-286.6 620.72,-301.15 608.01,-314.16 595.76,-323.76"/>
232
+ <polygon fill="black" stroke="black" points="593.85,-320.82 587.8,-329.52 597.95,-326.49 593.85,-320.82"/>
233
+ <path fill="none" stroke="black" d="M265.78,-215.87C276.57,-221.03 289.01,-226 301,-228.6 325.76,-233.96 504.24,-233.96 529,-228.6 544.99,-225.14 561.76,-217.45 574.4,-210.73"/>
234
+ <polygon fill="black" stroke="black" points="267.46,-212.8 256.96,-211.41 264.3,-219.05 267.46,-212.8"/>
235
+ </g>
236
+ <!-- i -->
237
+ <g id="node9" class="node">
238
+ <title>i</title>
239
+ <ellipse fill="none" stroke="black" cx="287" cy="-18" rx="27" ry="18"/>
240
+ <text xml:space="preserve" text-anchor="middle" x="287" y="-13.8" font-family="Times,serif" font-size="14.00">i</text>
241
+ </g>
242
+ <!-- g&#45;&gt;i -->
243
+ <g id="edge18" class="edge">
244
+ <title>g&#45;&gt;i</title>
245
+ <path fill="none" stroke="black" d="M647,-72.81C647,-65.23 647,-56.1 647,-47.54"/>
246
+ <polygon fill="black" stroke="black" points="650.5,-47.54 647,-37.54 643.5,-47.54 650.5,-47.54"/>
247
+ <path fill="none" stroke="black" d="M622.42,-198.6C630.4,-198.6 638.37,-198.6 646.35,-198.6"/>
248
+ <polygon fill="black" stroke="black" points="646.11,-202.1 656.11,-198.6 646.11,-195.1 646.11,-202.1"/>
249
+ <path fill="none" stroke="black" d="M287,-72.81C287,-65.23 287,-56.1 287,-47.54"/>
250
+ <polygon fill="black" stroke="black" points="290.5,-47.54 287,-37.54 283.5,-47.54 290.5,-47.54"/>
251
+ <text xml:space="preserve" text-anchor="middle" x="283.5" y="-40.23" font-family="Times,serif" font-size="14.00">h</text>
252
+ <text xml:space="preserve" text-anchor="middle" x="645.06" y="-77.01" font-family="Times,serif" font-size="14.00">t</text>
253
+ </g>
254
+ </g>
255
+ </svg>
@@ -51,6 +51,13 @@ done
51
51
  for e in dot fdp patchwork; do
52
52
  run multi-edge "$e" plain nofree "multi-edge.$e.plain.nofree"
53
53
  done
54
+ run multi-edge dot svg nofree multi-edge.dot.svg.nofree
55
+ # A flat label at rank 0 runs abomination on every layout: the shift must not carry over.
56
+ for c in abom-shift abom-shift-parity abom-shift-pack; do
57
+ run "$c" dot plain nofree "$c.dot.plain.nofree"
58
+ done
59
+ # tests/2368.dot: its third layout merges an edge flagged adjacent into a new reversed flat edge.
60
+ run flat-rev-stale dot plain nofree flat-rev-stale.dot.plain.nofree
54
61
  for e in neato fdp circo; do
55
62
  run filing dot plain "then:$e" "filing.dot.plain.then-$e"
56
63
  rm -f "filing.dot.plain.then-$e.1"
@@ -79,3 +86,21 @@ seq neato-pos neato json-plain l,json,f,l,plain,f
79
86
  seq neato-pos neato json0-plain l,json0,f,l,plain,f
80
87
  seq filing dot json-json l,json,f,l,json,f
81
88
  run sized-clip neato xdot 2 sized-clip.neato.xdot
89
+ # Part 10 T14. An edge to a cluster: -Tdot, -Txdot and -Tjson undo the first cycle's proxy nodes.
90
+ run cluster-edges fdp dot 2 cluster-edges.fdp.dot
91
+ run cluster-edges fdp xdot 2 cluster-edges.fdp.xdot
92
+ seq cluster-edges fdp dot-svg l,dot,f,l,svg,f
93
+ seq cluster-edges fdp dot-plain l,dot,f,l,plain,f
94
+ seq cluster-edges fdp json-json l,json,f,l,json,f
95
+ seq cluster-edges fdp nofree-dot-svg l,dot,l,svg
96
+ # The cluster-edge record outlives gvFreeLayout, so render 2 keeps line segments.
97
+ run cluster-edge-splines fdp plain 2 cluster-edge-splines.fdp.plain
98
+ # Native's render 2 of fdp-1581 takes one of two values per process (deriveGraph compares node addresses,
99
+ # lib/fdpgen/layout.c:466). Keep the one the port's id order gives; an unlucky run retries.
100
+ for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
101
+ run fdp-1581 fdp dot 2 fdp-1581.fdp.dot
102
+ grep -q 'bb="0,-24.8,29358,25432"' fdp-1581.fdp.dot.2 && break
103
+ done
104
+ grep -q 'bb="0,-24.8,29358,25432"' fdp-1581.fdp.dot.2
105
+ # cluster-edges.fdp.plain.noaddr.{1,2} are not regenerated here: render 2 of plain moves with node addresses
106
+ # at the same three sites, so they come from T14's patched plugin, GVTS_NOADDR=1, which orders by ND_id.
@@ -28,7 +28,7 @@ import type { ImageResolver } from './image-resolver.js';
28
28
  import type { RenderJob } from './job.js'; // scaffold in T25; full class in T26
29
29
  import { resetRenderState } from '../common/render-state.js';
30
30
  import { RenderError, invalidArgType, invalidArgValue } from '../errors.js';
31
- import { layoutWasFreed, resetLayoutRecords } from './layout-reset.js';
31
+ import { bindDotRoot, resetFreedLayouts, undoRenderedClusterEdges } from './layout-reset.js';
32
32
  import { initXdot } from './init-xdot.js';
33
33
  import { writeLayoutBb } from './layout-bb.js';
34
34
 
@@ -326,7 +326,12 @@ export class GvcContext {
326
326
  }
327
327
  engine = override;
328
328
  }
329
- if (layoutWasFreed(g)) resetLayoutRecords(g);
329
+ undoRenderedClusterEdges(g);
330
+ if (g.root) { // test doubles have no graph tree
331
+ resetFreedLayouts(g);
332
+ bindDotRoot(g);
333
+ g.root.info.gvc = this; // @see lib/gvc/gvlayout.c:61-64
334
+ }
330
335
  if (g.info) g.info.gvc = this;
331
336
  initXdot(g); // C: graph_init, before the engine. @see lib/common/input.c:784
332
337
  engine.layout(g);
@@ -9,12 +9,12 @@
9
9
 
10
10
  import { agwarningf } from '../common/agerr.js';
11
11
  import { lateInt } from '../common/nodeinit.js';
12
- import { findStopColor, parseStyleFlags, resolvePenType, resolvePenWidth, styleTokens } from '../common/style-resolve.js';
12
+ import { findStopColor, parseStyleFlags, resolvePenWidth, styleName, styleTokens } from '../common/style-resolve.js';
13
13
  import type { Box, Point } from '../model/geom.js';
14
14
  import type { Graph } from '../model/graph.js';
15
15
  import { resolveFillColorName, resolveRenderColor } from '../render/color-resolve.js';
16
16
  import type { XdotColor, XdotOp, XdotPoint } from '../xdot/types.js';
17
- import { FillType, type RendererPlugin } from './context.js';
17
+ import { FillType, PenType, type RendererPlugin } from './context.js';
18
18
  import { transformPoint } from './device-transform.js';
19
19
  import { graphXdots } from './init-xdot.js';
20
20
  import { gvrenderSetStyle } from './gvrender-set-style.js';
@@ -110,13 +110,34 @@ function setGradientFill(obj: ObjState, color: XdotColor): void {
110
110
  }
111
111
  }
112
112
 
113
- /** @see lib/gvc/gvrender.c:480 gvrender_set_style */
113
+ /**
114
+ * The pen each pen token sets. `filled` and `unfilled` are absent: they write
115
+ * C's `obj->fill`, which emit_xdot does not read (it passes a local `filled`).
116
+ * The port's `obj.fill` stands in for that local, so they must not write it.
117
+ * @see lib/gvc/gvrender.c:480 gvrender_set_style
118
+ */
119
+ const PEN_OF_STYLE: ReadonlyMap<string, PenType> = new Map([
120
+ ['solid', PenType.Solid],
121
+ ['dashed', PenType.Dashed],
122
+ ['dotted', PenType.Dotted],
123
+ ['invis', PenType.None],
124
+ ['invisible', PenType.None],
125
+ ]);
126
+
127
+ /**
128
+ * Tokens apply in order, and each changes only the field it names: `bold` leaves
129
+ * a dashed pen dashed, and `dashed` leaves the width.
130
+ * @see lib/gvc/gvrender.c:480 gvrender_set_style
131
+ */
114
132
  function setStyle(obj: ObjState, tokens: readonly string[]): void {
115
133
  gvrenderSetStyle(tokens);
116
134
  obj.rawStyle = [...tokens];
117
- const flags = parseStyleFlags(tokens.join(','));
118
- obj.pen = resolvePenType(flags);
119
- obj.penWidth = resolvePenWidth(flags, undefined);
135
+ for (const token of tokens) {
136
+ const pen = PEN_OF_STYLE.get(styleName(token));
137
+ if (pen !== undefined) obj.pen = pen;
138
+ const flags = parseStyleFlags(token);
139
+ if (flags.bold || flags.setLineWidth !== null) obj.penWidth = resolvePenWidth(flags, undefined);
140
+ }
120
141
  }
121
142
 
122
143
  /** What a drawing op passes to the renderer, in device coordinates. */
@@ -196,12 +217,21 @@ export function emitXdot(g: Graph, renderer: RendererPlugin, job: RenderJob): vo
196
217
  for (const op of xd.ops) {
197
218
  styled ||= op.kind === 'style';
198
219
  if (op.kind === 'text') continue;
199
- if (!inClip && isDrawing(op)) continue;
220
+ if (isDrawing(op) && !drawsNow(obj, inClip)) continue;
200
221
  if (!drawOp(op, renderer, job)) stateOp(op, obj, warned);
201
222
  }
202
223
  if (styled) setStyle(obj, DEFAULT_LINE_STYLE);
203
224
  }
204
225
 
226
+ /**
227
+ * A drawing op's clip test, and gvrender's own: its ellipse, polygon, beziercurve
228
+ * and polyline all draw only if `pen != PEN_NONE`.
229
+ * @see lib/gvc/gvrender.c:524,543,583,600
230
+ */
231
+ function drawsNow(obj: ObjState, inClip: boolean): boolean {
232
+ return inClip && obj.pen !== PenType.None;
233
+ }
234
+
205
235
  function isDrawing(op: XdotOp): boolean {
206
236
  return op.kind.endsWith('ellipse') || op.kind.endsWith('polygon') || op.kind.endsWith('bezier')
207
237
  || op.kind === 'polyline';
@@ -22,6 +22,7 @@
22
22
  * @see lib/osage/osageinit.c:cleanup_graphs
23
23
  */
24
24
 
25
+ import { undoClusterEdges } from '../layout/fdp/cluster-edges.js';
25
26
  import { makeEdgeInfo, makePort } from '../model/edgeInfo.js';
26
27
  import { makeGraphInfo } from '../model/graphInfo.js';
27
28
  import type { Graph } from '../model/graph.js';
@@ -40,13 +41,31 @@ export function layoutWasFreed(g: Graph): boolean {
40
41
  return g.info?.laidOut === true && g.info.cleanup === undefined;
41
42
  }
42
43
 
44
+ /**
45
+ * attach_attrs ends by undoing the cluster edges, so -Tdot, -Txdot and -Tjson
46
+ * leave the graph with its original nodes, and -Tplain and -Tsvg leave the
47
+ * proxies as ordinary ones. The port's writers read the proxies as they print
48
+ * (`src/render/dot/agwrite.ts`), so the undo waits for the next layout, as the
49
+ * records do. Nothing sees the difference: a second attach_attrs on one layout
50
+ * crashes C. Only attach_attrs replaces `bb` with its comma-separated form
51
+ * (rec_attach_bb); `gvLayout`'s, which `writeLayoutBb` wrote, has spaces.
52
+ *
53
+ * @see lib/common/output.c:403 (if (HAS_CLUST_EDGE(g)) undoClusterEdges(g))
54
+ * @see lib/common/output.c:229 rec_attach_bb
55
+ */
56
+ export function undoRenderedClusterEdges(g: Graph): void {
57
+ if (g.info?.n_cluster_edges && g.attrs.get('bb')?.includes(',')) undoClusterEdges(g);
58
+ }
59
+
43
60
  /**
44
61
  * Replaces the record of `g` and of every subgraph under it.
45
62
  * @see lib/common/input.c:802 (agclean(g, AGRAPH, "Agraphinfo_t"))
46
63
  * @see lib/cgraph/rec.c:agclean (agapply over the subgraphs)
47
64
  */
48
65
  function resetGraphRecords(g: Graph): void {
66
+ const clusterEdges = g.info.n_cluster_edges;
49
67
  g.info = makeGraphInfo();
68
+ if (clusterEdges !== undefined) g.info.n_cluster_edges = clusterEdges;
50
69
  for (const subg of g.subgraphs.values()) resetGraphRecords(subg);
51
70
  }
52
71
 
@@ -56,15 +75,54 @@ function resetGraphRecords(g: Graph): void {
56
75
  * graph, including those declared in a subgraph (as agfstnode/agfstout do), and
57
76
  * the virtual nodes and edges of a layout are reachable only through the
58
77
  * records this drops. The parser and the builder stamp nothing on a record, and
59
- * `layout` sets `gvc` after this runs, so there is nothing to carry over.
78
+ * `layout` sets `gvc` after this runs. The one thing to carry over is the
79
+ * cluster-edge count, which C keeps in a record of its own (CL_EDGE_TAG) that no
80
+ * free deletes: a later layout still sees HAS_CLUST_EDGE and takes line segments.
60
81
  *
61
82
  * @see lib/common/utils.c:1522 (gv_cleanup_edge: agdelrec Agedgeinfo_t)
62
83
  * @see lib/common/utils.c:gv_cleanup_node (agdelrec Agnodeinfo_t)
63
84
  * @see lib/dotgen/dotinit.c:114 (dot_cleanup_node: agdelrec Agnodeinfo_t)
64
85
  * @see lib/common/input.c:graph_cleanup
86
+ * @see lib/common/utils.c:960 (agbindrec(g, CL_EDGE_TAG, ...))
87
+ * @see lib/fdpgen/layout.c:1049 (HAS_CLUST_EDGE)
65
88
  */
66
89
  export function resetLayoutRecords(g: Graph): void {
67
90
  for (const n of g.nodes.values()) n.info = makeNodeInfo();
68
91
  for (const e of g.edges) e.info = makeEdgeInfo(makePort(), makePort());
69
92
  resetGraphRecords(g);
70
93
  }
94
+
95
+ /**
96
+ * Runs the reset of every graph in `g`'s tree whose layout was freed. C frees a
97
+ * graph's records when that graph is freed, whichever graph is laid out next: a
98
+ * subgraph after its root, or a root after its subgraph.
99
+ *
100
+ * @see lib/gvc/gvlayout.c:61-64 (gvLayoutJobs binds the root's record too)
101
+ * @see lib/gvc/gvlayout.c:gvFreeLayout
102
+ */
103
+ export function resetFreedLayouts(g: Graph): void {
104
+ const visit = (h: Graph): void => {
105
+ if (layoutWasFreed(h)) resetLayoutRecords(h);
106
+ else for (const subg of h.subgraphs.values()) visit(subg);
107
+ };
108
+ visit(g.root);
109
+ }
110
+
111
+ /**
112
+ * C has one GD_dotroot, on the root, and dot_init_subg points it at the graph
113
+ * being laid out. The port reads each graph's own slot (`dotRoot`, and
114
+ * pack-components.ts for the same reason), so a subgraph points itself and all
115
+ * under it. A root layout clears what an earlier one left, which reads as the
116
+ * root again; on a first layout there is nothing to clear.
117
+ *
118
+ * @see lib/dotgen/dotinit.c:36 (GD_dotroot(agroot(g)) = droot)
119
+ * @see lib/dotgen/dotinit.c:520 dot_root
120
+ */
121
+ export function bindDotRoot(g: Graph): void {
122
+ const droot = g === g.root ? undefined : g;
123
+ const visit = (h: Graph): void => {
124
+ h.info.dotroot = droot;
125
+ for (const subg of h.subgraphs.values()) visit(subg);
126
+ };
127
+ visit(g);
128
+ }
package/src/index.ts CHANGED
@@ -143,6 +143,10 @@ export type {
143
143
  GvExpectation,
144
144
  RenderResult,
145
145
  } from './errors.js';
146
+ // Engine messages (graphviz's stderr): a caller-set function receives them
147
+ // in place of the console, as cgraph's agseterrf. @see lib/cgraph/agerror.c
148
+ export { agseterrf } from './common/agerr.js';
149
+ export type { AgUserErrF } from './common/agerr.js';
146
150
  export { setImageSizer } from './gvc/usershape.js';
147
151
  export type { ImageSizer } from './common/htmltable-types.js';
148
152
  export { setImageResolver } from './gvc/image-resolver.js';
@@ -88,7 +88,9 @@ export function buildDerivedEdges(g: Graph, dg: DerivedGraph): DerivedEdge[] {
88
88
 
89
89
  /** Decompose derived graph into connected components with their edges. */
90
90
  export function derivedComponents(g: Graph, dg: DerivedGraph, allEdges: DerivedEdge[]): SubGraph[] {
91
- const comps = ccomps(g);
91
+ // C decomposes the derived graph, which holds no user subgraph to reuse.
92
+ // @see lib/circogen/circularinit.c:circomps
93
+ const comps = ccomps(g, null, false);
92
94
  return comps.map((sg, i) => {
93
95
  const nodes: DerivedNode[] = [];
94
96
  for (const n of sg.nodes.values()) {
@@ -13,7 +13,7 @@
13
13
 
14
14
  import type { Graph } from '../../model/graph.js';
15
15
  import type { Edge as GraphEdge } from '../../model/edge.js';
16
- import type { Point, Box } from '../../model/geom.js';
16
+ import type { Point, Box, Port } from '../../model/geom.js';
17
17
  import type { Node } from '../../model/node.js';
18
18
  import { VIRTUAL, NORMAL } from './fastgr.js';
19
19
  import type { NodeBox } from './edge-route-geom.js';
@@ -229,6 +229,77 @@ function routeChainSegmented(
229
229
  return finishChain(w, endEdge, segs[ei], segFirst, segs) ? w.pts : null;
230
230
  }
231
231
 
232
+ // ---------------------------------------------------------------------------
233
+ // Hackflag views for an edge routed on another edge's chain
234
+ // @see lib/dotgen/dotsplines.c:make_regular_edge (abs(rank diff) > 1)
235
+ // ---------------------------------------------------------------------------
236
+
237
+ /** A port copied by value, as C's struct assignment copies `port`. */
238
+ function copyPort(p: Port): Port {
239
+ return { ...p, p: { ...p.p } };
240
+ }
241
+
242
+ /**
243
+ * C's `fwdedgea`: a copy of `e` from its rank-low end to the first vnode of the
244
+ * chain, head port undefined at (0,0), VIRTUAL with `to_orig = e`. beginpath's
245
+ * side-port clip reset therefore lands on `e` itself.
246
+ */
247
+ function hackflagBeginView(e: GraphEdge, back: boolean, firstVnode: Node): GraphEdge {
248
+ const tailPort = back ? e.info.head_port : e.info.tail_port;
249
+ return {
250
+ ...e,
251
+ tail: back ? e.head : e.tail,
252
+ head: firstVnode,
253
+ info: {
254
+ ...e.info,
255
+ tail_port: copyPort(tailPort),
256
+ head_port: { ...copyPort(e.info.head_port), defined: false, p: { x: 0, y: 0 } },
257
+ edge_type: VIRTUAL,
258
+ to_orig: e,
259
+ },
260
+ } as GraphEdge;
261
+ }
262
+
263
+ /**
264
+ * C's `fwdedgeb`: for a back edge, `makefwdedge(e)` (VIRTUAL, `to_orig = e`);
265
+ * otherwise a plain struct copy of `e` that stays NORMAL, so endpath's
266
+ * side-port clip reset lands on the copy and `e` keeps its head clip.
267
+ */
268
+ function hackflagEndView(e: GraphEdge, back: boolean): GraphEdge {
269
+ if (back) return makeFwdEdge(e);
270
+ return {
271
+ ...e,
272
+ info: { ...e.info, tail_port: copyPort(e.info.tail_port), head_port: copyPort(e.info.head_port) },
273
+ } as GraphEdge;
274
+ }
275
+
276
+ /**
277
+ * The edges that drive the chain's first beginpath and last endpath. A chain
278
+ * owned by `e` itself is C's ordinary walk from the first to the last fast
279
+ * edge. A chain owned by another edge means class2 merged `e` into it
280
+ * (`merge_chain`), so `e` sits in ND_other and C's group loop hands the real
281
+ * edge to make_regular_edge, which takes the hackflag branch: beginpath on
282
+ * `fwdedgea`, endpath on `fwdedgeb`. Driving those calls with the owner's
283
+ * segments reset the owner's clip flags instead of `e`'s (plantuml-ts 41).
284
+ * @see lib/dotgen/dotsplines.c:make_regular_edge (hackflag)
285
+ * @see lib/dotgen/class2.c:class2 (merge_chain, other_edge)
286
+ */
287
+ function chainEnds(e: GraphEdge, segs: GraphEdge[]): [GraphEdge, GraphEdge] {
288
+ const first = segs[0];
289
+ const last = segs[segs.length - 1];
290
+ const orig = resolveOrigEdge(e);
291
+ if (resolveOrigEdge(first) === orig) return [first, last];
292
+ const back = (orig.head.info.rank ?? 0) < (orig.tail.info.rank ?? 0);
293
+ return [hackflagBeginView(orig, back, first.head), hackflagEndView(orig, back)];
294
+ }
295
+
296
+ /** True when `e` runs forward across two or more ranks of a ranked graph. */
297
+ function spansRanksForward(g: Graph, e: GraphEdge): boolean {
298
+ const r = e.tail.info.rank;
299
+ const rh = e.head.info.rank;
300
+ return g.info.rank !== undefined && r !== undefined && rh !== undefined && rh > r + 1;
301
+ }
302
+
232
303
  /**
233
304
  * Route a forward edge spanning ≥2 ranks via its virtual-node chain through the
234
305
  * faithful pipeline (REGULAREDGE side boxes steer the port, routeSplines over
@@ -240,9 +311,7 @@ function routeChainSegmented(
240
311
  * @see lib/dotgen/dotsplines.c:make_regular_edge (hackflag forward path)
241
312
  */
242
313
  export function routeMultiRankEdgeFaithful(g: Graph, e: GraphEdge): Point[] | null | 'lost' {
243
- const r = e.tail.info.rank;
244
- const rh = e.head.info.rank;
245
- if (g.info.rank === undefined || r === undefined || rh === undefined || rh <= r + 1) return null;
314
+ if (!spansRanksForward(g, e)) return null;
246
315
  const et = edgeType(g);
247
316
  // EDGETYPE_LINE: C tries makeLineEdge first (direct tail→head segment),
248
317
  // falling back to the box corridor only when it declines (delr==1, or delr==2
@@ -261,8 +330,10 @@ export function routeMultiRankEdgeFaithful(g: Graph, e: GraphEdge): Point[] | nu
261
330
  // endpath with the LAST (each carries the orig's copied port, so a dyna
262
331
  // record port resolves toward the adjacent-rank vnode, not the far real
263
332
  // endpoint). @see lib/dotgen/dotsplines.c:make_regular_edge (tn/hn walk),
264
- // lib/dotgen/fastgr.c:new_virtual_edge (port copies)
265
- return routeChainSegmented(g, segs[0], segs[segs.length - 1], segs) ?? 'lost';
333
+ // lib/dotgen/fastgr.c:new_virtual_edge (port copies). An edge merged into
334
+ // another's chain takes the hackflag views instead (chainEnds).
335
+ const [beginEdge, endEdge] = chainEnds(e, segs);
336
+ return routeChainSegmented(g, beginEdge, endEdge, segs) ?? 'lost';
266
337
  }
267
338
 
268
339
  /**
@@ -415,7 +486,8 @@ export function routeBackEdge(e: GraphEdge, _tailBox: NodeBox, _headBox: NodeBox
415
486
  // (fastgr new_virtual_edge copy rules); fwdEdge remains the clip target so
416
487
  // bezier_clip keeps the load-bearing forward direction (1644).
417
488
  // @see lib/dotgen/dotsplines.c:make_regular_edge (segfirst/tn/hn walk)
418
- const fwd = routeChainSegmented(g, segs[0], segs[segs.length - 1], segs);
489
+ const [beginEdge, endEdge] = chainEnds(e, segs);
490
+ const fwd = routeChainSegmented(g, beginEdge, endEdge, segs);
419
491
  // Chain routing failed: C's make_regular_edge returns with no spline and
420
492
  // dot_splines_ never revisits the edge — mark it consumed so the backstop
421
493
  // sweep does not re-route (and re-report) it.