@graphty/graph-io 0.3.29 → 0.3.31

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 (141) hide show
  1. package/dist/chunks/{choose-DT5da6OC.js → choose-BJq_vp1b.js} +2 -2
  2. package/dist/chunks/{choose-DT5da6OC.js.map → choose-BJq_vp1b.js.map} +1 -1
  3. package/dist/chunks/{constants-DowRD9ai.js → constants-Bw-6JQuC.js} +2 -2
  4. package/dist/chunks/{constants-DowRD9ai.js.map → constants-Bw-6JQuC.js.map} +1 -1
  5. package/dist/chunks/{escape-DQC5HWqF.js → escape-CnTfa_y8.js} +2 -2
  6. package/dist/chunks/{escape-DQC5HWqF.js.map → escape-CnTfa_y8.js.map} +1 -1
  7. package/dist/chunks/{export-CVi12U7J.js → export-ZucVKiU4.js} +97 -91
  8. package/dist/chunks/{export-CVi12U7J.js.map → export-ZucVKiU4.js.map} +1 -1
  9. package/dist/chunks/{exporter-JubAlNWi.js → exporter-BOLJIzvA.js} +5 -5
  10. package/dist/chunks/exporter-BOLJIzvA.js.map +1 -0
  11. package/dist/chunks/{exporter-C3Pa2PSd.js → exporter-DRNkA2k0.js} +9 -10
  12. package/dist/chunks/exporter-DRNkA2k0.js.map +1 -0
  13. package/dist/chunks/{exporter-Cy_1da4c.js → exporter-DgDjwLOm.js} +7 -8
  14. package/dist/chunks/exporter-DgDjwLOm.js.map +1 -0
  15. package/dist/chunks/{exporter-CgsO2nSl.js → exporter-hc2ZuqVe.js} +8 -7
  16. package/dist/chunks/{exporter-CgsO2nSl.js.map → exporter-hc2ZuqVe.js.map} +1 -1
  17. package/dist/chunks/{importer-Dej72hIF.js → importer-BAlFKpHP.js} +10 -9
  18. package/dist/chunks/importer-BAlFKpHP.js.map +1 -0
  19. package/dist/chunks/{importer-CDXlxXlS.js → importer-ByCd2CAY.js} +11 -20
  20. package/dist/chunks/importer-ByCd2CAY.js.map +1 -0
  21. package/dist/chunks/{importer-lLH9gQF_.js → importer-CaLIrkjL.js} +10 -19
  22. package/dist/chunks/importer-CaLIrkjL.js.map +1 -0
  23. package/dist/chunks/{importer-q-R-Q98w.js → importer-D7xB8oVV.js} +4 -4
  24. package/dist/chunks/{importer-q-R-Q98w.js.map → importer-D7xB8oVV.js.map} +1 -1
  25. package/dist/chunks/{importer-DLz2Vb4q.js → importer-DsNj_zoG.js} +5 -5
  26. package/dist/chunks/importer-DsNj_zoG.js.map +1 -0
  27. package/dist/chunks/{importer-BA_hZKo7.js → importer-WPz-AUz8.js} +6 -6
  28. package/dist/chunks/importer-WPz-AUz8.js.map +1 -0
  29. package/dist/chunks/{importer-DVxzzibh.js → importer-rjFCmKfx.js} +5 -5
  30. package/dist/chunks/{importer-DVxzzibh.js.map → importer-rjFCmKfx.js.map} +1 -1
  31. package/dist/chunks/{json-elements-1IUzkRNy.js → json-elements-CkC87El2.js} +12 -16
  32. package/dist/chunks/{json-elements-1IUzkRNy.js.map → json-elements-CkC87El2.js.map} +1 -1
  33. package/dist/chunks/{ontology-export-b0GLNIj-.js → ontology-export-BRErBO6J.js} +11 -9
  34. package/dist/chunks/ontology-export-BRErBO6J.js.map +1 -0
  35. package/dist/chunks/{records-CdyqwXeY.js → records-DwfSjH8c.js} +2 -2
  36. package/dist/chunks/{records-CdyqwXeY.js.map → records-DwfSjH8c.js.map} +1 -1
  37. package/dist/chunks/{text-CDgjbkLC.js → text-BEEWD-G1.js} +2 -2
  38. package/dist/chunks/{text-CDgjbkLC.js.map → text-BEEWD-G1.js.map} +1 -1
  39. package/dist/csv.js +4 -4
  40. package/dist/cx.js +1 -1
  41. package/dist/cx2.js +2 -2
  42. package/dist/cys.js +1 -1
  43. package/dist/dot.js +1 -1
  44. package/dist/gexf.js +9 -8
  45. package/dist/gexf.js.map +1 -1
  46. package/dist/gml.js +3 -3
  47. package/dist/graph-io.js +69 -69
  48. package/dist/graphml.js +2 -2
  49. package/dist/json.js +1 -1
  50. package/dist/neo4j.js +3 -3
  51. package/dist/obo.js +1 -1
  52. package/dist/pajek.js +1 -1
  53. package/dist/src/common/export.d.ts +6 -1
  54. package/dist/src/common/export.d.ts.map +1 -1
  55. package/dist/src/common/export.js +18 -2
  56. package/dist/src/common/export.js.map +1 -1
  57. package/dist/src/common/format.d.ts +0 -8
  58. package/dist/src/common/format.d.ts.map +1 -1
  59. package/dist/src/common/format.js +0 -10
  60. package/dist/src/common/format.js.map +1 -1
  61. package/dist/src/common/json-elements.d.ts +1 -9
  62. package/dist/src/common/json-elements.d.ts.map +1 -1
  63. package/dist/src/common/json-elements.js +2 -12
  64. package/dist/src/common/json-elements.js.map +1 -1
  65. package/dist/src/common/ontology-export.d.ts.map +1 -1
  66. package/dist/src/common/ontology-export.js +11 -15
  67. package/dist/src/common/ontology-export.js.map +1 -1
  68. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  69. package/dist/src/formats/cx/importer.js +3 -3
  70. package/dist/src/formats/cx/importer.js.map +1 -1
  71. package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
  72. package/dist/src/formats/cx2/exporter.js +2 -4
  73. package/dist/src/formats/cx2/exporter.js.map +1 -1
  74. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  75. package/dist/src/formats/cx2/importer.js +3 -3
  76. package/dist/src/formats/cx2/importer.js.map +1 -1
  77. package/dist/src/formats/cys/exporter.d.ts.map +1 -1
  78. package/dist/src/formats/cys/exporter.js +4 -3
  79. package/dist/src/formats/cys/exporter.js.map +1 -1
  80. package/dist/src/formats/dot/exporter.js +1 -1
  81. package/dist/src/formats/dot/importer.d.ts +2 -2
  82. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  83. package/dist/src/formats/dot/importer.js +7 -11
  84. package/dist/src/formats/dot/importer.js.map +1 -1
  85. package/dist/src/formats/gexf/exporter.d.ts +2 -2
  86. package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
  87. package/dist/src/formats/gexf/exporter.js +7 -5
  88. package/dist/src/formats/gexf/exporter.js.map +1 -1
  89. package/dist/src/formats/gexf/schema.js +1 -1
  90. package/dist/src/formats/json/exporter.js +1 -1
  91. package/dist/src/formats/json/importer.d.ts.map +1 -1
  92. package/dist/src/formats/json/importer.js +4 -6
  93. package/dist/src/formats/json/importer.js.map +1 -1
  94. package/dist/src/formats/obo/exporter.d.ts +2 -2
  95. package/dist/src/formats/obo/exporter.js +2 -2
  96. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  97. package/dist/src/formats/pajek/exporter.js +5 -4
  98. package/dist/src/formats/pajek/exporter.js.map +1 -1
  99. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  100. package/dist/src/formats/pajek/importer.js +3 -7
  101. package/dist/src/formats/pajek/importer.js.map +1 -1
  102. package/dist/src/formats/pajek/syntax.d.ts +1 -1
  103. package/dist/src/formats/pajek/syntax.js +1 -1
  104. package/dist/src/formats/xgmml/constants.d.ts +1 -1
  105. package/dist/src/formats/xgmml/constants.js +1 -1
  106. package/dist/src/formats/xgmml/emit.js +1 -1
  107. package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
  108. package/dist/src/formats/xgmml/exporter.js +4 -3
  109. package/dist/src/formats/xgmml/exporter.js.map +1 -1
  110. package/dist/xgmml.js +2 -2
  111. package/package.json +2 -2
  112. package/src/common/export.ts +25 -3
  113. package/src/common/format.ts +0 -11
  114. package/src/common/json-elements.ts +2 -13
  115. package/src/common/ontology-export.ts +12 -17
  116. package/src/formats/cx/importer.ts +2 -3
  117. package/src/formats/cx2/exporter.ts +2 -4
  118. package/src/formats/cx2/importer.ts +2 -3
  119. package/src/formats/cys/exporter.ts +4 -3
  120. package/src/formats/dot/exporter.ts +1 -1
  121. package/src/formats/dot/importer.ts +7 -17
  122. package/src/formats/gexf/exporter.ts +7 -5
  123. package/src/formats/gexf/schema.ts +1 -1
  124. package/src/formats/json/exporter.ts +1 -1
  125. package/src/formats/json/importer.ts +4 -7
  126. package/src/formats/obo/exporter.ts +2 -2
  127. package/src/formats/pajek/exporter.ts +5 -4
  128. package/src/formats/pajek/importer.ts +3 -13
  129. package/src/formats/pajek/syntax.ts +1 -1
  130. package/src/formats/xgmml/constants.ts +1 -1
  131. package/src/formats/xgmml/emit.ts +1 -1
  132. package/src/formats/xgmml/exporter.ts +4 -3
  133. package/dist/chunks/exporter-C3Pa2PSd.js.map +0 -1
  134. package/dist/chunks/exporter-Cy_1da4c.js.map +0 -1
  135. package/dist/chunks/exporter-JubAlNWi.js.map +0 -1
  136. package/dist/chunks/importer-BA_hZKo7.js.map +0 -1
  137. package/dist/chunks/importer-CDXlxXlS.js.map +0 -1
  138. package/dist/chunks/importer-DLz2Vb4q.js.map +0 -1
  139. package/dist/chunks/importer-Dej72hIF.js.map +0 -1
  140. package/dist/chunks/importer-lLH9gQF_.js.map +0 -1
  141. package/dist/chunks/ontology-export-b0GLNIj-.js.map +0 -1
