@graphty/graph-io 0.3.19 → 0.3.21

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 (201) hide show
  1. package/README.md +49 -4
  2. package/dist/chunks/{escape-CWExcecC.js → escape-B-tkk_Cl.js} +74 -16
  3. package/dist/chunks/escape-B-tkk_Cl.js.map +1 -0
  4. package/dist/chunks/{writer-DQiKgQJc.js → export-Bh60Dv-n.js} +5 -79
  5. package/dist/chunks/export-Bh60Dv-n.js.map +1 -0
  6. package/dist/chunks/{exporter-CbMZyVt-.js → exporter-BGrsWamJ.js} +7 -6
  7. package/dist/chunks/{exporter-CbMZyVt-.js.map → exporter-BGrsWamJ.js.map} +1 -1
  8. package/dist/chunks/exporter-DIeGJXAZ.js +834 -0
  9. package/dist/chunks/exporter-DIeGJXAZ.js.map +1 -0
  10. package/dist/chunks/{importer-BNFuV1-K.js → importer-BWY2FFc5.js} +28 -7
  11. package/dist/chunks/importer-BWY2FFc5.js.map +1 -0
  12. package/dist/chunks/importer-DD-xv9_Y.js +1471 -0
  13. package/dist/chunks/importer-DD-xv9_Y.js.map +1 -0
  14. package/dist/chunks/{importer-BAP4PrxR.js → importer-DET1tg6s.js} +30 -20
  15. package/dist/chunks/importer-DET1tg6s.js.map +1 -0
  16. package/dist/chunks/{importer-ByPGO-09.js → importer-DEcKhsmQ.js} +2 -2
  17. package/dist/chunks/{importer-ByPGO-09.js.map → importer-DEcKhsmQ.js.map} +1 -1
  18. package/dist/chunks/{importer-BW-Ft2ps.js → importer-DIrbbnAf.js} +6 -5
  19. package/dist/chunks/{importer-BW-Ft2ps.js.map → importer-DIrbbnAf.js.map} +1 -1
  20. package/dist/chunks/importer-D_e7e7LX.js +3055 -0
  21. package/dist/chunks/importer-D_e7e7LX.js.map +1 -0
  22. package/dist/chunks/{importer-Bm1_5vPS.js → importer-eUREhBGj.js} +11 -8
  23. package/dist/chunks/importer-eUREhBGj.js.map +1 -0
  24. package/dist/chunks/{importer-DOepkgnG.js → importer-vi3bSdtw.js} +4 -4
  25. package/dist/chunks/{importer-DOepkgnG.js.map → importer-vi3bSdtw.js.map} +1 -1
  26. package/dist/chunks/{importer-BVGtU1NA.js → importer-zGLo8Dg_.js} +6 -5
  27. package/dist/chunks/{importer-BVGtU1NA.js.map → importer-zGLo8Dg_.js.map} +1 -1
  28. package/dist/chunks/{json-elements-CZY1wiZh.js → json-elements-DDS8N2Dd.js} +2 -2
  29. package/dist/chunks/{json-elements-CZY1wiZh.js.map → json-elements-DDS8N2Dd.js.map} +1 -1
  30. package/dist/chunks/{records-BzNicMsf.js → records-dbRkxwaq.js} +2 -2
  31. package/dist/chunks/{records-BzNicMsf.js.map → records-dbRkxwaq.js.map} +1 -1
  32. package/dist/chunks/{report-BcWboivV.js → report-B1z4WT9e.js} +143 -111
  33. package/dist/chunks/{report-BcWboivV.js.map → report-B1z4WT9e.js.map} +1 -1
  34. package/dist/chunks/{weights-CwISIpCP.js → weights-Dzba96G3.js} +5 -5
  35. package/dist/chunks/{weights-CwISIpCP.js.map → weights-Dzba96G3.js.map} +1 -1
  36. package/dist/chunks/writer-C7flM-Ih.js +77 -0
  37. package/dist/chunks/writer-C7flM-Ih.js.map +1 -0
  38. package/dist/csv.js +6 -5
  39. package/dist/csv.js.map +1 -1
  40. package/dist/cx.js +1 -1
  41. package/dist/cx2.js +2 -2
  42. package/dist/cys.d.ts +1 -0
  43. package/dist/cys.js +6 -0
  44. package/dist/cys.js.map +1 -0
  45. package/dist/dot.js +1 -1
  46. package/dist/gexf.js +5 -4
  47. package/dist/gexf.js.map +1 -1
  48. package/dist/gml.js +12 -14
  49. package/dist/gml.js.map +1 -1
  50. package/dist/graph-io.js +288 -141
  51. package/dist/graph-io.js.map +1 -1
  52. package/dist/graphml.js +1 -1
  53. package/dist/json.js +1 -1
  54. package/dist/neo4j.js +6 -5
  55. package/dist/neo4j.js.map +1 -1
  56. package/dist/obo.js +1 -1
  57. package/dist/pajek.js +1 -1
  58. package/dist/src/common/cell-budget.d.ts +84 -0
  59. package/dist/src/common/cell-budget.d.ts.map +1 -0
  60. package/dist/src/common/cell-budget.js +138 -0
  61. package/dist/src/common/cell-budget.js.map +1 -0
  62. package/dist/src/common/input.d.ts +10 -0
  63. package/dist/src/common/input.d.ts.map +1 -1
  64. package/dist/src/common/input.js +39 -0
  65. package/dist/src/common/input.js.map +1 -1
  66. package/dist/src/common/options.d.ts +6 -0
  67. package/dist/src/common/options.d.ts.map +1 -1
  68. package/dist/src/common/options.js +1 -1
  69. package/dist/src/common/options.js.map +1 -1
  70. package/dist/src/common/xml.d.ts +37 -3
  71. package/dist/src/common/xml.d.ts.map +1 -1
  72. package/dist/src/common/xml.js +86 -6
  73. package/dist/src/common/xml.js.map +1 -1
  74. package/dist/src/common/zip.d.ts +92 -0
  75. package/dist/src/common/zip.d.ts.map +1 -0
  76. package/dist/src/common/zip.js +399 -0
  77. package/dist/src/common/zip.js.map +1 -0
  78. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  79. package/dist/src/formats/cx/importer.js +26 -17
  80. package/dist/src/formats/cx/importer.js.map +1 -1
  81. package/dist/src/formats/cys/constants.d.ts +68 -0
  82. package/dist/src/formats/cys/constants.d.ts.map +1 -0
  83. package/dist/src/formats/cys/constants.js +76 -0
  84. package/dist/src/formats/cys/constants.js.map +1 -0
  85. package/dist/src/formats/cys/importer.d.ts +38 -0
  86. package/dist/src/formats/cys/importer.d.ts.map +1 -0
  87. package/dist/src/formats/cys/importer.js +830 -0
  88. package/dist/src/formats/cys/importer.js.map +1 -0
  89. package/dist/src/formats/cys/index.d.ts +7 -0
  90. package/dist/src/formats/cys/index.d.ts.map +1 -0
  91. package/dist/src/formats/cys/index.js +7 -0
  92. package/dist/src/formats/cys/index.js.map +1 -0
  93. package/dist/src/formats/cys/session.d.ts +132 -0
  94. package/dist/src/formats/cys/session.d.ts.map +1 -0
  95. package/dist/src/formats/cys/session.js +315 -0
  96. package/dist/src/formats/cys/session.js.map +1 -0
  97. package/dist/src/formats/cys/tables.d.ts +90 -0
  98. package/dist/src/formats/cys/tables.d.ts.map +1 -0
  99. package/dist/src/formats/cys/tables.js +293 -0
  100. package/dist/src/formats/cys/tables.js.map +1 -0
  101. package/dist/src/formats/dot/exporter.d.ts +2 -0
  102. package/dist/src/formats/dot/exporter.d.ts.map +1 -1
  103. package/dist/src/formats/dot/exporter.js +12 -0
  104. package/dist/src/formats/dot/exporter.js.map +1 -1
  105. package/dist/src/formats/dot/importer.js +6 -2
  106. package/dist/src/formats/dot/importer.js.map +1 -1
  107. package/dist/src/formats/gexf/importer.d.ts +2 -2
  108. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  109. package/dist/src/formats/gexf/importer.js +1 -1
  110. package/dist/src/formats/gexf/importer.js.map +1 -1
  111. package/dist/src/formats/gml/exporter.d.ts +0 -8
  112. package/dist/src/formats/gml/exporter.d.ts.map +1 -1
  113. package/dist/src/formats/gml/exporter.js +7 -17
  114. package/dist/src/formats/gml/exporter.js.map +1 -1
  115. package/dist/src/formats/json/exporter.d.ts.map +1 -1
  116. package/dist/src/formats/json/exporter.js +3 -1
  117. package/dist/src/formats/json/exporter.js.map +1 -1
  118. package/dist/src/formats/json/importer.d.ts.map +1 -1
  119. package/dist/src/formats/json/importer.js +3 -2
  120. package/dist/src/formats/json/importer.js.map +1 -1
  121. package/dist/src/formats/xgmml/columns.d.ts +152 -0
  122. package/dist/src/formats/xgmml/columns.d.ts.map +1 -0
  123. package/dist/src/formats/xgmml/columns.js +593 -0
  124. package/dist/src/formats/xgmml/columns.js.map +1 -0
  125. package/dist/src/formats/xgmml/constants.d.ts +196 -0
  126. package/dist/src/formats/xgmml/constants.d.ts.map +1 -0
  127. package/dist/src/formats/xgmml/constants.js +197 -0
  128. package/dist/src/formats/xgmml/constants.js.map +1 -0
  129. package/dist/src/formats/xgmml/document.d.ts +361 -0
  130. package/dist/src/formats/xgmml/document.d.ts.map +1 -0
  131. package/dist/src/formats/xgmml/document.js +695 -0
  132. package/dist/src/formats/xgmml/document.js.map +1 -0
  133. package/dist/src/formats/xgmml/emit.d.ts +341 -0
  134. package/dist/src/formats/xgmml/emit.d.ts.map +1 -0
  135. package/dist/src/formats/xgmml/emit.js +1275 -0
  136. package/dist/src/formats/xgmml/emit.js.map +1 -0
  137. package/dist/src/formats/xgmml/exporter.d.ts +24 -0
  138. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -0
  139. package/dist/src/formats/xgmml/exporter.js +999 -0
  140. package/dist/src/formats/xgmml/exporter.js.map +1 -0
  141. package/dist/src/formats/xgmml/importer.d.ts +58 -0
  142. package/dist/src/formats/xgmml/importer.d.ts.map +1 -0
  143. package/dist/src/formats/xgmml/importer.js +360 -0
  144. package/dist/src/formats/xgmml/importer.js.map +1 -0
  145. package/dist/src/formats/xgmml/index.d.ts +8 -0
  146. package/dist/src/formats/xgmml/index.d.ts.map +1 -0
  147. package/dist/src/formats/xgmml/index.js +8 -0
  148. package/dist/src/formats/xgmml/index.js.map +1 -0
  149. package/dist/src/formats/xgmml/values.d.ts +60 -0
  150. package/dist/src/formats/xgmml/values.d.ts.map +1 -0
  151. package/dist/src/formats/xgmml/values.js +148 -0
  152. package/dist/src/formats/xgmml/values.js.map +1 -0
  153. package/dist/src/index.d.ts +2 -0
  154. package/dist/src/index.d.ts.map +1 -1
  155. package/dist/src/index.js +2 -0
  156. package/dist/src/index.js.map +1 -1
  157. package/dist/src/registry.d.ts +7 -0
  158. package/dist/src/registry.d.ts.map +1 -1
  159. package/dist/src/registry.js +25 -10
  160. package/dist/src/registry.js.map +1 -1
  161. package/dist/src/sniff.d.ts +1 -1
  162. package/dist/src/sniff.d.ts.map +1 -1
  163. package/dist/src/sniff.js +2 -0
  164. package/dist/src/sniff.js.map +1 -1
  165. package/dist/xgmml.d.ts +1 -0
  166. package/dist/xgmml.js +9 -0
  167. package/dist/xgmml.js.map +1 -0
  168. package/package.json +15 -2
  169. package/src/common/cell-budget.ts +170 -0
  170. package/src/common/input.ts +40 -0
  171. package/src/common/options.ts +1 -1
  172. package/src/common/xml.ts +127 -6
  173. package/src/common/zip.ts +472 -0
  174. package/src/formats/cx/importer.ts +27 -19
  175. package/src/formats/cys/constants.ts +99 -0
  176. package/src/formats/cys/importer.ts +1100 -0
  177. package/src/formats/cys/index.ts +7 -0
  178. package/src/formats/cys/session.ts +428 -0
  179. package/src/formats/cys/tables.ts +400 -0
  180. package/src/formats/dot/exporter.ts +17 -0
  181. package/src/formats/dot/importer.ts +6 -2
  182. package/src/formats/gexf/importer.ts +0 -1
  183. package/src/formats/gml/exporter.ts +7 -18
  184. package/src/formats/json/exporter.ts +3 -1
  185. package/src/formats/json/importer.ts +3 -2
  186. package/src/formats/xgmml/columns.ts +747 -0
  187. package/src/formats/xgmml/constants.ts +265 -0
  188. package/src/formats/xgmml/document.ts +975 -0
  189. package/src/formats/xgmml/emit.ts +1563 -0
  190. package/src/formats/xgmml/exporter.ts +1215 -0
  191. package/src/formats/xgmml/importer.ts +491 -0
  192. package/src/formats/xgmml/index.ts +8 -0
  193. package/src/formats/xgmml/values.ts +183 -0
  194. package/src/index.ts +9 -0
  195. package/src/registry.ts +41 -15
  196. package/src/sniff.ts +5 -1
  197. package/dist/chunks/escape-CWExcecC.js.map +0 -1
  198. package/dist/chunks/importer-BAP4PrxR.js.map +0 -1
  199. package/dist/chunks/importer-BNFuV1-K.js.map +0 -1
  200. package/dist/chunks/importer-Bm1_5vPS.js.map +0 -1
  201. package/dist/chunks/writer-DQiKgQJc.js.map +0 -1
