@knowvah/dot-engine 2.10.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 (392) hide show
  1. package/dist/gvc/context.d.ts +7 -1
  2. package/dist/gvc/context.d.ts.map +1 -1
  3. package/dist/gvc/device.d.ts +2 -3
  4. package/dist/gvc/device.d.ts.map +1 -1
  5. package/dist/gvc/emit-xdot.d.ts +11 -0
  6. package/dist/gvc/emit-xdot.d.ts.map +1 -0
  7. package/dist/gvc/init-xdot.d.ts +7 -0
  8. package/dist/gvc/init-xdot.d.ts.map +1 -0
  9. package/dist/gvc/landscape.d.ts +11 -0
  10. package/dist/gvc/landscape.d.ts.map +1 -0
  11. package/dist/gvc/layout-bb.d.ts +17 -0
  12. package/dist/gvc/layout-bb.d.ts.map +1 -0
  13. package/dist/gvc/layout-reset.d.ts +26 -0
  14. package/dist/gvc/layout-reset.d.ts.map +1 -0
  15. package/dist/gvc/usershape.d.ts +0 -2
  16. package/dist/gvc/usershape.d.ts.map +1 -1
  17. package/dist/gvc/viewport.d.ts +1 -10
  18. package/dist/gvc/viewport.d.ts.map +1 -1
  19. package/dist/index.js +1514 -768
  20. package/dist/index.js.map +4 -4
  21. package/dist/layout/circo/blocks.d.ts +2 -0
  22. package/dist/layout/circo/blocks.d.ts.map +1 -1
  23. package/dist/layout/circo/blocktree.d.ts +6 -0
  24. package/dist/layout/circo/blocktree.d.ts.map +1 -1
  25. package/dist/layout/circo/circular.d.ts +6 -0
  26. package/dist/layout/circo/circular.d.ts.map +1 -1
  27. package/dist/layout/dot/edge-route-rank.d.ts +34 -0
  28. package/dist/layout/dot/edge-route-rank.d.ts.map +1 -1
  29. package/dist/layout/dot/index.d.ts.map +1 -1
  30. package/dist/layout/dot/init.d.ts.map +1 -1
  31. package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
  32. package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
  33. package/dist/layout/dot/splines-flat.d.ts +1 -2
  34. package/dist/layout/dot/splines-flat.d.ts.map +1 -1
  35. package/dist/layout/dot/splines.d.ts +2 -2
  36. package/dist/layout/dot/splines.d.ts.map +1 -1
  37. package/dist/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.d.ts +12 -0
  38. package/dist/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.d.ts.map +1 -0
  39. package/dist/layout/neato/dijkstra.d.ts +7 -0
  40. package/dist/layout/neato/dijkstra.d.ts.map +1 -1
  41. package/dist/layout/neato/splines.d.ts +7 -3
  42. package/dist/layout/neato/splines.d.ts.map +1 -1
  43. package/dist/layout/pack/ccomps.d.ts +32 -0
  44. package/dist/layout/pack/ccomps.d.ts.map +1 -0
  45. package/dist/layout/pack/index.d.ts +1 -24
  46. package/dist/layout/pack/index.d.ts.map +1 -1
  47. package/dist/layout/sfdp/init.d.ts.map +1 -1
  48. package/dist/render/dot/write-back.d.ts +37 -0
  49. package/dist/render/dot/write-back.d.ts.map +1 -0
  50. package/dist/render/dot.d.ts +5 -7
  51. package/dist/render/dot.d.ts.map +1 -1
  52. package/dist/render/json.d.ts +16 -21
  53. package/dist/render/json.d.ts.map +1 -1
  54. package/dist/render.js +1757 -1011
  55. package/dist/render.js.map +4 -4
  56. package/dist/util/libcxx-sort.d.ts +7 -0
  57. package/dist/util/libcxx-sort.d.ts.map +1 -0
  58. package/dist/vpsc/SweepLine.d.ts +2 -2
  59. package/dist/vpsc/SweepLine.d.ts.map +1 -1
  60. package/package.json +1 -1
  61. package/src/gvc/__fixtures__/replay-native.json +422 -0
  62. package/src/gvc/__fixtures__/rerender/background.dot.seq-xdot-svg.1 +25 -0
  63. package/src/gvc/__fixtures__/rerender/background.dot.seq-xdot-svg.2 +37 -0
  64. package/src/gvc/__fixtures__/rerender/background.gv +1 -0
  65. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.plain.1 +5 -0
  66. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.plain.2 +5 -0
  67. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.xdot.1 +25 -0
  68. package/src/gvc/__fixtures__/rerender/cluster-lrvn.dot.xdot.2 +25 -0
  69. package/src/gvc/__fixtures__/rerender/cluster-lrvn.gv +1 -0
  70. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.plain.1 +7 -0
  71. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.plain.2 +7 -0
  72. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-dot-dot.1 +18 -0
  73. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-dot-dot.2 +18 -0
  74. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-plain-xdot.1 +7 -0
  75. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-plain-xdot.2 +33 -0
  76. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-dot.1 +33 -0
  77. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-dot.2 +33 -0
  78. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-plain.1 +33 -0
  79. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-plain.2 +7 -0
  80. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-svg.1 +33 -0
  81. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-svg.2 +46 -0
  82. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-then-svg.1 +33 -0
  83. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-then-svg.2 +47 -0
  84. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-xdot.1 +33 -0
  85. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.seq-xdot-xdot.2 +33 -0
  86. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.xdot.1 +33 -0
  87. package/src/gvc/__fixtures__/rerender/cluster-skeleton.dot.xdot.2 +33 -0
  88. package/src/gvc/__fixtures__/rerender/cluster-skeleton.gv +1 -0
  89. package/src/gvc/__fixtures__/rerender/filing.circo.plain.1 +5 -0
  90. package/src/gvc/__fixtures__/rerender/filing.circo.plain.2 +5 -0
  91. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.1 +5 -0
  92. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.2 +5 -0
  93. package/src/gvc/__fixtures__/rerender/filing.circo.plain.nofree.3 +5 -0
  94. package/src/gvc/__fixtures__/rerender/filing.circo.xdot.1 +20 -0
  95. package/src/gvc/__fixtures__/rerender/filing.circo.xdot.2 +20 -0
  96. package/src/gvc/__fixtures__/rerender/filing.dot.plain.1 +5 -0
  97. package/src/gvc/__fixtures__/rerender/filing.dot.plain.2 +5 -0
  98. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.1 +5 -0
  99. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.2 +5 -0
  100. package/src/gvc/__fixtures__/rerender/filing.dot.plain.nofree.3 +5 -0
  101. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-circo.2 +5 -0
  102. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-fdp.2 +5 -0
  103. package/src/gvc/__fixtures__/rerender/filing.dot.plain.then-neato.2 +5 -0
  104. package/src/gvc/__fixtures__/rerender/filing.dot.seq-dot-dot.1 +11 -0
  105. package/src/gvc/__fixtures__/rerender/filing.dot.seq-dot-dot.2 +11 -0
  106. package/src/gvc/__fixtures__/rerender/filing.dot.seq-json-json.1 +148 -0
  107. package/src/gvc/__fixtures__/rerender/filing.dot.seq-json-json.2 +162 -0
  108. package/src/gvc/__fixtures__/rerender/filing.dot.seq-plain-xdot.1 +5 -0
  109. package/src/gvc/__fixtures__/rerender/filing.dot.seq-plain-xdot.2 +20 -0
  110. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-dot.1 +20 -0
  111. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-dot.2 +20 -0
  112. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-plain.1 +20 -0
  113. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-plain.2 +5 -0
  114. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-svg.1 +20 -0
  115. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-svg.2 +30 -0
  116. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-then-svg.1 +20 -0
  117. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-then-svg.2 +31 -0
  118. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-xdot.1 +20 -0
  119. package/src/gvc/__fixtures__/rerender/filing.dot.seq-xdot-xdot.2 +20 -0
  120. package/src/gvc/__fixtures__/rerender/filing.dot.xdot.1 +20 -0
  121. package/src/gvc/__fixtures__/rerender/filing.dot.xdot.2 +20 -0
  122. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.1 +5 -0
  123. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.2 +5 -0
  124. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.1 +5 -0
  125. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.2 +5 -0
  126. package/src/gvc/__fixtures__/rerender/filing.fdp.plain.nofree.3 +5 -0
  127. package/src/gvc/__fixtures__/rerender/filing.fdp.xdot.1 +20 -0
  128. package/src/gvc/__fixtures__/rerender/filing.fdp.xdot.2 +21 -0
  129. package/src/gvc/__fixtures__/rerender/filing.gv +1 -0
  130. package/src/gvc/__fixtures__/rerender/filing.neato.plain.1 +5 -0
  131. package/src/gvc/__fixtures__/rerender/filing.neato.plain.2 +5 -0
  132. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.1 +5 -0
  133. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.2 +5 -0
  134. package/src/gvc/__fixtures__/rerender/filing.neato.plain.nofree.3 +5 -0
  135. package/src/gvc/__fixtures__/rerender/filing.neato.seq-xdot-then-svg.1 +20 -0
  136. package/src/gvc/__fixtures__/rerender/filing.neato.seq-xdot-then-svg.2 +31 -0
  137. package/src/gvc/__fixtures__/rerender/filing.neato.xdot.1 +20 -0
  138. package/src/gvc/__fixtures__/rerender/filing.neato.xdot.2 +21 -0
  139. package/src/gvc/__fixtures__/rerender/filing.osage.plain.1 +5 -0
  140. package/src/gvc/__fixtures__/rerender/filing.osage.plain.2 +5 -0
  141. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.1 +5 -0
  142. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.2 +5 -0
  143. package/src/gvc/__fixtures__/rerender/filing.osage.plain.nofree.3 +5 -0
  144. package/src/gvc/__fixtures__/rerender/filing.osage.xdot.1 +20 -0
  145. package/src/gvc/__fixtures__/rerender/filing.osage.xdot.2 +20 -0
  146. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.1 +5 -0
  147. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.2 +5 -0
  148. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.1 +5 -0
  149. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.2 +5 -0
  150. package/src/gvc/__fixtures__/rerender/filing.patchwork.plain.nofree.3 +5 -0
  151. package/src/gvc/__fixtures__/rerender/filing.patchwork.xdot.1 +20 -0
  152. package/src/gvc/__fixtures__/rerender/filing.patchwork.xdot.2 +20 -0
  153. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.1 +5 -0
  154. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.2 +5 -0
  155. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.1 +5 -0
  156. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.2 +5 -0
  157. package/src/gvc/__fixtures__/rerender/filing.sfdp.plain.nofree.3 +5 -0
  158. package/src/gvc/__fixtures__/rerender/filing.sfdp.xdot.1 +20 -0
  159. package/src/gvc/__fixtures__/rerender/filing.sfdp.xdot.2 +20 -0
  160. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.1 +5 -0
  161. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.2 +5 -0
  162. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.1 +5 -0
  163. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.2 +5 -0
  164. package/src/gvc/__fixtures__/rerender/filing.twopi.plain.nofree.3 +5 -0
  165. package/src/gvc/__fixtures__/rerender/filing.twopi.xdot.1 +20 -0
  166. package/src/gvc/__fixtures__/rerender/filing.twopi.xdot.2 +20 -0
  167. package/src/gvc/__fixtures__/rerender/mixed.circo.plain.1 +18 -0
  168. package/src/gvc/__fixtures__/rerender/mixed.circo.plain.2 +18 -0
  169. package/src/gvc/__fixtures__/rerender/mixed.circo.xdot.1 +103 -0
  170. package/src/gvc/__fixtures__/rerender/mixed.circo.xdot.2 +104 -0
  171. package/src/gvc/__fixtures__/rerender/mixed.dot.plain.1 +18 -0
  172. package/src/gvc/__fixtures__/rerender/mixed.dot.plain.2 +18 -0
  173. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-dot-dot.1 +75 -0
  174. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-dot-dot.2 +75 -0
  175. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-plain-xdot.1 +18 -0
  176. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-plain-xdot.2 +119 -0
  177. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-dot.1 +119 -0
  178. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-dot.2 +119 -0
  179. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-plain.1 +119 -0
  180. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-plain.2 +18 -0
  181. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-svg.1 +119 -0
  182. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-svg.2 +127 -0
  183. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-then-svg.1 +119 -0
  184. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-then-svg.2 +128 -0
  185. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-xdot.1 +119 -0
  186. package/src/gvc/__fixtures__/rerender/mixed.dot.seq-xdot-xdot.2 +119 -0
  187. package/src/gvc/__fixtures__/rerender/mixed.dot.xdot.1 +119 -0
  188. package/src/gvc/__fixtures__/rerender/mixed.dot.xdot.2 +119 -0
  189. package/src/gvc/__fixtures__/rerender/mixed.fdp.plain.1 +18 -0
  190. package/src/gvc/__fixtures__/rerender/mixed.fdp.xdot.1 +117 -0
  191. package/src/gvc/__fixtures__/rerender/mixed.gv +8 -0
  192. package/src/gvc/__fixtures__/rerender/mixed.neato.plain.1 +18 -0
  193. package/src/gvc/__fixtures__/rerender/mixed.neato.plain.2 +18 -0
  194. package/src/gvc/__fixtures__/rerender/mixed.neato.xdot.1 +117 -0
  195. package/src/gvc/__fixtures__/rerender/mixed.neato.xdot.2 +118 -0
  196. package/src/gvc/__fixtures__/rerender/mixed.osage.plain.1 +18 -0
  197. package/src/gvc/__fixtures__/rerender/mixed.osage.plain.2 +18 -0
  198. package/src/gvc/__fixtures__/rerender/mixed.osage.xdot.1 +117 -0
  199. package/src/gvc/__fixtures__/rerender/mixed.osage.xdot.2 +117 -0
  200. package/src/gvc/__fixtures__/rerender/mixed.patchwork.plain.1 +18 -0
  201. package/src/gvc/__fixtures__/rerender/mixed.patchwork.plain.2 +18 -0
  202. package/src/gvc/__fixtures__/rerender/mixed.patchwork.xdot.1 +78 -0
  203. package/src/gvc/__fixtures__/rerender/mixed.patchwork.xdot.2 +79 -0
  204. package/src/gvc/__fixtures__/rerender/mixed.sfdp.plain.1 +18 -0
  205. package/src/gvc/__fixtures__/rerender/mixed.sfdp.xdot.1 +103 -0
  206. package/src/gvc/__fixtures__/rerender/mixed.twopi.plain.1 +18 -0
  207. package/src/gvc/__fixtures__/rerender/mixed.twopi.plain.2 +18 -0
  208. package/src/gvc/__fixtures__/rerender/mixed.twopi.xdot.1 +103 -0
  209. package/src/gvc/__fixtures__/rerender/mixed.twopi.xdot.2 +103 -0
  210. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +29 -0
  211. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +29 -0
  212. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +29 -0
  213. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.1 +29 -0
  214. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.2 +29 -0
  215. package/src/gvc/__fixtures__/rerender/multi-edge.fdp.plain.nofree.3 +29 -0
  216. package/src/gvc/__fixtures__/rerender/multi-edge.gv +16 -0
  217. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.1 +29 -0
  218. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.2 +29 -0
  219. package/src/gvc/__fixtures__/rerender/multi-edge.patchwork.plain.nofree.3 +29 -0
  220. package/src/gvc/__fixtures__/rerender/neato-pos.gv +1 -0
  221. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-dot-plain.1 +34 -0
  222. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-dot-plain.2 +18 -0
  223. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json-plain.1 +471 -0
  224. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json-plain.2 +18 -0
  225. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json0-plain.1 +121 -0
  226. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-json0-plain.2 +18 -0
  227. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-xdot-plain.1 +60 -0
  228. package/src/gvc/__fixtures__/rerender/neato-pos.neato.seq-xdot-plain.2 +18 -0
  229. package/src/gvc/__fixtures__/rerender/regen.sh +81 -0
  230. package/src/gvc/__fixtures__/rerender/sized-clip.gv +18 -0
  231. package/src/gvc/__fixtures__/rerender/sized-clip.neato.xdot.1 +86 -0
  232. package/src/gvc/__fixtures__/rerender/sized-clip.neato.xdot.2 +86 -0
  233. package/src/gvc/context.ts +13 -1
  234. package/src/gvc/device.ts +6 -6
  235. package/src/gvc/emit-xdot.ts +208 -0
  236. package/src/gvc/init-xdot.ts +36 -0
  237. package/src/gvc/landscape.ts +36 -0
  238. package/src/gvc/layout-bb.ts +43 -0
  239. package/src/gvc/layout-reset.ts +62 -0
  240. package/src/gvc/usershape.ts +0 -5
  241. package/src/gvc/viewport.ts +1 -32
  242. package/src/layout/circo/__fixtures__/root/both-connected.gv +11 -0
  243. package/src/layout/circo/__fixtures__/root/both-connected.xdot +53 -0
  244. package/src/layout/circo/__fixtures__/root/both-connected.xdot.stderr +0 -0
  245. package/src/layout/circo/__fixtures__/root/both-per-component.gv +18 -0
  246. package/src/layout/circo/__fixtures__/root/both-per-component.xdot +97 -0
  247. package/src/layout/circo/__fixtures__/root/both-per-component.xdot.stderr +0 -0
  248. package/src/layout/circo/__fixtures__/root/graph-none-node.gv +11 -0
  249. package/src/layout/circo/__fixtures__/root/graph-none-node.xdot +53 -0
  250. package/src/layout/circo/__fixtures__/root/graph-none-node.xdot.stderr +0 -0
  251. package/src/layout/circo/__fixtures__/root/graph-root-first.gv +17 -0
  252. package/src/layout/circo/__fixtures__/root/graph-root-first.xdot +96 -0
  253. package/src/layout/circo/__fixtures__/root/graph-root-first.xdot.stderr +0 -0
  254. package/src/layout/circo/__fixtures__/root/graph-root-later.gv +17 -0
  255. package/src/layout/circo/__fixtures__/root/graph-root-later.xdot +96 -0
  256. package/src/layout/circo/__fixtures__/root/graph-root-later.xdot.stderr +0 -0
  257. package/src/layout/circo/__fixtures__/root/graph-root-none.gv +17 -0
  258. package/src/layout/circo/__fixtures__/root/graph-root-none.xdot +96 -0
  259. package/src/layout/circo/__fixtures__/root/graph-root-none.xdot.stderr +0 -0
  260. package/src/layout/circo/__fixtures__/root/graph-root-paths.gv +7 -0
  261. package/src/layout/circo/__fixtures__/root/graph-root-paths.xdot +46 -0
  262. package/src/layout/circo/__fixtures__/root/graph-root-paths.xdot.stderr +0 -0
  263. package/src/layout/circo/__fixtures__/root/no-root-connected.gv +9 -0
  264. package/src/layout/circo/__fixtures__/root/no-root-connected.xdot +51 -0
  265. package/src/layout/circo/__fixtures__/root/no-root-connected.xdot.stderr +0 -0
  266. package/src/layout/circo/__fixtures__/root/no-root.gv +16 -0
  267. package/src/layout/circo/__fixtures__/root/no-root.xdot +95 -0
  268. package/src/layout/circo/__fixtures__/root/no-root.xdot.stderr +0 -0
  269. package/src/layout/circo/__fixtures__/root/node-root-connected.gv +10 -0
  270. package/src/layout/circo/__fixtures__/root/node-root-connected.xdot +52 -0
  271. package/src/layout/circo/__fixtures__/root/node-root-connected.xdot.stderr +0 -0
  272. package/src/layout/circo/__fixtures__/root/node-root-false.gv +10 -0
  273. package/src/layout/circo/__fixtures__/root/node-root-false.xdot +52 -0
  274. package/src/layout/circo/__fixtures__/root/node-root-false.xdot.stderr +0 -0
  275. package/src/layout/circo/__fixtures__/root/node-root-later.gv +17 -0
  276. package/src/layout/circo/__fixtures__/root/node-root-later.xdot +96 -0
  277. package/src/layout/circo/__fixtures__/root/node-root-later.xdot.stderr +0 -0
  278. package/src/layout/circo/__fixtures__/root/node-root-two.gv +11 -0
  279. package/src/layout/circo/__fixtures__/root/node-root-two.xdot +53 -0
  280. package/src/layout/circo/__fixtures__/root/node-root-two.xdot.stderr +0 -0
  281. package/src/layout/circo/__fixtures__/root/regen.sh +16 -0
  282. package/src/layout/circo/blocks.ts +3 -0
  283. package/src/layout/circo/blocktree.ts +17 -3
  284. package/src/layout/circo/circular.ts +13 -1
  285. package/src/layout/dot/edge-route-rank.ts +72 -0
  286. package/src/layout/dot/edge-route.ts +6 -6
  287. package/src/layout/dot/index.ts +2 -0
  288. package/src/layout/dot/init.ts +17 -5
  289. package/src/layout/dot/splines-flat-labeled.ts +2 -1
  290. package/src/layout/dot/splines-flat-multi.ts +2 -1
  291. package/src/layout/dot/splines-flat.ts +3 -3
  292. package/src/layout/dot/splines.ts +9 -9
  293. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.gv +17 -0
  294. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.xdot +115 -0
  295. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-default.xdot.stderr +0 -0
  296. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.gv +18 -0
  297. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.xdot +116 -0
  298. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-epsilon.xdot.stderr +0 -0
  299. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.gv +18 -0
  300. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.xdot +116 -0
  301. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiter3.xdot.stderr +0 -0
  302. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.gv +18 -0
  303. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.xdot +116 -0
  304. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-maxiterneg.xdot.stderr +0 -0
  305. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.gv +18 -0
  306. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.xdot +116 -0
  307. package/src/layout/neato/__fixtures__/multi-component-attrs/hier-stresswt.xdot.stderr +0 -0
  308. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.gv +18 -0
  309. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.xdot +102 -0
  310. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-default.xdot.stderr +0 -0
  311. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.gv +19 -0
  312. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.xdot +103 -0
  313. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-epsilon.xdot.stderr +0 -0
  314. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.gv +19 -0
  315. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.xdot +103 -0
  316. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiter3.xdot.stderr +3 -0
  317. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.gv +19 -0
  318. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.xdot +103 -0
  319. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-maxiterneg.xdot.stderr +0 -0
  320. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.gv +19 -0
  321. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.xdot +103 -0
  322. package/src/layout/neato/__fixtures__/multi-component-attrs/kk-stresswt.xdot.stderr +0 -0
  323. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.gv +16 -0
  324. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.xdot +100 -0
  325. package/src/layout/neato/__fixtures__/multi-component-attrs/major-default.xdot.stderr +0 -0
  326. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.gv +17 -0
  327. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.xdot +101 -0
  328. package/src/layout/neato/__fixtures__/multi-component-attrs/major-epsilon.xdot.stderr +0 -0
  329. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.gv +18 -0
  330. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.xdot +106 -0
  331. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-cluster.xdot.stderr +0 -0
  332. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.gv +18 -0
  333. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.xdot +101 -0
  334. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3-pin.xdot.stderr +0 -0
  335. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.gv +17 -0
  336. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.xdot +101 -0
  337. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiter3.xdot.stderr +0 -0
  338. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.gv +17 -0
  339. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.xdot +101 -0
  340. package/src/layout/neato/__fixtures__/multi-component-attrs/major-maxiterneg.xdot.stderr +0 -0
  341. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.gv +17 -0
  342. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.xdot +101 -0
  343. package/src/layout/neato/__fixtures__/multi-component-attrs/major-stresswt.xdot.stderr +0 -0
  344. package/src/layout/neato/__fixtures__/multi-component-attrs/regen.sh +16 -0
  345. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.gv +17 -0
  346. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.xdot +101 -0
  347. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-default.xdot.stderr +0 -0
  348. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.gv +18 -0
  349. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.xdot +102 -0
  350. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-epsilon.xdot.stderr +0 -0
  351. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.gv +18 -0
  352. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.xdot +102 -0
  353. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiter3.xdot.stderr +0 -0
  354. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.gv +18 -0
  355. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.xdot +102 -0
  356. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-maxiterneg.xdot.stderr +0 -0
  357. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.gv +18 -0
  358. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.xdot +102 -0
  359. package/src/layout/neato/__fixtures__/multi-component-attrs/sgd-stresswt.xdot.stderr +0 -0
  360. package/src/layout/neato/__fixtures__/quad-prog-vpsc-dir1-n40.ts +14 -0
  361. package/src/layout/neato/dijkstra.ts +12 -3
  362. package/src/layout/neato/splines.ts +18 -18
  363. package/src/layout/pack/ccomps.ts +131 -0
  364. package/src/layout/pack/index.ts +1 -95
  365. package/src/layout/sfdp/__fixtures__/start-warning/regen.sh +16 -0
  366. package/src/layout/sfdp/__fixtures__/start-warning/start-5.gv +15 -0
  367. package/src/layout/sfdp/__fixtures__/start-warning/start-5.xdot +77 -0
  368. package/src/layout/sfdp/__fixtures__/start-warning/start-5.xdot.stderr +0 -0
  369. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.gv +15 -0
  370. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.xdot +77 -0
  371. package/src/layout/sfdp/__fixtures__/start-warning/start-random5.xdot.stderr +0 -0
  372. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.gv +15 -0
  373. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.xdot +77 -0
  374. package/src/layout/sfdp/__fixtures__/start-warning/start-regular.xdot.stderr +1 -0
  375. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.gv +16 -0
  376. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.xdot +78 -0
  377. package/src/layout/sfdp/__fixtures__/start-warning/start-self-label-scheme.xdot.stderr +2 -0
  378. package/src/layout/sfdp/__fixtures__/start-warning/start-self.gv +15 -0
  379. package/src/layout/sfdp/__fixtures__/start-warning/start-self.xdot +77 -0
  380. package/src/layout/sfdp/__fixtures__/start-warning/start-self.xdot.stderr +1 -0
  381. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.gv +14 -0
  382. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.xdot +76 -0
  383. package/src/layout/sfdp/__fixtures__/start-warning/start-unset.xdot.stderr +0 -0
  384. package/src/layout/sfdp/index.ts +1 -1
  385. package/src/layout/sfdp/init.ts +9 -1
  386. package/src/layout/twopi/index.ts +1 -1
  387. package/src/render/dot/agwrite.ts +1 -1
  388. package/src/render/dot/write-back.ts +137 -0
  389. package/src/render/dot.ts +12 -12
  390. package/src/render/json.ts +34 -34
  391. package/src/util/libcxx-sort.ts +461 -0
  392. package/src/vpsc/SweepLine.ts +11 -12