@@ -150,8 +150,8 @@ export const OBO_LOSS = Object.freeze({
150
150
  */
151
151
  ROLE_ASSUMED: ROLE_ASSUMED_CODE,
152
152
  /**
153
- * An attribute with a role (for example, the label) is written where the format keeps that role, and reads back under the
154
- * name the format's importer gives it.
153
+ * The node label column is written as each node's `name` and reads back as the column `name`. An edge label has no slot:
154
+ * it is written as a qualifier (W_ROLE_DROPPED and W_OBO_EDGE_COLUMN_AS_QUALIFIER), never under a new name.
155
155
  */
156
156
  COLUMN_NAME_CHANGED: LOSS.COLUMN_NAME_CHANGED,
157
157
  /**
@@ -17,7 +17,7 @@ import { type Column, GraphFormatError, type GraphSnapshot } from "@graphty/grap
17
17
  import { pairFolding } from "../../common/direction.js";
18
18
  import { isPajekLabel, quotePajekLabel } from "../../common/escape.js";
19
19
  import { capabilities, checkCapabilities, LOSS, type SanitizedIds, sanitizeIds } from "../../common/export.js";
20
- import { formatDecimal, formatF32, formatInteger, idText } from "../../common/format.js";
20
+ import { formatDecimal, formatF32, formatInteger, formatNumber, idText } from "../../common/format.js";
21
21
  import { canonicalId } from "../../common/ids.js";
22
22
  import { resolveExportOptions } from "../../common/options.js";
23
23
  import { agree, plural } from "../../common/plural.js";
@@ -586,10 +586,11 @@ function coordinatesText(column: Column, i: number, writeZ: boolean): string | n
586
586
  }
587
587
  const dtype = column.dtype as "f32" | "f64" | "i32" | "u32" | "u8";
588
588
  const vector = column.value(i) as ArrayLike<number>;
589
- const x = numberText(vector[0], dtype);
590
- const y = numberText(vector[1], dtype);
589
+ // the importer reads coordinates by position, so the shortest text of each is enough
590
+ const x = formatNumber(vector[0], dtype);
591
+ const y = formatNumber(vector[1], dtype);
591
592
  if (column.meta.components === 3 && writeZ) {
592
- return `${x} ${y} ${numberText(vector[2], dtype)}`;
593
+ return `${x} ${y} ${formatNumber(vector[2], dtype)}`;
593
594
  }
594
595
  return `${x} ${y}`;
595
596
  }
@@ -46,7 +46,6 @@ import {
46
46
  UNKNOWN_ENCODING_CODE,
47
47
  } from "../../common/codes.js";
48
48
  import { DirectionResolver, type EdgeKind } from "../../common/direction.js";
49
- import { survivesF32 } from "../../common/format.js";
50
49
  import { coerceIdText, ID_MERGED_CODE, IdCoercer } from "../../common/ids.js";
51
50
  import { LineReader, throwIfAborted } from "../../common/input.js";
52
51
  import {
@@ -292,14 +291,14 @@ function spellsDecl(): ColumnDecl {
292
291
  }
293
292
 
294
293
  /**
295
- * The position column declaration (design section 5.2: f32 x 3, role position, units "file").
294
+ * The position column declaration (design section 5.2: f64 x 3, role position, units "file").
296
295
  * @param sourceDims - 2 or 3, the coordinate count of the first vertex line with coordinates
297
296
  * @returns a fresh declaration
298
297
  */
299
298
  function positionDecl(sourceDims: number): ColumnDecl {
300
299
  return {
301
300
  name: POSITION_COLUMN,
302
- dtype: "f32",
301
+ dtype: "f64",
303
302
  components: 3,
304
303
  nullable: true,
305
304
  role: "position",
@@ -1183,7 +1182,7 @@ class PajekParser {
1183
1182
  }
1184
1183
 
1185
1184
  /**
1186
- * Write a vertex's coordinates into the position column (f32 x 3), declared on first use.
1185
+ * Write a vertex's coordinates into the position column (f64 x 3), declared on first use.
1187
1186
  * @param index - the node index
1188
1187
  * @param dims - 2 or 3, the coordinates the line gave
1189
1188
  * @param point - x, y, z (0 when absent)
@@ -1202,15 +1201,6 @@ class PajekParser {
1202
1201
  { line, element: String(k) },
1203
1202
  );
1204
1203
  }
1205
- if (!point.every(survivesF32)) {
1206
- this.report.warnOnce(
1207
- "precision",
1208
- PAJEK_ISSUE.PRECISION,
1209
- `vertex ${k} has a coordinate the f32 position column rounds (warned once)`,
1210
- { line, element: String(k) },
1211
- `${PAJEK_ISSUE.PRECISION}:position`,
1212
- );
1213
- }
1214
1204
  this.sink.setNodeValue(this.positionHandle, index, point);
1215
1205
  }
1216
1206
 
@@ -15,7 +15,7 @@
15
15
  export const LABEL_COLUMN = "label";
16
16
 
17
17
  /**
18
- * The node column holding the vertex coordinates (role position, f32 x 3, units "file").
18
+ * The node column holding the vertex coordinates (role position, f64 x 3, units "file").
19
19
  * @category Plugin helpers
20
20
  */
21
21
  export const POSITION_COLUMN = "position";
@@ -108,7 +108,7 @@ export const LABEL_COLUMN = "label";
108
108
  export const EDGE_ID_COLUMN = "id";
109
109
 
110
110
  /**
111
- * The node position (f32 x3, role position, y up).
111
+ * The node position (f64 x3, role position, y up).
112
112
  * @category Plugin helpers
113
113
  */
114
114
  export const POSITION_COLUMN = "position";
@@ -1430,7 +1430,7 @@ class Positions {
1430
1430
  if (this.values.size > 0) {
1431
1431
  const handle = this.emitter.declare("node", {
1432
1432
  name: POSITION_COLUMN,
1433
- dtype: "f32",
1433
+ dtype: "f64",
1434
1434
  components: 3,
1435
1435
  role: "position",
1436
1436
  nullable: true,
@@ -538,7 +538,7 @@ function planExport(snapshot: GraphSnapshot, options: ResolvedExportOptions, esc
538
538
  const notes = checkCapabilities(snapshot, CAPABILITIES, options, {
539
539
  roles: SLOT_ROLES,
540
540
  roleNames: ROLE_NAMES,
541
- positionDtype: "f32",
541
+ positionDtype: "f64",
542
542
  }).filter((n) => n.code !== LOSS.JSON);
543
543
  const note: NoteFn = (code, message, column = null, count = null): void => {
544
544
  notes.push(Object.freeze({ code, message, column, count }));
@@ -986,10 +986,11 @@ function coordsOf(plan: Plan, zColumn: Column | null, node: number): [string, st
986
986
  const xyz = cellOf(plan.position, node);
987
987
  if (xyz !== null) {
988
988
  const [x, y, z] = Array.from(xyz as ArrayLike<number>);
989
+ const fmt = plan.position?.dtype === "f32" ? formatF32 : formatF64;
989
990
  if (Number.isFinite(x) && Number.isFinite(y)) {
990
- out.push(["x", formatF32(x)], ["y", formatF32(y === 0 ? 0 : -y)]);
991
+ out.push(["x", fmt(x)], ["y", fmt(y === 0 ? 0 : -y)]);
991
992
  if (zColumn === null && z !== undefined && z !== 0 && Number.isFinite(z)) {
992
- out.push(["z", formatF32(z)]);
993
+ out.push(["z", fmt(z)]);
993
994
  }
994
995
  }
995
996
  }