package/dist/graph-io.js CHANGED
@@ -1,37 +1,173 @@
1
- import { I as ImportReportBuilder, t as throwIfAborted } from "./chunks/report-BcWboivV.js";
2
- import { A, a, B, b, c, d, C, e, f, g, D, h, i, j, k, l, m, n, o, p, E, q, r, s, G, H, u, v, w, x, y, z, F, J, L, M, K, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at, au, av, aw, ax, ay, az, aA, aB, aC, aD } from "./chunks/report-BcWboivV.js";
1
+ import { ag as describe, w as ImportReportBuilder, y as throwIfAborted } from "./chunks/report-B1z4WT9e.js";
2
+ import { A, m, n, Z, ah, B, C, a5, ai, l, j, aj, ak, D, a, i, c, al, d, J, a4, u, E, am, G, an, I, a8, b, a2, r, s, K, ao, ap, e, f, af, M, a9, aq, aa, N, $, O, ar, ab, h, as, P, at, a6, ac, R, S, p, o, a3, au, g, t, ae, ad, a1, T, k, Y, q, U, av, a7, W, a0, aw, ax, H, ay, az, aA, L, aB, aC, aD, aE, aF, X, aG, F, z, V, v, x } from "./chunks/report-B1z4WT9e.js";
3
3
  import { C as C2, c as c2, a as a10 } from "./chunks/children-CL3Cy0ez.js";