package/src/render/dot.ts CHANGED
@@ -25,6 +25,7 @@ import { edgeHasDrawableContent } from './svg.js';
25
25
  import type { Bezier } from '../model/geom.js';
26
26
  import type { RendererPlugin } from '../gvc/context.js';
27
27
  import { EdgeDrawBase } from './dot/edge-draw.js';
28
+ import { attachXdotAttrs, storedDraws } from './dot/write-back.js';
28
29
  export * from './dot/types.js';
29
30
  export type { XdotDraws, SerCtx } from './dot/types.js';
30
31
  import type { XdotDraws } from './dot/types.js';
@@ -78,10 +79,10 @@ export class XdotRenderer extends EdgeDrawBase implements RendererPlugin {
78
79
  */
79
80
  protected override readonly emitDraws: boolean = true;
80
81
 
81
- /** Draw strings for `obj`, or undefined in a format that emits none (`-Tdot`).
82
- * Single gate so the xdot path cannot drift from the dot path. */
82
+ /** Draw strings for `obj`. `-Tdot` computes none, and agwrite prints the ones the
83
+ * attribute slots already hold. Single gate so the two paths cannot drift. */
83
84
  protected drawsOf(obj: Node | Edge | Graph): XdotDraws | undefined {
84
- return this.emitDraws ? this.draws.get(obj) : undefined;
85
+ return this.emitDraws ? this.draws.get(obj) : storedDraws(obj.attrs);
85
86
  }
86
87
 
87
88
  /** Per-render draw buffers. Indices 8/9 alias 1; 10/11 alias 5. */
@@ -103,18 +104,14 @@ export class XdotRenderer extends EdgeDrawBase implements RendererPlugin {
103
104
  this.clusters = [];
104
105
  }
105
106
 
106
- /** The per-object draw strings accumulated during the last render, keyed by
107
- * the ORIGINAL model object. These are the pre-serialization values C's
108
- * `-Tjson` reads directly (via agxget) — feeding them to parseXDot avoids the
109
- * DOT-text round-trip, which cannot represent draw text containing `"` and so
110
- * drops a preceding backslash (a cluster label's `\"` → `"`, id 2239). */
107
+ /** The last render's draw strings by ORIGINAL object: what `-Tjson` reads via agxget.
108
+ * The DOT-text round-trip cannot represent draw text containing `"` (id 2239). */
111
109
  drawStringsByObject(): ReadonlyMap<Node | Edge | Graph, XdotDraws> {
112
110
  return this.draws;
113
111
  }
114
112
 
115
113
  endGraph(g: Graph, job: RenderJob): void {
116
- // Flush the graph-level GDRAW/GLABEL buffers (canvas background + graph
117
- // label) onto the root graph, then serialize the whole graph.
114
+ // Flush GDRAW/GLABEL (canvas background + graph label) onto the root, then serialize.
118
115
  // @see gvrender_core_dot.c:427 xdot_end_graph
119
116
  const gd = this.flush(EmitState.GDraw);
120
117
  const gl = this.flush(EmitState.GLabel);
@@ -124,6 +121,11 @@ export class XdotRenderer extends EdgeDrawBase implements RendererPlugin {
124
121
  if (gl) set.ldraw = escBackslash(gl);
125
122
  }
126
123
  job.write(this.serialize(g));
124
+ this.writeBack(g); // C writes before agwrite; the serializer overlaid the same values
125
+ }
126
+
127
+ protected writeBack(g: Graph): void {
128
+ attachXdotAttrs(g, this.emitDraws ? (o) => this.drawsOf(o) : undefined);
127
129
  }
128
130
 
129
131
  /** Emit the canvas background polygon into the GDRAW buffer.
@@ -461,8 +463,6 @@ export class XdotRenderer extends EdgeDrawBase implements RendererPlugin {
461
463
  return d;
462
464
  }
463
465
 
464
- // --- serialization (agwrite-at-end) ------------------------------------
465
-
466
466
  }
467
467
 
468
468
  // ---------------------------------------------------------------------------
@@ -42,6 +42,8 @@ import type { RenderJob } from '../gvc/job.js';
42
42
  import type { XdotOp, XdotColor } from '../xdot/types.js';
43
43
  import type { TextlabelT, FieldT } from '../common/types.js';
44
44
  import { printNum, gfmt5, XdotRenderer, type XdotDraws } from './dot.js';
45
+ import { attachAttrs } from './dot/write-back.js';
46
+ import { attrsWithoutLayoutBb } from '../gvc/layout-bb.js';
45
47
  import { CHAR_LATIN1 } from '../common/graph-init.js';
46
48
  import { parse } from '../parser/index.js';
47
49
  import { render as deviceRender } from '../gvc/device.js';
@@ -58,8 +60,7 @@ const XDOT_ATTR_NAMES: ReadonlySet<string> = new Set([
58
60
  '_draw_', '_ldraw_', '_hdraw_', '_tdraw_', '_hldraw_', '_tldraw_',
59
61
  ]);
60
62
 
61
- /** Built-in node label default installed by graphviz (`\N`). Emitted for every
62
- * node with no explicit/inherited label. @see lib/common/input.c NODENAME */
63
+ /** Graphviz's built-in node label default (`\N`). @see lib/common/input.c NODENAME */
63
64
  const DEFAULT_NODE_LABEL = '\\N';
64
65
 
65
66
  /** Loosely-typed JSON value tree, serialized with JSON.stringify. */
@@ -200,6 +201,14 @@ interface DrawLookup {
200
201
  cluster: Map<Graph, Map<string, string>>;
201
202
  /** Edge xdot/layout attrs by the original graph's Edge object. */
202
203
  edge: Map<Edge, Map<string, string>>;
204
+ /** The inner xdot render's write-back, due once the JSON has been written. */
205
+ attach: () => void;
206
+ }
207
+
208
+ /** C's inner gvRender writes back first; buildJson overlays the same values. */
209
+ class HeldXdotRenderer extends XdotRenderer {
210
+ protected override writeBack(): void { /* see attach */ }
211
+ attach(g: Graph): void { super.writeBack(g); }
203
212
  }
204
213
 
205
214
  /** Root edges in agfstnode/agfstout order, each tagged with its canonical
@@ -241,7 +250,7 @@ function collectDrawLookup(g: Graph): DrawLookup | undefined {
241
250
  let xg: Graph;
242
251
  // Our own XdotRenderer (last-registered wins) exposes raw draw strings: the
243
252
  // DOT re-parse is LOSSY for draw text containing `"` (id 2239); overlay them.
244
- const xr = new XdotRenderer();
253
+ const xr = new HeldXdotRenderer();
245
254
  try {
246
255
  const ctx = createDefaultContext();
247
256
  ctx.register(xr);
@@ -289,7 +298,7 @@ function collectDrawLookup(g: Graph): DrawLookup | undefined {
289
298
  for (const [nm, gn] of g.nodes) applyDraws(node.get(nm), draws.get(gn));
290
299
  for (const [gc, attrs] of cluster) applyDraws(attrs, draws.get(gc));
291
300
  for (const [ge, attrs] of edge) applyDraws(attrs, draws.get(ge));
292
- return { graph: graphAttrs, node, cluster, edge };
301
+ return { graph: graphAttrs, node, cluster, edge, attach: () => xr.attach(g) };
293
302
  }
294
303
 
295
304
  // ---------------------------------------------------------------------------
@@ -333,7 +342,7 @@ function isGraphLabelDeclared(g: Graph): boolean {
333
342
  * graph-attribute values (agxget inheritance), captured at build time in
334
343
  * `graphDefaultsSnapshot`; the root uses only its own. */
335
344
  function graphEffectiveAttrs(g: Graph, top: boolean): Map<string, string> {
336
- if (top) return g.attrs;
345
+ if (top) return attrsWithoutLayoutBb(g);
337
346
  const m = new Map<string, string>(g.graphDefaultsSnapshot ?? []);
338
347
  for (const [k, v] of g.attrs) m.set(k, v);
339
348
  return m;
@@ -653,6 +662,21 @@ export function buildJson(g: Graph, doXDot: boolean, preDraws?: DrawLookup): str
653
662
  return JSON.stringify(root, null, 2) + '\n';
654
663
  }
655
664
 
665
+ /** Everything the JSON writers leave to the graph walk: they write once, at the end. */
666
+ abstract class JsonRendererBase {
667
+ /** @see plugin/core/gvplugin_core.c registration table */
668
+ readonly quality = 0;
669
+ beginNode(_n: Node, _job: RenderJob): void { /* no-op */ }
670
+ endNode(_n: Node, _job: RenderJob): void { /* no-op */ }
671
+ beginEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
672
+ endEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
673
+ textspan(_pos: Point, _span: TextSpan, _job: RenderJob): void { /* no-op */ }
674
+ ellipse(_c: Point, _rx: number, _ry: number, _f: boolean, _j: RenderJob): void { /* no-op */ }
675
+ polygon(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
676
+ bezier(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
677
+ polyline(_pts: Point[], _job: RenderJob): void { /* no-op */ }
678
+ }
679
+
656
680
  // ---------------------------------------------------------------------------
657
681
  // Json0Renderer
658
682
  // ---------------------------------------------------------------------------
@@ -662,26 +686,13 @@ export function buildJson(g: Graph, doXDot: boolean, preDraws?: DrawLookup): str
662
686
  *
663
687
  * @see plugin/core/gvrender_core_json.c FORMAT_JSON0
664
688
  */
665
- export class Json0Renderer implements RendererPlugin {
689
+ export class Json0Renderer extends JsonRendererBase implements RendererPlugin {
666
690
  readonly type = 'json0';
667
- /** @see plugin/core/gvplugin_core.c registration table */
668
- readonly quality = 0;
669
691
 
670
692
  beginGraph(_g: Graph, _job: RenderJob): void { /* no-op */ }
671
693
 
672
- endGraph(g: Graph, job: RenderJob): void {
673
- job.write(buildJson(g, false));
674
- }
675
-
676
- beginNode(_n: Node, _job: RenderJob): void { /* no-op */ }
677
- endNode(_n: Node, _job: RenderJob): void { /* no-op */ }
678
- beginEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
679
- endEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
680
- textspan(_pos: Point, _span: TextSpan, _job: RenderJob): void { /* no-op */ }
681
- ellipse(_c: Point, _rx: number, _ry: number, _f: boolean, _j: RenderJob): void { /* no-op */ }
682
- polygon(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
683
- bezier(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
684
- polyline(_pts: Point[], _job: RenderJob): void { /* no-op */ }
694
+ /** C's json_begin_graph runs attach_attrs; buildJson overlays the same values. */
695
+ endGraph(g: Graph, job: RenderJob): void { job.write(buildJson(g, false)); attachAttrs(g); }
685
696
  }
686
697
 
687
698
  // ---------------------------------------------------------------------------
@@ -693,10 +704,8 @@ export class Json0Renderer implements RendererPlugin {
693
704
  *
694
705
  * @see plugin/core/gvrender_core_json.c FORMAT_JSON
695
706
  */
696
- export class JsonRenderer implements RendererPlugin {
707
+ export class JsonRenderer extends JsonRendererBase implements RendererPlugin {
697
708
  readonly type = 'json';
698
- /** @see plugin/core/gvplugin_core.c registration table */
699
- readonly quality = 0;
700
709
 
701
710
  private draws: DrawLookup | undefined; // set by beginGraph, cleared by endGraph
702
711
  /** @see plugin/core/gvrender_core_json.c:json_begin_graph */
@@ -704,18 +713,9 @@ export class JsonRenderer implements RendererPlugin {
704
713
 
705
714
  endGraph(g: Graph, job: RenderJob): void {
706
715
  job.write(buildJson(g, true, this.draws));
716
+ this.draws?.attach();
707
717
  this.draws = undefined;
708
718
  }
709
-
710
- beginNode(_n: Node, _job: RenderJob): void { /* no-op */ }
711
- endNode(_n: Node, _job: RenderJob): void { /* no-op */ }
712
- beginEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
713
- endEdge(_e: Edge, _job: RenderJob): void { /* no-op */ }
714
- textspan(_pos: Point, _span: TextSpan, _job: RenderJob): void { /* no-op */ }
715
- ellipse(_c: Point, _rx: number, _ry: number, _f: boolean, _j: RenderJob): void { /* no-op */ }
716
- polygon(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
717
- bezier(_pts: Point[], _filled: boolean, _job: RenderJob): void { /* no-op */ }
718
- polyline(_pts: Point[], _job: RenderJob): void { /* no-op */ }
719
719
  }
720
720
 
721
721
  // ---------------------------------------------------------------------------
@@ -0,0 +1,461 @@
1
+ // SPDX-License-Identifier: EPL-2.0
2
+
3
+ /**
4
+ * In-place sort matching libc++ `std::sort`'s permutation, including its treatment of
5
+ * comparator-equal elements. Ported from LLVM libc++ (`_LIBCPP_VERSION` 220106), which is
6
+ * permissively licensed and EPL-2.0-compatible:
7
+ *
8
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9
+ * See https://llvm.org/LICENSE.txt for license information.
10
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
+ *
12
+ * Source: `__algorithm/sort.h`, `sift_down.h`, `make_heap.h`, `partial_sort.h`, `sort_heap.h`,
13
+ * `pop_heap.h`, `push_heap.h`.
14
+ *
15
+ * Why: lib/vpsc/generate-constraints.cpp sorts sweep events with `std::sort`. Its comparator
16
+ * reports a tie for different rectangles at one position, and libc++ reorders ties repeatably,
17
+ * so JS's stable sort gives another event order from 24 rectangles up (48 events, the first
18
+ * length above `__limit`). See plans/post-16-1-followups-9/harness/T7.
19
+ *
20
+ * This is the one instantiation the oracle's libvpsc.a holds, whose mangled names read
21
+ * `__introsort<_ClassicAlgPolicy, bool (*&)(const Event&, const Event&), Event*, false>` and
22
+ * `__sift_down<_ClassicAlgPolicy, false, ...>`: a type that is not arithmetic and so not
23
+ * branchless. What that instantiation cannot reach is not ported: the branchless `__sort3-5`,
24
+ * `__bitset_partition`, `__sift_down`'s `__assume_both_children`, and `__partial_sort_impl`'s
25
+ * loop over `[middle, last)`, because the fallback passes `middle == last`.
26
+ *
27
+ * Moved-from slots keep their old value here. No path reads one before it is written, as in C++.
28
+ */
29
+
30
+ /** Upper bound for using insertion sort. @see __algorithm/sort.h:__introsort __limit */
31
+ const LIMIT = 24;
32
+ /** Lower bound for Tukey's ninther. @see __algorithm/sort.h:__introsort __ninther_threshold */
33
+ const NINTHER_THRESHOLD = 128;
34
+ /** Insertions before giving up. @see __algorithm/sort.h:__insertion_sort_incomplete __limit */
35
+ const INCOMPLETE_LIMIT = 8;
36
+
37
+ /** @see __bit/bit_log2.h:__bit_log2 */
38
+ function bitLog2(n: number): number {
39
+ return 31 - Math.clz32(n);
40
+ }
41
+
42
+ /**
43
+ * The template's fixed arguments, the array and the comparator, as fields. Indices stand for the
44
+ * C++ iterators.
45
+ */
46
+ class Introsort<T> {
47
+ private readonly a: T[];
48
+ private readonly lt: (x: T, y: T) => boolean;
49
+
50
+ constructor(a: T[], lt: (x: T, y: T) => boolean) {
51
+ this.a = a;
52
+ this.lt = lt;
53
+ }
54
+
55
+ /** @see __algorithm/iter_swap.h:iter_swap */
56
+ private swap(i: number, j: number): void {
57
+ const a = this.a;
58
+ const t = a[i]!;
59
+ a[i] = a[j]!;
60
+ a[j] = t;
61
+ }
62
+
63
+ /** @see __algorithm/sort.h:__sort3 */
64
+ private sort3(x: number, y: number, z: number): void {
65
+ const { a, lt } = this;
66
+ if (!lt(a[y]!, a[x]!)) {
67
+ if (!lt(a[z]!, a[y]!)) return;
68
+ this.swap(y, z);
69
+ if (lt(a[y]!, a[x]!)) this.swap(x, y);
70
+ return;
71
+ }
72
+ if (lt(a[z]!, a[y]!)) {
73
+ this.swap(x, z);
74
+ return;
75
+ }
76
+ this.swap(x, y);
77
+ if (lt(a[z]!, a[y]!)) this.swap(y, z);
78
+ }
79
+
80
+ /** @see __algorithm/sort.h:__sort4 */
81
+ private sort4(x1: number, x2: number, x3: number, x4: number): void {
82
+ const { a, lt } = this;
83
+ this.sort3(x1, x2, x3);
84
+ if (lt(a[x4]!, a[x3]!)) {
85
+ this.swap(x3, x4);
86
+ if (lt(a[x3]!, a[x2]!)) {
87
+ this.swap(x2, x3);
88
+ if (lt(a[x2]!, a[x1]!)) this.swap(x1, x2);
89
+ }
90
+ }
91
+ }
92
+
93
+ /** @see __algorithm/sort.h:__sort5 */
94
+ private sort5(x1: number, x2: number, x3: number, x4: number, x5: number): void {
95
+ const { a, lt } = this;
96
+ this.sort4(x1, x2, x3, x4);
97
+ if (lt(a[x5]!, a[x4]!)) {
98
+ this.swap(x4, x5);
99
+ if (lt(a[x4]!, a[x3]!)) {
100
+ this.swap(x3, x4);
101
+ if (lt(a[x3]!, a[x2]!)) {
102
+ this.swap(x2, x3);
103
+ if (lt(a[x2]!, a[x1]!)) this.swap(x1, x2);
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ /**
110
+ * The `switch (__last - __first)` that `__introsort` and `__insertion_sort_incomplete` share
111
+ * word for word, as one function because of the project's complexity limit.
112
+ * @returns true when the length was one of the cases, so the range is sorted
113
+ * @see __algorithm/sort.h:__introsort
114
+ */
115
+ private sortSmall(first: number, last: number): boolean {
116
+ const { a, lt } = this;
117
+ switch (last - first) {
118
+ case 0:
119
+ case 1:
120
+ return true;
121
+ case 2:
122
+ if (lt(a[last - 1]!, a[first]!)) this.swap(first, last - 1);
123
+ return true;
124
+ case 3:
125
+ this.sort3(first, first + 1, last - 1);
126
+ return true;
127
+ case 4:
128
+ this.sort4(first, first + 1, first + 2, last - 1);
129
+ return true;
130
+ case 5:
131
+ this.sort5(first, first + 1, first + 2, first + 3, last - 1);
132
+ return true;
133
+ default:
134
+ return false;
135
+ }
136
+ }
137
+
138
+ /** @see __algorithm/sort.h:__insertion_sort */
139
+ private insertionSort(first: number, last: number): void {
140
+ const { a, lt } = this;
141
+ if (first === last) return;
142
+ for (let i = first + 1; i !== last; ++i) {
143
+ let j = i - 1;
144
+ if (lt(a[i]!, a[j]!)) {
145
+ const t = a[i]!;
146
+ let k = j;
147
+ j = i;
148
+ do {
149
+ a[j] = a[k]!;
150
+ j = k;
151
+ } while (j !== first && lt(t, a[--k]!));
152
+ a[j] = t;
153
+ }
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Assumes that `first - 1` holds an element no element of the range sorts before.
159
+ * @see __algorithm/sort.h:__insertion_sort_unguarded
160
+ */
161
+ private insertionSortUnguarded(first: number, last: number): void {
162
+ const { a, lt } = this;
163
+ if (first === last) return;
164
+ for (let i = first + 1; i !== last; ++i) {
165
+ let j = i - 1;
166
+ if (lt(a[i]!, a[j]!)) {
167
+ const t = a[i]!;
168
+ let k = j;
169
+ j = i;
170
+ do {
171
+ a[j] = a[k]!;
172
+ j = k;
173
+ } while (lt(t, a[--k]!));
174
+ a[j] = t;
175
+ }
176
+ }
177
+ }
178
+
179
+ /** @see __algorithm/sort.h:__insertion_sort_incomplete */
180
+ private insertionSortIncomplete(first: number, last: number): boolean {
181
+ const { a, lt } = this;
182
+ if (this.sortSmall(first, last)) return true;
183
+ let j = first + 2;
184
+ this.sort3(first, first + 1, j);
185
+ let count = 0;
186
+ for (let i = j + 1; i !== last; ++i) {
187
+ if (lt(a[i]!, a[j]!)) {
188
+ const t = a[i]!;
189
+ let k = j;
190
+ j = i;
191
+ do {
192
+ a[j] = a[k]!;
193
+ j = k;
194
+ } while (j !== first && lt(t, a[--k]!));
195
+ a[j] = t;
196
+ if (++count === INCOMPLETE_LIMIT) return ++i === last;
197
+ }
198
+ j = i;
199
+ }
200
+ return true;
201
+ }
202
+
203
+ /**
204
+ * `*first` holds the pivot. Elements equivalent to it end up on its right.
205
+ * @returns the pivot's index, and whether the range was already partitioned
206
+ * @see __algorithm/sort.h:__partition_with_equals_on_right
207
+ */
208
+ private partitionWithEqualsOnRight(first: number, last: number): [number, boolean] {
209
+ const { a, lt } = this;
210
+ const begin = first;
211
+ const pivot = a[first]!;
212
+ do {
213
+ ++first;
214
+ } while (lt(a[first]!, pivot));
215
+ if (begin === first - 1) {
216
+ while (first < last && !lt(a[--last]!, pivot));
217
+ } else {
218
+ do {
219
+ --last;
220
+ } while (!lt(a[last]!, pivot));
221
+ }
222
+ const alreadyPartitioned = first >= last;
223
+ while (first < last) {
224
+ this.swap(first, last);
225
+ do {
226
+ ++first;
227
+ } while (lt(a[first]!, pivot));
228
+ do {
229
+ --last;
230
+ } while (!lt(a[last]!, pivot));
231
+ }
232
+ const pivotPos = first - 1;
233
+ if (begin !== pivotPos) a[begin] = a[pivotPos]!;
234
+ a[pivotPos] = pivot;
235
+ return [pivotPos, alreadyPartitioned];
236
+ }
237
+
238
+ /**
239
+ * The opening scan of `__partition_with_equals_on_left`, apart because of the project's
240
+ * complexity limit.
241
+ * @returns the first index after `first` that sorts after the pivot, or `last`
242
+ * @see __algorithm/sort.h:__partition_with_equals_on_left
243
+ */
244
+ private firstAfterPivot(first: number, last: number, pivot: T): number {
245
+ const { a, lt } = this;
246
+ if (lt(pivot, a[last - 1]!)) {
247
+ do {
248
+ ++first;
249
+ } while (!lt(pivot, a[first]!));
250
+ } else {
251
+ while (++first < last && !lt(pivot, a[first]!));
252
+ }
253
+ return first;
254
+ }
255
+
256
+ /**
257
+ * `*first` holds the pivot. Elements equivalent to it end up on its left.
258
+ * @returns the index after the pivot
259
+ * @see __algorithm/sort.h:__partition_with_equals_on_left
260
+ */
261
+ private partitionWithEqualsOnLeft(first: number, last: number): number {
262
+ const { a, lt } = this;
263
+ const begin = first;
264
+ const pivot = a[first]!;
265
+ first = this.firstAfterPivot(first, last, pivot);
266
+ if (first < last) {
267
+ do {
268
+ --last;
269
+ } while (lt(pivot, a[last]!));
270
+ }
271
+ while (first < last) {
272
+ this.swap(first, last);
273
+ do {
274
+ ++first;
275
+ } while (!lt(pivot, a[first]!));
276
+ do {
277
+ --last;
278
+ } while (lt(pivot, a[last]!));
279
+ }
280
+ const pivotPos = first - 1;
281
+ if (begin !== pivotPos) a[begin] = a[pivotPos]!;
282
+ a[pivotPos] = pivot;
283
+ return first;
284
+ }
285
+
286
+ /** @see __algorithm/sift_down.h:__sift_down */
287
+ private siftDown(first: number, len: number, start: number): void {
288
+ const { a, lt } = this;
289
+ let child = start;
290
+ if (len < 2 || Math.trunc((len - 2) / 2) < child) return;
291
+ child = 2 * child + 1;
292
+ if (child + 1 < len && lt(a[first + child]!, a[first + child + 1]!)) ++child;
293
+ if (lt(a[first + child]!, a[first + start]!)) return;
294
+ const top = a[first + start]!;
295
+ do {
296
+ a[first + start] = a[first + child]!;
297
+ start = child;
298
+ if (Math.trunc((len - 2) / 2) < child) break;
299
+ child = 2 * child + 1;
300
+ if (child + 1 < len && lt(a[first + child]!, a[first + child + 1]!)) ++child;
301
+ } while (!lt(a[first + child]!, top));
302
+ a[first + start] = top;
303
+ }
304
+
305
+ /** @see __algorithm/sift_down.h:__floyd_sift_down */
306
+ private floydSiftDown(first: number, len: number): number {
307
+ const { a, lt } = this;
308
+ let hole = first;
309
+ let childI = first;
310
+ let child = 0;
311
+ while (true) {
312
+ childI += child + 1;
313
+ child = 2 * child + 1;
314
+ if (child + 1 < len && lt(a[childI]!, a[childI + 1]!)) {
315
+ ++childI;
316
+ ++child;
317
+ }
318
+ a[hole] = a[childI]!;
319
+ hole = childI;
320
+ if (child > Math.trunc((len - 2) / 2)) return hole;
321
+ }
322
+ }
323
+
324
+ /** @see __algorithm/push_heap.h:__sift_up */
325
+ private siftUp(first: number, last: number, len: number): void {
326
+ const { a, lt } = this;
327
+ if (len > 1) {
328
+ len = Math.trunc((len - 2) / 2);
329
+ let ptr = first + len;
330
+ if (lt(a[ptr]!, a[--last]!)) {
331
+ const t = a[last]!;
332
+ do {
333
+ a[last] = a[ptr]!;
334
+ last = ptr;
335
+ if (len === 0) break;
336
+ len = Math.trunc((len - 1) / 2);
337
+ ptr = first + len;
338
+ } while (lt(a[ptr]!, t));
339
+ a[last] = t;
340
+ }
341
+ }
342
+ }
343
+
344
+ /** @see __algorithm/pop_heap.h:__pop_heap */
345
+ private popHeap(first: number, last: number, len: number): void {
346
+ const a = this.a;
347
+ if (len > 1) {
348
+ const top = a[first]!;
349
+ let hole = this.floydSiftDown(first, len);
350
+ --last;
351
+ if (hole === last) {
352
+ a[hole] = top;
353
+ } else {
354
+ a[hole] = a[last]!;
355
+ ++hole;
356
+ a[last] = top;
357
+ this.siftUp(first, hole, hole - first);
358
+ }
359
+ }
360
+ }
361
+
362
+ /** @see __algorithm/make_heap.h:__make_heap */
363
+ private makeHeap(first: number, last: number): void {
364
+ const n = last - first;
365
+ if (n > 1) {
366
+ for (let start = Math.trunc((n - 2) / 2); start >= 0; --start) {
367
+ this.siftDown(first, n, start);
368
+ }
369
+ }
370
+ }
371
+
372
+ /** @see __algorithm/sort_heap.h:__sort_heap */
373
+ private sortHeap(first: number, last: number): void {
374
+ for (let n = last - first; n > 1; --last, --n) this.popHeap(first, last, n);
375
+ }
376
+
377
+ /**
378
+ * `__partial_sort_impl(first, last, last, comp)`, as the depth fallback calls it.
379
+ * @see __algorithm/partial_sort.h:__partial_sort_impl
380
+ */
381
+ private partialSort(first: number, last: number): void {
382
+ this.makeHeap(first, last);
383
+ this.sortHeap(first, last);
384
+ }
385
+
386
+ /**
387
+ * Tukey's ninther or the median of 3, leaving the pivot at `first`. Apart from `__introsort`
388
+ * because of the project's complexity limit.
389
+ * @see __algorithm/sort.h:__introsort
390
+ */
391
+ private selectPivot(first: number, last: number, len: number): void {
392
+ const halfLen = Math.trunc(len / 2);
393
+ if (len > NINTHER_THRESHOLD) {
394
+ this.sort3(first, first + halfLen, last - 1);
395
+ this.sort3(first + 1, first + (halfLen - 1), last - 2);
396
+ this.sort3(first + 2, first + (halfLen + 1), last - 3);
397
+ this.sort3(first + (halfLen - 1), first + halfLen, first + (halfLen + 1));
398
+ this.swap(first, first + halfLen);
399
+ } else {
400
+ this.sort3(first + halfLen, first, last - 1);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * `__introsort`'s test for a pivot equal to the highest element on its left. Apart because of
406
+ * the project's complexity limit.
407
+ * @see __algorithm/sort.h:__introsort
408
+ */
409
+ private pivotEqualsLeftNeighbour(first: number, leftmost: boolean): boolean {
410
+ return !leftmost && !this.lt(this.a[first - 1]!, this.a[first]!);
411
+ }
412
+
413
+ /** @see __algorithm/sort.h:__introsort */
414
+ introsort(first: number, last: number, depth: number, leftmost: boolean): void {
415
+ while (true) {
416
+ const len = last - first;
417
+ if (this.sortSmall(first, last)) return;
418
+ if (len < LIMIT) {
419
+ if (leftmost) this.insertionSort(first, last);
420
+ else this.insertionSortUnguarded(first, last);
421
+ return;
422
+ }
423
+ if (depth === 0) {
424
+ this.partialSort(first, last);
425
+ return;
426
+ }
427
+ --depth;
428
+ this.selectPivot(first, last, len);
429
+ if (this.pivotEqualsLeftNeighbour(first, leftmost)) {
430
+ first = this.partitionWithEqualsOnLeft(first, last);
431
+ continue;
432
+ }
433
+ const [i, alreadyPartitioned] = this.partitionWithEqualsOnRight(first, last);
434
+ if (alreadyPartitioned) {
435
+ const fs = this.insertionSortIncomplete(first, i);
436
+ if (this.insertionSortIncomplete(i + 1, last)) {
437
+ if (fs) return;
438
+ last = i;
439
+ continue;
440
+ }
441
+ if (fs) {
442
+ first = i + 1;
443
+ continue;
444
+ }
445
+ }
446
+ this.introsort(first, i, depth, leftmost);
447
+ leftmost = false;
448
+ first = i + 1;
449
+ }
450
+ }
451
+ }
452
+
453
+ /**
454
+ * Sorts `a` in place as libc++ `std::sort(a.begin(), a.end(), lt)` does, for an element type that
455
+ * is not arithmetic and a comparator that is not `std::less`.
456
+ * @see __algorithm/sort.h:__sort_dispatch
457
+ */
458
+ export function libcxxSort<T>(a: T[], lt: (x: T, y: T) => boolean): void {
459
+ if (a.length === 0) return;
460
+ new Introsort(a, lt).introsort(0, a.length, 2 * bitLog2(a.length), true);
461
+ }