@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.
- package/dist/chunks/{choose-DT5da6OC.js → choose-BJq_vp1b.js} +2 -2
- package/dist/chunks/{choose-DT5da6OC.js.map → choose-BJq_vp1b.js.map} +1 -1
- package/dist/chunks/{constants-DowRD9ai.js → constants-Bw-6JQuC.js} +2 -2
- package/dist/chunks/{constants-DowRD9ai.js.map → constants-Bw-6JQuC.js.map} +1 -1
- package/dist/chunks/{escape-DQC5HWqF.js → escape-CnTfa_y8.js} +2 -2
- package/dist/chunks/{escape-DQC5HWqF.js.map → escape-CnTfa_y8.js.map} +1 -1
- package/dist/chunks/{export-CVi12U7J.js → export-ZucVKiU4.js} +97 -91
- package/dist/chunks/{export-CVi12U7J.js.map → export-ZucVKiU4.js.map} +1 -1
- package/dist/chunks/{exporter-JubAlNWi.js → exporter-BOLJIzvA.js} +5 -5
- package/dist/chunks/exporter-BOLJIzvA.js.map +1 -0
- package/dist/chunks/{exporter-C3Pa2PSd.js → exporter-DRNkA2k0.js} +9 -10
- package/dist/chunks/exporter-DRNkA2k0.js.map +1 -0
- package/dist/chunks/{exporter-Cy_1da4c.js → exporter-DgDjwLOm.js} +7 -8
- package/dist/chunks/exporter-DgDjwLOm.js.map +1 -0
- package/dist/chunks/{exporter-CgsO2nSl.js → exporter-hc2ZuqVe.js} +8 -7
- package/dist/chunks/{exporter-CgsO2nSl.js.map → exporter-hc2ZuqVe.js.map} +1 -1
- package/dist/chunks/{importer-Dej72hIF.js → importer-BAlFKpHP.js} +10 -9
- package/dist/chunks/importer-BAlFKpHP.js.map +1 -0
- package/dist/chunks/{importer-CDXlxXlS.js → importer-ByCd2CAY.js} +11 -20
- package/dist/chunks/importer-ByCd2CAY.js.map +1 -0
- package/dist/chunks/{importer-lLH9gQF_.js → importer-CaLIrkjL.js} +10 -19
- package/dist/chunks/importer-CaLIrkjL.js.map +1 -0
- package/dist/chunks/{importer-q-R-Q98w.js → importer-D7xB8oVV.js} +4 -4
- package/dist/chunks/{importer-q-R-Q98w.js.map → importer-D7xB8oVV.js.map} +1 -1
- package/dist/chunks/{importer-DLz2Vb4q.js → importer-DsNj_zoG.js} +5 -5
- package/dist/chunks/importer-DsNj_zoG.js.map +1 -0
- package/dist/chunks/{importer-BA_hZKo7.js → importer-WPz-AUz8.js} +6 -6
- package/dist/chunks/importer-WPz-AUz8.js.map +1 -0
- package/dist/chunks/{importer-DVxzzibh.js → importer-rjFCmKfx.js} +5 -5
- package/dist/chunks/{importer-DVxzzibh.js.map → importer-rjFCmKfx.js.map} +1 -1
- package/dist/chunks/{json-elements-1IUzkRNy.js → json-elements-CkC87El2.js} +12 -16
- package/dist/chunks/{json-elements-1IUzkRNy.js.map → json-elements-CkC87El2.js.map} +1 -1
- package/dist/chunks/{ontology-export-b0GLNIj-.js → ontology-export-BRErBO6J.js} +11 -9
- package/dist/chunks/ontology-export-BRErBO6J.js.map +1 -0
- package/dist/chunks/{records-CdyqwXeY.js → records-DwfSjH8c.js} +2 -2
- package/dist/chunks/{records-CdyqwXeY.js.map → records-DwfSjH8c.js.map} +1 -1
- package/dist/chunks/{text-CDgjbkLC.js → text-BEEWD-G1.js} +2 -2
- package/dist/chunks/{text-CDgjbkLC.js.map → text-BEEWD-G1.js.map} +1 -1
- package/dist/csv.js +4 -4
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +1 -1
- package/dist/gexf.js +9 -8
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +3 -3
- package/dist/graph-io.js +69 -69
- package/dist/graphml.js +2 -2
- package/dist/json.js +1 -1
- package/dist/neo4j.js +3 -3
- package/dist/obo.js +1 -1
- package/dist/pajek.js +1 -1
- package/dist/src/common/export.d.ts +6 -1
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +18 -2
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/format.d.ts +0 -8
- package/dist/src/common/format.d.ts.map +1 -1
- package/dist/src/common/format.js +0 -10
- package/dist/src/common/format.js.map +1 -1
- package/dist/src/common/json-elements.d.ts +1 -9
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +2 -12
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/ontology-export.d.ts.map +1 -1
- package/dist/src/common/ontology-export.js +11 -15
- package/dist/src/common/ontology-export.js.map +1 -1
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +3 -3
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +2 -4
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +3 -3
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cys/exporter.d.ts.map +1 -1
- package/dist/src/formats/cys/exporter.js +4 -3
- package/dist/src/formats/cys/exporter.js.map +1 -1
- package/dist/src/formats/dot/exporter.js +1 -1
- package/dist/src/formats/dot/importer.d.ts +2 -2
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +7 -11
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/gexf/exporter.d.ts +2 -2
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +7 -5
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/schema.js +1 -1
- package/dist/src/formats/json/exporter.js +1 -1
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +4 -6
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/obo/exporter.d.ts +2 -2
- package/dist/src/formats/obo/exporter.js +2 -2
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +5 -4
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +3 -7
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/syntax.d.ts +1 -1
- package/dist/src/formats/pajek/syntax.js +1 -1
- package/dist/src/formats/xgmml/constants.d.ts +1 -1
- package/dist/src/formats/xgmml/constants.js +1 -1
- package/dist/src/formats/xgmml/emit.js +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +4 -3
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/xgmml.js +2 -2
- package/package.json +2 -2
- package/src/common/export.ts +25 -3
- package/src/common/format.ts +0 -11
- package/src/common/json-elements.ts +2 -13
- package/src/common/ontology-export.ts +12 -17
- package/src/formats/cx/importer.ts +2 -3
- package/src/formats/cx2/exporter.ts +2 -4
- package/src/formats/cx2/importer.ts +2 -3
- package/src/formats/cys/exporter.ts +4 -3
- package/src/formats/dot/exporter.ts +1 -1
- package/src/formats/dot/importer.ts +7 -17
- package/src/formats/gexf/exporter.ts +7 -5
- package/src/formats/gexf/schema.ts +1 -1
- package/src/formats/json/exporter.ts +1 -1
- package/src/formats/json/importer.ts +4 -7
- package/src/formats/obo/exporter.ts +2 -2
- package/src/formats/pajek/exporter.ts +5 -4
- package/src/formats/pajek/importer.ts +3 -13
- package/src/formats/pajek/syntax.ts +1 -1
- package/src/formats/xgmml/constants.ts +1 -1
- package/src/formats/xgmml/emit.ts +1 -1
- package/src/formats/xgmml/exporter.ts +4 -3
- package/dist/chunks/exporter-C3Pa2PSd.js.map +0 -1
- package/dist/chunks/exporter-Cy_1da4c.js.map +0 -1
- package/dist/chunks/exporter-JubAlNWi.js.map +0 -1
- package/dist/chunks/importer-BA_hZKo7.js.map +0 -1
- package/dist/chunks/importer-CDXlxXlS.js.map +0 -1
- package/dist/chunks/importer-DLz2Vb4q.js.map +0 -1
- package/dist/chunks/importer-Dej72hIF.js.map +0 -1
- package/dist/chunks/importer-lLH9gQF_.js.map +0 -1
- 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
|
-
*
|
|
154
|
-
*
|
|
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
|
-
|
|
590
|
-
const
|
|
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} ${
|
|
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:
|
|
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: "
|
|
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 (
|
|
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,
|
|
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 (
|
|
111
|
+
* The node position (f64 x3, role position, y up).
|
|
112
112
|
* @category Plugin helpers
|
|
113
113
|
*/
|
|
114
114
|
export const POSITION_COLUMN = "position";
|
|
@@ -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: "
|
|
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",
|
|
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",
|
|
993
|
+
out.push(["z", fmt(z)]);
|
|
993
994
|
}
|
|
994
995
|
}
|
|
995
996
|
}
|