4
4
  import { GraphFormatError, GraphBuilder } from "@graphty/graph-format";
5
5
  import { csvImporter, csvExporter } from "./csv.js";
6
6
  import { CSV_CAPABILITIES, CSV_ISSUE, CSV_LOSS } from "./csv.js";
7
- import { c as cxImporter } from "./chunks/importer-BAP4PrxR.js";
8
- import { C as C3 } from "./chunks/importer-BAP4PrxR.js";
9
- import { c as cx2Exporter } from "./chunks/exporter-CbMZyVt-.js";
10
- import { C as C4, a as a11 } from "./chunks/exporter-CbMZyVt-.js";
11
- import { c as cx2Importer } from "./chunks/importer-DOepkgnG.js";
12
- import { C as C5 } from "./chunks/importer-DOepkgnG.js";
13
- import { b as dotImporter, d as dotExporter } from "./chunks/importer-BNFuV1-K.js";
14
- import { D as D2, a as a12 } from "./chunks/importer-BNFuV1-K.js";
7
+ import { c as cxImporter } from "./chunks/importer-DET1tg6s.js";
8
+ import { C as C3 } from "./chunks/importer-DET1tg6s.js";
9
+ import { c as cx2Exporter } from "./chunks/exporter-BGrsWamJ.js";
10
+ import { C as C4, a as a11 } from "./chunks/exporter-BGrsWamJ.js";
11
+ import { c as cx2Importer } from "./chunks/importer-vi3bSdtw.js";
12
+ import { C as C5 } from "./chunks/importer-vi3bSdtw.js";
13
+ import { c as cysImporter } from "./chunks/importer-DD-xv9_Y.js";
14
+ import { C as C6 } from "./chunks/importer-DD-xv9_Y.js";
15
+ import { b as dotImporter, d as dotExporter } from "./chunks/importer-BWY2FFc5.js";
16
+ import { D as D2, a as a12 } from "./chunks/importer-BWY2FFc5.js";
15
17
  import { gexfImporter, gexfExporter } from "./gexf.js";
16
18
  import { GEXF_1_2_CAPABILITIES, GEXF_ISSUE, GEXF_LOSS } from "./gexf.js";
17
19
  import { gmlImporter, gmlExporter } from "./gml.js";
18
20
  import { GML_ISSUE, GML_LOSS } from "./gml.js";
19
- import { b as graphmlImporter, g as graphmlExporter } from "./chunks/importer-BW-Ft2ps.js";
20
- import { G as G2, a as a13 } from "./chunks/importer-BW-Ft2ps.js";
21
- import { r as rankFormats, S as SNIFF_HEAD_BYTES, e as jsonImporter, c as jsonExporter } from "./chunks/importer-Bm1_5vPS.js";
22
- import { G as G3, J as J2, a as a14, b as b2, d as d2, f as f2, h as h2, j as j2, n as n2, s as s2, g as g2 } from "./chunks/importer-Bm1_5vPS.js";
21
+ import { b as graphmlImporter, g as graphmlExporter } from "./chunks/importer-DIrbbnAf.js";
22
+ import { G as G2, a as a13 } from "./chunks/importer-DIrbbnAf.js";
23
+ import { r as rankFormats, S as SNIFF_HEAD_BYTES, e as jsonImporter, c as jsonExporter } from "./chunks/importer-eUREhBGj.js";
24
+ import { G as G3, J as J2, a as a14, b as b2, d as d2, f as f2, h as h2, j as j2, n as n2, s as s2, g as g2 } from "./chunks/importer-eUREhBGj.js";
23
25
  import { neo4jImporter, neo4jExporter } from "./neo4j.js";
24
26
  import { ID_SPACE_COLUMN, LABELS_COLUMN, NEO4J_CAPABILITIES, NEO4J_ISSUE, NEO4J_LOSS, ORIGINAL_ID_COLUMN, TYPE_COLUMN } from "./neo4j.js";
25
- import { o as oboImporter } from "./chunks/importer-ByPGO-09.js";
26
- import { O as O2 } from "./chunks/importer-ByPGO-09.js";
27
- import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-BVGtU1NA.js";
28
- import { P as P2, a as a15 } from "./chunks/importer-BVGtU1NA.js";
29
- import { D as D3, L as L2, N as N2, c as c3, a as a16, b as b3, d as d3, e as e2, i as i2, j as j3, m as m2, s as s3, t } from "./chunks/writer-DQiKgQJc.js";
30
- import { e as e3, f as f3, a as a17, b as b4, c as c4, d as d4, i as i3, p as p2 } from "./chunks/weights-CwISIpCP.js";
31
- import { T as T2, W as W2, i as i4, a as a18, p as p3 } from "./chunks/text-Dr0Ifpag.js";
32
- import { X as X2, a as a19, h as h3, t as t2, x as x2 } from "./chunks/escape-CWExcecC.js";
27
+ import { o as oboImporter } from "./chunks/importer-DEcKhsmQ.js";
28
+ import { O as O2 } from "./chunks/importer-DEcKhsmQ.js";
29
+ import { b as pajekImporter, p as pajekExporter } from "./chunks/importer-zGLo8Dg_.js";
30
+ import { P as P2, a as a15 } from "./chunks/importer-zGLo8Dg_.js";
31
+ import { x as xgmmlExporter } from "./chunks/exporter-DIeGJXAZ.js";
32
+ import { x as xgmmlImporter } from "./chunks/importer-D_e7e7LX.js";
33
+ import { X as X2, a as a16 } from "./chunks/importer-D_e7e7LX.js";
34
+ import { L as L2, N as N2, c as c3, a as a17, i as i2, m as m2, s as s3 } from "./chunks/export-Bh60Dv-n.js";
35
+ import { e as e2, b as b3, f as f3, a as a18, c as c4, d as d3, i as i3, p as p2 } from "./chunks/weights-Dzba96G3.js";
36
+ import { T as T2, W as W2, i as i4, a as a19, p as p3 } from "./chunks/text-Dr0Ifpag.js";
37
+ import { D as D3, c as c5, d as d4, e as e3, j as j3, t as t2 } from "./chunks/writer-C7flM-Ih.js";
38
+ import { X as X3, b as b4, h as h3, t as t3, x as x2 } from "./chunks/escape-B-tkk_Cl.js";
39
+ const TOO_MANY_EMPTY_CELLS_CODE = "E_TOO_MANY_EMPTY_CELLS";
40
+ const DEFAULT_MAX_EMPTY_CELLS = 2 ** 24;
41
+ function maxEmptyCellsOption(value) {
42
+ if (value === void 0) {
43
+ return DEFAULT_MAX_EMPTY_CELLS;
44
+ }
45
+ if (typeof value === "number" && value >= 0 && (Number.isInteger(value) || value === Infinity)) {
46
+ return value;
47
+ }
48
+ throw new GraphFormatError(
49
+ "E_UNSUPPORTED",
50
+ `option maxEmptyCells: ${describe(value)} is not a non-negative integer or Infinity`,
51
+ { option: "maxEmptyCells", found: value }
52
+ );
53
+ }
54
+ class CellBudgetBuilder extends GraphBuilder {
55
+ /**
56
+ * Create a builder with a limit.
57
+ * @param options - the builder options
58
+ * @param format - the format being read, for the error's report
59
+ * @param maxEmptyCells - the most empty slots allowed
60
+ */
61
+ constructor(options, format, maxEmptyCells) {
62
+ super(options);
63
+ this.format = format;
64
+ this.maxEmptyCells = maxEmptyCells;
65
+ this.nodeColumns = /* @__PURE__ */ new Set();
66
+ this.edgeColumns = /* @__PURE__ */ new Set();
67
+ this.values = 0;
68
+ }
69
+ /**
70
+ * Add a node, then check the limit (its row adds a slot to every node column).
71
+ * @param id - the node id
72
+ * @returns the node index
73
+ */
74
+ addNode(id) {
75
+ const index = super.addNode(id);
76
+ this.checkBudget();
77
+ return index;
78
+ }
79
+ /**
80
+ * Add an edge, then check the limit (its row adds a slot to every edge column).
81
+ * @param source - source id
82
+ * @param target - target id
83
+ * @param weight - the weight
84
+ * @returns the edge index
85
+ */
86
+ addEdge(source, target, weight) {
87
+ const edge = super.addEdge(source, target, weight);
88
+ this.checkBudget();
89
+ return edge;
90
+ }
91
+ /**
92
+ * Declare a node column, then check the limit.
93
+ * @param decl - the declaration
94
+ * @returns the column handle
95
+ */
96
+ declareNodeColumn(decl) {
97
+ const handle = super.declareNodeColumn(decl);
98
+ this.nodeColumns.add(handle);
99
+ this.checkBudget();
100
+ return handle;
101
+ }
102
+ /**
103
+ * Declare an edge column, then check the limit.
104
+ * @param decl - the declaration
105
+ * @returns the column handle
106
+ */
107
+ declareEdgeColumn(decl) {
108
+ const handle = super.declareEdgeColumn(decl);
109
+ this.edgeColumns.add(handle);
110
+ this.checkBudget();
111
+ return handle;
112
+ }
113
+ /**
114
+ * Set a node cell (a new name declares a column), then check the limit.
115
+ * @param column - the handle or name
116
+ * @param index - the node index
117
+ * @param value - the value
118
+ */
119
+ setNodeValue(column, index, value) {
120
+ super.setNodeValue(column, index, value);
121
+ this.nodeColumns.add(typeof column === "string" ? this.nodeColumn(column) : column);
122
+ this.count(value);
123
+ }
124
+ /**
125
+ * Set an edge cell (a new name declares a column), then check the limit.
126
+ * @param column - the handle or name
127
+ * @param edge - the edge index
128
+ * @param value - the value
129
+ */
130
+ setEdgeValue(column, edge, value) {
131
+ super.setEdgeValue(column, edge, value);
132
+ this.edgeColumns.add(typeof column === "string" ? this.edgeColumn(column) : column);
133
+ this.count(value);
134
+ }
135
+ /**
136
+ * Count a written value and check the budget.
137
+ * @param value - the value; null and undefined unset a slot and do not count
138
+ */
139
+ count(value) {
140
+ if (value !== null && value !== void 0) {
141
+ this.values++;
142
+ }
143
+ this.checkBudget();
144
+ }
145
+ /**
146
+ * Throw when the columns' slots minus the values written pass the limit.
147
+ * @throws ImportError E_TOO_MANY_EMPTY_CELLS
148
+ */
149
+ checkBudget() {
150
+ const slots = this.nodeColumns.size * this.nodeBound + this.edgeColumns.size * this.edgeBound;
151
+ const empty = slots - this.values;
152
+ if (empty > this.maxEmptyCells) {
153
+ new ImportReportBuilder(this.format, Infinity).fail(
154
+ TOO_MANY_EMPTY_CELLS_CODE,
155
+ `the attributes are too sparse: ${this.nodeColumns.size} node and ${this.edgeColumns.size} edge attribute column(s) over ${this.nodeBound} node(s) and ${this.edgeBound} edge(s) would allocate more than ${this.maxEmptyCells} slots that hold no value; pass a larger maxEmptyCells (or Infinity) to read the file anyway`,
156
+ void 0,
157
+ { emptyCells: empty, maxEmptyCells: this.maxEmptyCells }
158
+ );
159
+ }
160
+ }
161
+ }
33
162
  const UNKNOWN_FORMAT_CODE = "E_UNKNOWN_FORMAT";
34
- const REGISTRY_KEYS = /* @__PURE__ */ new Set(["format", "filename", "mimeType", "builder", "freeze"]);
163
+ const REGISTRY_KEYS = /* @__PURE__ */ new Set([
164
+ "format",
165
+ "filename",
166
+ "mimeType",
167
+ "builder",
168
+ "freeze",
169
+ "maxEmptyCells"
170
+ ]);
35
171
  class FormatRegistry {
36
172
  constructor() {
37
173
  this.importerMap = /* @__PURE__ */ new Map();
@@ -148,7 +284,7 @@ class FormatRegistry {
148
284
  */
149
285
  async importGraph(input, options = {}) {
150
286
  const chosen = await this.choose(input, options);
151
- const builder = seededBuilder(options);
287
+ const builder = seededBuilder(options, chosen.importer.format);
152
288
  let report;
153
289
  try {
154
290
  report = await chosen.importer.import(chosen.source, builder, importerOptions(options));
@@ -174,13 +310,13 @@ class FormatRegistry {
174
310
  let reports;
175
311
  try {
176
312
  if (importer.importAll === void 0) {
177
- builders.push(seededBuilder(options));
313
+ builders.push(seededBuilder(options, importer.format));
178
314
  reports = [await importer.import(chosen.source, builders[0], importerOptions(options))];
179
315
  } else {
180
316
  reports = await importer.importAll(
181
317
  chosen.source,
182
318
  () => {
183
- const builder = seededBuilder(options);
319
+ const builder = seededBuilder(options, importer.format);
184
320
  builders.push(builder);
185
321
  return builder;
186
322
  },
@@ -266,7 +402,7 @@ class FormatRegistry {
266
402
  }
267
403
  }
268
404
  function createRegistry() {
269
- return new FormatRegistry().registerImporter(jsonImporter).registerExporter(jsonExporter).registerImporter(graphmlImporter).registerExporter(graphmlExporter).registerImporter(gexfImporter).registerExporter(gexfExporter).registerImporter(csvImporter).registerExporter(csvExporter).registerImporter(gmlImporter).registerExporter(gmlExporter).registerImporter(dotImporter).registerExporter(dotExporter).registerImporter(pajekImporter).registerExporter(pajekExporter).registerImporter(neo4jImporter).registerExporter(neo4jExporter).registerImporter(cx2Importer).registerExporter(cx2Exporter).registerImporter(cxImporter).registerImporter(oboImporter);
405
+ return new FormatRegistry().registerImporter(jsonImporter).registerExporter(jsonExporter).registerImporter(graphmlImporter).registerExporter(graphmlExporter).registerImporter(gexfImporter).registerExporter(gexfExporter).registerImporter(csvImporter).registerExporter(csvExporter).registerImporter(gmlImporter).registerExporter(gmlExporter).registerImporter(dotImporter).registerExporter(dotExporter).registerImporter(pajekImporter).registerExporter(pajekExporter).registerImporter(neo4jImporter).registerExporter(neo4jExporter).registerImporter(xgmmlImporter).registerExporter(xgmmlExporter).registerImporter(cx2Importer).registerExporter(cx2Exporter).registerImporter(cxImporter).registerImporter(oboImporter).registerImporter(cysImporter);
270
406
  }
271
407
  const registry = createRegistry();
272
408
  function importGraph(input, options) {
@@ -299,15 +435,20 @@ function importerOptions(options) {
299
435
  }
300
436
  return out;
301
437
  }
302
- function seededBuilder(options) {
303
- return new GraphBuilder({
304
- weightDtype: options.weightDtype ?? "f64",
305
- ...options.builder,
306
- directed: true,
307
- addMissingNodes: options.addMissingNodes ?? true,
308
- duplicateEdges: options.duplicateEdges ?? "keep",
309
- selfLoops: options.selfLoops ?? "keep"
310
- });
438
+ function seededBuilder(options, format) {
439
+ const maxEmptyCells = maxEmptyCellsOption(options.maxEmptyCells);
440
+ return new CellBudgetBuilder(
441
+ {
442
+ weightDtype: options.weightDtype ?? "f64",
443
+ ...options.builder,
444
+ directed: true,
445
+ addMissingNodes: options.addMissingNodes ?? true,
446
+ duplicateEdges: options.duplicateEdges ?? "keep",
447
+ selfLoops: options.selfLoops ?? "keep"
448
+ },
449
+ format,
450
+ maxEmptyCells
451
+ );
311
452
  }
312
453
  function result(chosen, builder, report, options) {
313
454
  const frozen = builder.freezeWithReport(options.freeze);
@@ -370,10 +511,10 @@ async function peekHead(input, bytes, signal) {
370
511
  return { head: joinHead(buffered, bytes), input: replayed, close: () => replayed.close() };
371
512
  }
372
513
  function joinHead(chunks, bytes) {
373
- if (chunks.every((c5) => c5 instanceof Uint8Array)) {
514
+ if (chunks.every((c6) => c6 instanceof Uint8Array)) {
374
515
  const total = Math.min(
375
516
  bytes,
376
- chunks.reduce((sum, c5) => sum + c5.byteLength, 0)
517
+ chunks.reduce((sum, c6) => sum + c6.byteLength, 0)
377
518
  );
378
519
  const head = new Uint8Array(total);
379
520
  let offset = 0;
@@ -460,15 +601,15 @@ function readerIterator(stream) {
460
601
  }
461
602
  export {
462
603
  A as AMBIGUOUS_GRAPH_NAME_CODE,
463
- a as ASPECT_ORDER_CODE,
464
- B as BAD_ASPECT_BLOCK_CODE,
465
- b as BAD_DEFAULT_CODE,
466
- c as BAD_OPTIONS_CODE,
467
- d as BAD_VALUE_CODE,
604
+ m as ASPECT_ORDER_CODE,
605
+ n as BAD_ASPECT_BLOCK_CODE,
606
+ Z as BAD_DEFAULT_CODE,
607
+ ah as BAD_OPTIONS_CODE,
608
+ B as BAD_VALUE_CODE,
468
609
  C as COLUMN_RENAMED_CODE,
469
- e as COLUMN_RENAMED_LOSS_CODE,
470
- f as COUNT_HINT_CODE,
471
- g as COUNT_MISMATCH_CODE,
610
+ a5 as COLUMN_RENAMED_LOSS_CODE,
611
+ ai as COUNT_HINT_CODE,
612
+ l as COUNT_MISMATCH_CODE,
472
613
  CSV_CAPABILITIES,
473
614
  CSV_ISSUE,
474
615
  CSV_LOSS,
@@ -476,24 +617,25 @@ export {
476
617
  C5 as CX2_ISSUE,
477
618
  a11 as CX2_LOSS,
478
619
  C3 as CX_ISSUE,
620
+ C6 as CYS_ISSUE,
479
621
  C2 as ChildrenCsr,
480
- D as DANGLING_REFERENCE_CODE,
622
+ j as DANGLING_REFERENCE_CODE,
481
623
  D3 as DEFAULT_CHUNK_BYTES,
482
- h as DEFAULT_ERROR_LIMIT,
483
- i as DIRECTED_COLUMN,
484
- j as DIRECTION_FORCED_CODE,
485
- k as DIRECTION_REFUSED_CODE,
624
+ aj as DEFAULT_ERROR_LIMIT,
625
+ ak as DIRECTED_COLUMN,
626
+ D as DIRECTION_FORCED_CODE,
627
+ a as DIRECTION_REFUSED_CODE,
486
628
  D2 as DOT_ISSUE,
487
629
  a12 as DOT_LOSS,
488
- l as DUPLICATE_ATTRIBUTE_CODE,
489
- m as DUPLICATE_EDGE_ID_CODE,
490
- n as DUPLICATE_KEY_CODE,
491
- o as DUPLICATE_NODE_CODE,
492
- p as DirectionResolver,
493
- E as EMPTY_COLUMN_DROPPED_CODE,
494
- q as EMPTY_INPUT_CODE,
495
- r as ENCODING_FALLBACK_CODE,
496
- s as EQUATION_AS_TEXT_CODE,
630
+ i as DUPLICATE_ATTRIBUTE_CODE,
631
+ c as DUPLICATE_EDGE_ID_CODE,
632
+ al as DUPLICATE_KEY_CODE,
633
+ d as DUPLICATE_NODE_CODE,
634
+ J as DirectionResolver,
635
+ a4 as EMPTY_COLUMN_DROPPED_CODE,
636
+ u as EMPTY_INPUT_CODE,
637
+ E as ENCODING_FALLBACK_CODE,
638
+ am as EQUATION_AS_TEXT_CODE,
497
639
  FormatRegistry,
498
640
  GEXF_1_2_CAPABILITIES,
499
641
  GEXF_ISSUE,
@@ -504,110 +646,113 @@ export {
504
646
  a13 as GRAPHML_LOSS,
505
647
  G3 as GRAPH_FORMATS,
506
648
  G as GRAPH_NOT_FOUND_CODE,
507
- H as HYPEREDGE_CODE,
508
- u as ID_MERGED_CODE,
649
+ an as HYPEREDGE_CODE,
650
+ I as ID_MERGED_CODE,
509
651
  ID_SPACE_COLUMN,
510
- v as ID_TEXT_COLLISION_CODE,
511
- w as ID_TEXT_TYPE_CODE,
512
- x as INTEGRAL_F64_CODE,
513
- y as INVALID_ENCODING_CODE,
514
- z as INVALID_UTF8_CODE,
515
- F as IdCoercer,
516
- J as ImportError,
652
+ a8 as ID_TEXT_COLLISION_CODE,
653
+ b as ID_TEXT_TYPE_CODE,
654
+ a2 as INTEGRAL_F64_CODE,
655
+ r as INVALID_ENCODING_CODE,
656
+ s as INVALID_UTF8_CODE,
657
+ K as IdCoercer,
658
+ ao as ImportError,
517
659
  ImportReportBuilder,
518
660
  J2 as JSON_DIALECTS,
519
661
  a14 as JSON_ISSUE,
520
662
  b2 as JSON_LOSS,
521
663
  LABELS_COLUMN,
522
664
  L2 as LOSS,
523
- L as LineReader,
524
- M as MISSING_ENDPOINT_CODE,
525
- K as MISSING_ID_CODE,
526
- N as MIXED_DIRECTION_CODE,
527
- O as MULTIPLE_GRAPHS_CODE,
528
- P as MUTUAL_AS_UNDIRECTED_CODE,
529
- Q as MUTUAL_COLUMN,
530
- R as MUTUAL_EXPANDED_CODE,
665
+ ap as LineReader,
666
+ e as MISSING_ENDPOINT_CODE,
667
+ f as MISSING_ID_CODE,
668
+ af as MIXED_DIRECTION_CODE,
669
+ M as MULTIPLE_GRAPHS_CODE,
670
+ a9 as MUTUAL_AS_UNDIRECTED_CODE,
671
+ aq as MUTUAL_COLUMN,
672
+ aa as MUTUAL_EXPANDED_CODE,
531
673
  NEO4J_CAPABILITIES,
532
674
  NEO4J_ISSUE,
533
675
  NEO4J_LOSS,
534
676
  N2 as NO_CAPABILITIES,
535
- S as NO_GRAPH_CODE,
677
+ N as NO_GRAPH_CODE,
536
678
  O2 as OBO_ISSUE,
537
- T as OPTIONS_GAINED_CODE,
538
- U as OPTION_IGNORED_CODE,
679
+ $ as OPTIONS_GAINED_CODE,
680
+ O as OPTION_IGNORED_CODE,
539
681
  ORIGINAL_ID_COLUMN,
540
- V as PAIR_COLUMN,
682
+ ar as PAIR_COLUMN,
541
683
  P2 as PAJEK_ISSUE,
542
684
  a15 as PAJEK_LOSS,
543
- W as PARENTS_DROPPED_CODE,
544
- X as PARENT_CYCLE_CODE,
545
- Y as PARSE_ERROR_CODE,
546
- Z as PRECISION_CODE,
547
- _ as RENAMED_CODE,
548
- $ as ROLE_ASSUMED_CODE,
549
- a0 as ROLE_DROPPED_CODE,
550
- a1 as ROLE_TAKEN_CODE,
551
- a2 as SINK_OPTION_CODE,
685
+ ab as PARENTS_DROPPED_CODE,
686
+ h as PARENT_CYCLE_CODE,
687
+ as as PARSE_ERROR_CODE,
688
+ P as PRECISION_CODE,
689
+ at as RENAMED_CODE,
690
+ a6 as ROLE_ASSUMED_CODE,
691
+ ac as ROLE_DROPPED_CODE,
692
+ R as ROLE_TAKEN_CODE,
693
+ S as SINK_OPTION_CODE,
552
694
  SNIFF_HEAD_BYTES,
553
- a3 as STATUS_FAILED_CODE,
554
- a4 as STATUS_WARNING_CODE,
555
- a5 as STORAGE_CLASS_CODE,
556
- a6 as STRAY_TEXT_CODE,
557
- a7 as STYLES_NOT_IMPORTED_CODE,
558
- a8 as SYNTAX_CODE,
559
- a9 as TEMPORAL_DROPPED_CODE,
560
- aa as TEMPORAL_TEXT_DROPPED_CODE,
561
- ab as TEXT_INFERRED_CODE,
562
- ac as TOO_LARGE_CODE,
695
+ p as STATUS_FAILED_CODE,
696
+ o as STATUS_WARNING_CODE,
697
+ a3 as STORAGE_CLASS_CODE,
698
+ au as STRAY_TEXT_CODE,
699
+ g as STYLES_NOT_IMPORTED_CODE,
700
+ t as SYNTAX_CODE,
701
+ ae as TEMPORAL_DROPPED_CODE,
702
+ ad as TEMPORAL_TEXT_DROPPED_CODE,
703
+ a1 as TEXT_INFERRED_CODE,
704
+ T as TOO_LARGE_CODE,
563
705
  TYPE_COLUMN,
564
706
  T2 as TextCellWriter,
565
- ad as UNKNOWN_ATTR_TYPE_CODE,
566
- ae as UNKNOWN_ELEMENT_CODE,
567
- af as UNKNOWN_ENCODING_CODE,
707
+ k as UNKNOWN_ATTR_TYPE_CODE,
708
+ Y as UNKNOWN_ELEMENT_CODE,
709
+ q as UNKNOWN_ENCODING_CODE,
568
710
  UNKNOWN_FORMAT_CODE,
569
- ag as UNKNOWN_PARENT_CODE,
570
- ah as UNKNOWN_TYPE_CODE,
571
- ai as WEIGHT_KEY_CLASH_CODE,
572
- aj as WIDENED_CODE,
711
+ U as UNKNOWN_PARENT_CODE,
712
+ av as UNKNOWN_TYPE_CODE,
713
+ a7 as WEIGHT_KEY_CLASH_CODE,
714
+ W as WIDENED_CODE,
573
715
  W2 as WIDENING_UNSUPPORTED_CODE,
574
- ak as XML_ILLEGAL_CHAR_CODE,
575
- al as XML_SYNTAX_CODE,
576
- X2 as XmlSyntaxError,
577
- a19 as XmlTokenizer,
578
- am as canonicalId,
716
+ X2 as XGMML_ISSUE,
717
+ a16 as XGMML_LOSS,
718
+ a0 as XML_ILLEGAL_CHAR_CODE,
719
+ aw as XML_SYNTAX_CODE,
720
+ X3 as XmlSyntaxError,
721
+ b4 as XmlTokenizer,
722
+ ax as canonicalId,
579
723
  c3 as capabilities,
580
- a16 as checkCapabilities,
724
+ a17 as checkCapabilities,
581
725
  checkExport,
582
726
  c2 as childrenCsr,
583
727
  a10 as childrenFromColumn,
584
- an as chooseGraph,
585
- ao as coerceId,
586
- ap as coerceIdText,
587
- b3 as collectBytes,
728
+ H as chooseGraph,
729
+ ay as coerceId,
730
+ az as coerceIdText,
731
+ c5 as collectBytes,
588
732
  createRegistry,
589
733
  csvExporter,
590
734
  csvImporter,
591
735
  cx2Exporter,
592
736
  cx2Importer,
593
737
  cxImporter,
594
- aq as declareCompanion,
595
- ar as declareResolved,
596
- d3 as decodeChunks,
597
- as as decodeEntryName,
738
+ cysImporter,
739
+ aA as declareCompanion,
740
+ L as declareResolved,
741
+ d4 as decodeChunks,
742
+ aB as decodeEntryName,
598
743
  d2 as dialectCapabilities,
599
744
  dotExporter,
600
745
  dotImporter,
601
- e2 as encodeChunks,
602
- e3 as explicitWeights,
746
+ e3 as encodeChunks,
747
+ e2 as explicitWeights,
603
748
  exportGraph,
604
749
  exportGraphToString,
605
750
  f2 as extensionOf,
606
- f3 as formatDecimal,
607
- a17 as formatF32,
608
- b4 as formatF64,
751
+ b3 as formatDecimal,
752
+ f3 as formatF32,
753
+ a18 as formatF64,
609
754
  c4 as formatGmlReal,
610
- d4 as formatInteger,
755
+ d3 as formatInteger,
611
756
  gexfExporter,
612
757
  gexfImporter,
613
758
  gmlExporter,
@@ -619,12 +764,12 @@ export {
619
764
  importAllGraphs,
620
765
  importGraph,
621
766
  i4 as inferTextDtype,
622
- at as inputLength,
623
- au as isAbortError,
624
- av as isCanonicalIntegerText,
625
- aw as isImportInput,
767
+ aC as inputLength,
768
+ aD as isAbortError,
769
+ aE as isCanonicalIntegerText,
770
+ aF as isImportInput,
626
771
  i2 as isNmtoken,
627
- a18 as isNumericText,
772
+ a19 as isNumericText,
628
773
  i3 as isWeightField,
629
774
  j3 as joinText,
630
775
  j2 as jsonCapabilities,
@@ -636,26 +781,28 @@ export {
636
781
  neo4jImporter,
637
782
  n2 as normalizeMimeType,
638
783
  oboImporter,
639
- ax as pairFolding,
784
+ X as pairFolding,
640
785
  pajekExporter,
641
786
  pajekImporter,
642
787
  p3 as parseTextCell,
643
788
  p2 as parseWeightText,
644
789
  rankFormats,
645
- ay as readText,
790
+ aG as readText,
646
791
  registry,
647
- az as reportSinkOptions,
648
- aA as reportUnusedOptions,
649
- aB as resolveExportOptions,
650
- aC as resolveImportOptions,
792
+ F as reportSinkOptions,
793
+ z as reportUnusedOptions,
794
+ V as resolveExportOptions,
795
+ v as resolveImportOptions,
651
796
  s3 as sanitizeIds,
652
797
  sniff,
653
798
  s2 as sniffFormat,
654
799
  g2 as sniffJsonDialectHead,
655
- aD as textChunks,
800
+ x as textChunks,
656
801
  throwIfAborted,
657
- t as toReadableStream,
658
- t2 as tokenizeXml,
802
+ t2 as toReadableStream,
803
+ t3 as tokenizeXml,
804
+ xgmmlExporter,
805
+ xgmmlImporter,
659
806
  x2 as xmlIllegalTextNotes
660
807
  };
661
808
  //# sourceMappingURL=graph-io.js.map