@statelyai/graph 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +65 -15
  2. package/dist/{adjacency-list-CXpOCibq.mjs → adjacency-list-A4_Eiwj3.mjs} +1 -1
  3. package/dist/{algorithms-R35X6ro4.mjs → algorithms-DBU7nmIV.mjs} +83 -2
  4. package/dist/algorithms.d.mts +10 -2
  5. package/dist/algorithms.mjs +2 -2
  6. package/dist/converter-DnbeyE_p.mjs +33 -0
  7. package/dist/{edge-list-BRujEnnU.mjs → edge-list-DuHMz8hf.mjs} +1 -1
  8. package/dist/{adjacency-list-DW-lAUe8.d.mts → formats/adjacency-list/index.d.mts} +3 -3
  9. package/dist/formats/adjacency-list/index.mjs +3 -0
  10. package/dist/formats/converter/index.d.mts +27 -0
  11. package/dist/formats/converter/index.mjs +3 -0
  12. package/dist/formats/cytoscape/index.d.mts +35 -0
  13. package/dist/formats/cytoscape/index.mjs +87 -0
  14. package/dist/formats/d3/index.d.mts +22 -0
  15. package/dist/formats/d3/index.mjs +65 -0
  16. package/dist/formats/dot/index.d.mts +9 -0
  17. package/dist/formats/dot/index.mjs +235 -0
  18. package/dist/{edge-list-CJmfoNu2.d.mts → formats/edge-list/index.d.mts} +3 -3
  19. package/dist/formats/edge-list/index.mjs +3 -0
  20. package/dist/formats/gexf/index.d.mts +9 -0
  21. package/dist/formats/gexf/index.mjs +249 -0
  22. package/dist/formats/gml/index.d.mts +9 -0
  23. package/dist/formats/gml/index.mjs +236 -0
  24. package/dist/formats/graphml/index.d.mts +9 -0
  25. package/dist/{graphml-CUTNRXqd.mjs → formats/graphml/index.mjs} +18 -4
  26. package/dist/formats/jgf/index.d.mts +30 -0
  27. package/dist/formats/jgf/index.mjs +85 -0
  28. package/dist/formats/mermaid/index.d.mts +188 -0
  29. package/dist/formats/mermaid/index.mjs +1898 -0
  30. package/dist/formats/tgf/index.d.mts +9 -0
  31. package/dist/formats/tgf/index.mjs +67 -0
  32. package/dist/index.d.mts +14 -9
  33. package/dist/index.mjs +5 -9
  34. package/dist/queries.d.mts +78 -2
  35. package/dist/queries.mjs +121 -2
  36. package/dist/{types-XV3S5Jnh.d.mts → types-B6Tpeerk.d.mts} +36 -1
  37. package/package.json +43 -17
  38. package/dist/dot-BRtq3e3c.mjs +0 -59
  39. package/dist/dot-HmJeUMsj.d.mts +0 -6
  40. package/dist/formats/adjacency-list.d.mts +0 -2
  41. package/dist/formats/adjacency-list.mjs +0 -3
  42. package/dist/formats/dot.d.mts +0 -2
  43. package/dist/formats/dot.mjs +0 -3
  44. package/dist/formats/edge-list.d.mts +0 -2
  45. package/dist/formats/edge-list.mjs +0 -3
  46. package/dist/formats/graphml.d.mts +0 -2
  47. package/dist/formats/graphml.mjs +0 -3
  48. package/dist/graphml-CMjPzSfY.d.mts +0 -7
  49. /package/dist/{indexing-BHg1VhqN.mjs → indexing-BFFVMnjF.mjs} +0 -0
@@ -0,0 +1,235 @@
1
+ import { n as createFormatConverter } from "../../converter-DnbeyE_p.mjs";
2
+ import parse from "dotparser";
3
+
4
+ //#region src/formats/dot/index.ts
5
+ /** Escape a DOT identifier */
6
+ function escapeId(id) {
7
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(id)) return id;
8
+ return `"${id.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
9
+ }
10
+ /** Escape a DOT label string */
11
+ function escapeLabel(label) {
12
+ return label.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
13
+ }
14
+ const DIRECTION_TO_RANKDIR = {
15
+ down: "TB",
16
+ up: "BT",
17
+ right: "LR",
18
+ left: "RL"
19
+ };
20
+ const SHAPE_TO_DOT = {
21
+ rectangle: "box",
22
+ ellipse: "ellipse",
23
+ circle: "circle",
24
+ diamond: "diamond",
25
+ hexagon: "hexagon",
26
+ cylinder: "cylinder",
27
+ parallelogram: "parallelogram"
28
+ };
29
+ function toDOT(graph) {
30
+ const isDirected = graph.type === "directed";
31
+ const keyword = isDirected ? "digraph" : "graph";
32
+ const edgeOp = isDirected ? "->" : "--";
33
+ const lines = [];
34
+ lines.push(`${keyword} ${escapeId(graph.id)} {`);
35
+ if (graph.direction) {
36
+ const rankdir = DIRECTION_TO_RANKDIR[graph.direction] ?? "TB";
37
+ lines.push(` rankdir=${rankdir};`);
38
+ }
39
+ for (const node of graph.nodes) {
40
+ const attrs = [];
41
+ if (node.label) attrs.push(`label="${escapeLabel(node.label)}"`);
42
+ if (node.shape) {
43
+ const dotShape = SHAPE_TO_DOT[node.shape] ?? node.shape;
44
+ attrs.push(`shape=${dotShape}`);
45
+ }
46
+ if (node.color) attrs.push(`fillcolor="${escapeLabel(node.color)}" style=filled`);
47
+ if (attrs.length > 0) lines.push(` ${escapeId(node.id)} [${attrs.join(", ")}];`);
48
+ else lines.push(` ${escapeId(node.id)};`);
49
+ }
50
+ for (const edge of graph.edges) {
51
+ const attrs = [];
52
+ if (edge.label) attrs.push(`label="${escapeLabel(edge.label)}"`);
53
+ if (edge.color) attrs.push(`color="${escapeLabel(edge.color)}"`);
54
+ const attrStr = attrs.length > 0 ? ` [${attrs.join(", ")}]` : "";
55
+ lines.push(` ${escapeId(edge.sourceId)} ${edgeOp} ${escapeId(edge.targetId)}${attrStr};`);
56
+ }
57
+ lines.push("}");
58
+ return lines.join("\n");
59
+ }
60
+ const RANKDIR_TO_DIRECTION = {
61
+ TB: "down",
62
+ BT: "up",
63
+ LR: "right",
64
+ RL: "left"
65
+ };
66
+ const DOT_TO_SHAPE = {
67
+ box: "rectangle",
68
+ rect: "rectangle",
69
+ rectangle: "rectangle",
70
+ ellipse: "ellipse",
71
+ oval: "ellipse",
72
+ circle: "circle",
73
+ diamond: "diamond",
74
+ hexagon: "hexagon",
75
+ cylinder: "cylinder",
76
+ parallelogram: "parallelogram"
77
+ };
78
+ function attrsToMap(attrList) {
79
+ const map = {};
80
+ for (const a of attrList) map[a.id] = String(a.eq);
81
+ return map;
82
+ }
83
+ function nodeFromAttrs(id, attrs, defaults, parentId) {
84
+ const merged = {
85
+ ...defaults,
86
+ ...attrs
87
+ };
88
+ const label = merged["label"] ?? "";
89
+ const rawShape = merged["shape"];
90
+ const shape = rawShape ? DOT_TO_SHAPE[rawShape] ?? rawShape : void 0;
91
+ const color = merged["fillcolor"] ?? merged["color"] ?? void 0;
92
+ return {
93
+ type: "node",
94
+ id,
95
+ parentId,
96
+ initialNodeId: null,
97
+ label,
98
+ data: void 0,
99
+ ...shape && { shape },
100
+ ...color && { color }
101
+ };
102
+ }
103
+ function fromDOT(dot) {
104
+ if (typeof dot !== "string") throw new Error("DOT: expected a string");
105
+ if (!dot.trim()) throw new Error("DOT: input is empty");
106
+ let ast;
107
+ try {
108
+ ast = parse(dot);
109
+ } catch (e) {
110
+ throw new Error(`DOT: parse error — ${e.message}`);
111
+ }
112
+ if (!ast || ast.length === 0) throw new Error("DOT: no graph found");
113
+ const root = ast[0];
114
+ const isDirected = root.type === "digraph";
115
+ const nodeMap = /* @__PURE__ */ new Map();
116
+ const edges = [];
117
+ let edgeIdx = 0;
118
+ let direction;
119
+ function ensureNode(id, parentId, defaults) {
120
+ if (!nodeMap.has(id)) nodeMap.set(id, nodeFromAttrs(id, {}, defaults, parentId));
121
+ }
122
+ function getNodeIdsFromSubgraph(children) {
123
+ const ids = /* @__PURE__ */ new Set();
124
+ function collect(statements) {
125
+ for (const stmt of statements) switch (stmt.type) {
126
+ case "node_stmt":
127
+ ids.add(stmt.node_id.id);
128
+ break;
129
+ case "edge_stmt":
130
+ for (const item of stmt.edge_list) if (item.type === "node_id") ids.add(item.id);
131
+ else if (item.type === "subgraph") collect(item.children);
132
+ break;
133
+ case "subgraph":
134
+ collect(stmt.children);
135
+ break;
136
+ }
137
+ }
138
+ collect(children);
139
+ return [...ids];
140
+ }
141
+ function walkChildren(children, parentId, nodeDefaults, edgeDefaults) {
142
+ let nd = { ...nodeDefaults };
143
+ let ed = { ...edgeDefaults };
144
+ for (const stmt of children) switch (stmt.type) {
145
+ case "attr_stmt":
146
+ if (stmt.target === "node") nd = {
147
+ ...nd,
148
+ ...attrsToMap(stmt.attr_list)
149
+ };
150
+ else if (stmt.target === "edge") ed = {
151
+ ...ed,
152
+ ...attrsToMap(stmt.attr_list)
153
+ };
154
+ else if (stmt.target === "graph") {
155
+ const graphAttrs = attrsToMap(stmt.attr_list);
156
+ if (graphAttrs["rankdir"]) direction = RANKDIR_TO_DIRECTION[graphAttrs["rankdir"].toUpperCase()] ?? void 0;
157
+ }
158
+ break;
159
+ case "node_stmt": {
160
+ const id = stmt.node_id.id;
161
+ const node = nodeFromAttrs(id, attrsToMap(stmt.attr_list), nd, parentId);
162
+ nodeMap.set(id, node);
163
+ break;
164
+ }
165
+ case "edge_stmt": {
166
+ const edgeAttrs = attrsToMap(stmt.attr_list);
167
+ const mergedEdgeAttrs = {
168
+ ...ed,
169
+ ...edgeAttrs
170
+ };
171
+ const endpointGroups = [];
172
+ for (const item of stmt.edge_list) if (item.type === "node_id") {
173
+ ensureNode(item.id, parentId, nd);
174
+ endpointGroups.push([item.id]);
175
+ } else if (item.type === "subgraph") {
176
+ walkChildren(item.children, parentId, nd, ed);
177
+ const subNodeIds = getNodeIdsFromSubgraph(item.children);
178
+ for (const subNodeId of subNodeIds) ensureNode(subNodeId, parentId, nd);
179
+ if (subNodeIds.length > 0) endpointGroups.push(subNodeIds);
180
+ }
181
+ for (let i = 0; i < endpointGroups.length - 1; i++) {
182
+ const left = endpointGroups[i];
183
+ const right = endpointGroups[i + 1];
184
+ for (const sourceId of left) for (const targetId of right) {
185
+ const edge = {
186
+ type: "edge",
187
+ id: `e${edgeIdx++}`,
188
+ sourceId,
189
+ targetId,
190
+ label: mergedEdgeAttrs["label"] ?? "",
191
+ data: void 0,
192
+ ...mergedEdgeAttrs["color"] && { color: mergedEdgeAttrs["color"] }
193
+ };
194
+ edges.push(edge);
195
+ }
196
+ }
197
+ break;
198
+ }
199
+ case "subgraph": {
200
+ const subId = stmt.id ?? `subgraph_${nodeMap.size}`;
201
+ let subLabel = "";
202
+ for (const child of stmt.children) if (child.type === "attr_stmt" && child.target === "graph") {
203
+ const ga = attrsToMap(child.attr_list);
204
+ if (ga["label"]) subLabel = ga["label"];
205
+ }
206
+ const subNode = {
207
+ type: "node",
208
+ id: subId,
209
+ parentId,
210
+ initialNodeId: null,
211
+ label: subLabel,
212
+ data: void 0
213
+ };
214
+ nodeMap.set(subId, subNode);
215
+ walkChildren(stmt.children, subId, nd, ed);
216
+ break;
217
+ }
218
+ }
219
+ }
220
+ walkChildren(root.children, null, {}, {});
221
+ return {
222
+ id: root.id ?? "",
223
+ type: isDirected ? "directed" : "undirected",
224
+ initialNodeId: null,
225
+ nodes: [...nodeMap.values()],
226
+ edges,
227
+ data: void 0,
228
+ ...direction && { direction }
229
+ };
230
+ }
231
+ /** Bidirectional converter for DOT (Graphviz) format. */
232
+ const dotConverter = createFormatConverter(toDOT, fromDOT);
233
+
234
+ //#endregion
235
+ export { dotConverter, fromDOT, toDOT };
@@ -1,10 +1,10 @@
1
- import { c as Graph } from "./types-XV3S5Jnh.mjs";
1
+ import { c as Graph } from "../../types-B6Tpeerk.mjs";
2
2
 
3
- //#region src/formats/edge-list.d.ts
3
+ //#region src/formats/edge-list/index.d.ts
4
4
  declare function toEdgeList(graph: Graph): [string, string][];
5
5
  declare function fromEdgeList(edges: [string, string][], options?: {
6
6
  directed?: boolean;
7
7
  id?: string;
8
8
  }): Graph;
9
9
  //#endregion
10
- export { toEdgeList as n, fromEdgeList as t };
10
+ export { fromEdgeList, toEdgeList };
@@ -0,0 +1,3 @@
1
+ import { n as toEdgeList, t as fromEdgeList } from "../../edge-list-DuHMz8hf.mjs";
2
+
3
+ export { fromEdgeList, toEdgeList };
@@ -0,0 +1,9 @@
1
+ import { c as Graph, f as GraphFormatConverter } from "../../types-B6Tpeerk.mjs";
2
+
3
+ //#region src/formats/gexf/index.d.ts
4
+ declare function toGEXF(graph: Graph): string;
5
+ declare function fromGEXF(xml: string): Graph;
6
+ /** Bidirectional converter for GEXF (Graph Exchange XML Format). */
7
+ declare const gexfConverter: GraphFormatConverter<string>;
8
+ //#endregion
9
+ export { fromGEXF, gexfConverter, toGEXF };
@@ -0,0 +1,249 @@
1
+ import { n as createFormatConverter } from "../../converter-DnbeyE_p.mjs";
2
+ import { XMLBuilder, XMLParser } from "fast-xml-parser";
3
+
4
+ //#region src/formats/gexf/index.ts
5
+ function toGEXF(graph) {
6
+ const nodeAttrs = [
7
+ {
8
+ "@_id": "a_parentId",
9
+ "@_title": "parentId",
10
+ "@_type": "string"
11
+ },
12
+ {
13
+ "@_id": "a_initialNodeId",
14
+ "@_title": "initialNodeId",
15
+ "@_type": "string"
16
+ },
17
+ {
18
+ "@_id": "a_data",
19
+ "@_title": "data",
20
+ "@_type": "string"
21
+ },
22
+ {
23
+ "@_id": "a_shape",
24
+ "@_title": "shape",
25
+ "@_type": "string"
26
+ }
27
+ ];
28
+ const edgeAttrs = [{
29
+ "@_id": "a_edgeData",
30
+ "@_title": "data",
31
+ "@_type": "string"
32
+ }];
33
+ const nodes = graph.nodes.map((n) => {
34
+ const attvalues = [];
35
+ if (n.parentId !== null) attvalues.push({
36
+ "@_for": "a_parentId",
37
+ "@_value": n.parentId
38
+ });
39
+ if (n.initialNodeId !== null) attvalues.push({
40
+ "@_for": "a_initialNodeId",
41
+ "@_value": n.initialNodeId
42
+ });
43
+ if (n.data !== void 0) attvalues.push({
44
+ "@_for": "a_data",
45
+ "@_value": JSON.stringify(n.data)
46
+ });
47
+ if (n.shape) attvalues.push({
48
+ "@_for": "a_shape",
49
+ "@_value": n.shape
50
+ });
51
+ const node = {
52
+ "@_id": n.id,
53
+ "@_label": n.label || n.id
54
+ };
55
+ if (n.parentId !== null) node["@_pid"] = n.parentId;
56
+ if (attvalues.length > 0) node.attvalues = { attvalue: attvalues };
57
+ if (n.color) {
58
+ const hex$1 = n.color.replace("#", "");
59
+ if (hex$1.length === 6) node["viz:color"] = {
60
+ "@_r": parseInt(hex$1.slice(0, 2), 16),
61
+ "@_g": parseInt(hex$1.slice(2, 4), 16),
62
+ "@_b": parseInt(hex$1.slice(4, 6), 16)
63
+ };
64
+ }
65
+ if (n.x !== void 0 || n.y !== void 0) node["viz:position"] = {
66
+ "@_x": n.x ?? 0,
67
+ "@_y": n.y ?? 0
68
+ };
69
+ if (n.width !== void 0 || n.height !== void 0) node["viz:size"] = { "@_value": n.width ?? n.height ?? 0 };
70
+ return node;
71
+ });
72
+ const edges = graph.edges.map((e) => {
73
+ const edge = {
74
+ "@_id": e.id,
75
+ "@_source": e.sourceId,
76
+ "@_target": e.targetId
77
+ };
78
+ if (e.label) edge["@_label"] = e.label;
79
+ if (e.data !== void 0) edge.attvalues = { attvalue: [{
80
+ "@_for": "a_edgeData",
81
+ "@_value": JSON.stringify(e.data)
82
+ }] };
83
+ if (e.color) {
84
+ const hex$1 = e.color.replace("#", "");
85
+ if (hex$1.length === 6) edge["viz:color"] = {
86
+ "@_r": parseInt(hex$1.slice(0, 2), 16),
87
+ "@_g": parseInt(hex$1.slice(2, 4), 16),
88
+ "@_b": parseInt(hex$1.slice(4, 6), 16)
89
+ };
90
+ }
91
+ return edge;
92
+ });
93
+ const graphData = [];
94
+ if (graph.initialNodeId !== null) graphData.push({
95
+ "@_for": "a_initialNodeId",
96
+ "@_value": graph.initialNodeId
97
+ });
98
+ if (graph.data !== void 0) graphData.push({
99
+ "@_for": "a_data",
100
+ "@_value": JSON.stringify(graph.data)
101
+ });
102
+ const obj = {
103
+ "?xml": {
104
+ "@_version": "1.0",
105
+ "@_encoding": "UTF-8"
106
+ },
107
+ gexf: {
108
+ "@_xmlns": "http://gexf.net/1.3",
109
+ "@_xmlns:viz": "http://gexf.net/1.3/viz",
110
+ "@_version": "1.3",
111
+ graph: {
112
+ "@_defaultedgetype": graph.type === "directed" ? "directed" : "undirected",
113
+ ...graph.id && { "@_id": graph.id },
114
+ attributes: [{
115
+ "@_class": "node",
116
+ attribute: nodeAttrs
117
+ }, {
118
+ "@_class": "edge",
119
+ attribute: edgeAttrs
120
+ }],
121
+ nodes: { node: nodes },
122
+ edges: { edge: edges }
123
+ }
124
+ }
125
+ };
126
+ return new XMLBuilder({
127
+ ignoreAttributes: false,
128
+ format: true,
129
+ suppressEmptyNode: true
130
+ }).build(obj);
131
+ }
132
+ function fromGEXF(xml) {
133
+ if (typeof xml !== "string") throw new Error("GEXF: expected a string");
134
+ const parser = new XMLParser({
135
+ ignoreAttributes: false,
136
+ isArray: (name) => [
137
+ "node",
138
+ "edge",
139
+ "attribute",
140
+ "attvalue",
141
+ "attributes"
142
+ ].includes(name)
143
+ });
144
+ let parsed;
145
+ try {
146
+ parsed = parser.parse(xml);
147
+ } catch (e) {
148
+ throw new Error(`GEXF: invalid XML — ${e.message}`);
149
+ }
150
+ const gexf = parsed?.gexf;
151
+ if (!gexf) throw new Error("GEXF: missing <gexf> root element");
152
+ const graphEl = gexf.graph;
153
+ if (!graphEl) throw new Error("GEXF: missing <graph> element");
154
+ const graphType = graphEl["@_defaultedgetype"] === "undirected" ? "undirected" : "directed";
155
+ const attrMap = /* @__PURE__ */ new Map();
156
+ for (const block of asArray(graphEl.attributes)) for (const attr of asArray(block?.attribute)) if (attr?.["@_id"] && attr?.["@_title"]) attrMap.set(attr["@_id"], attr["@_title"]);
157
+ const nodes = [];
158
+ function parseNodes(nodeEls, parentId) {
159
+ for (const n of asArray(nodeEls)) {
160
+ const attvals = getAttValues(n, attrMap);
161
+ const id = String(n["@_id"]);
162
+ const node = {
163
+ type: "node",
164
+ id,
165
+ parentId: (n["@_pid"] != null ? String(n["@_pid"]) : null) ?? attvals["parentId"] ?? parentId,
166
+ initialNodeId: attvals["initialNodeId"] ?? null,
167
+ label: n["@_label"] ?? "",
168
+ data: attvals["data"] !== void 0 ? tryParseJSON(attvals["data"]) : void 0
169
+ };
170
+ if (attvals["shape"]) node.shape = attvals["shape"];
171
+ const pos = n["viz:position"];
172
+ if (pos) {
173
+ node.x = Number(pos["@_x"] ?? 0);
174
+ node.y = Number(pos["@_y"] ?? 0);
175
+ }
176
+ const size = n["viz:size"];
177
+ if (size) {
178
+ node.width = Number(size["@_value"] ?? 0);
179
+ node.height = Number(size["@_value"] ?? 0);
180
+ }
181
+ const color = n["viz:color"];
182
+ if (color) {
183
+ const r = Number(color["@_r"] ?? 0);
184
+ const g = Number(color["@_g"] ?? 0);
185
+ const b = Number(color["@_b"] ?? 0);
186
+ node.color = `#${hex(r)}${hex(g)}${hex(b)}`;
187
+ }
188
+ nodes.push(node);
189
+ const nested = n.nodes?.node ?? n.node;
190
+ if (nested) parseNodes(nested, id);
191
+ }
192
+ }
193
+ parseNodes(graphEl.nodes?.node ?? graphEl.node, null);
194
+ const edges = asArray(graphEl.edges?.edge ?? graphEl.edge).map((e, i) => {
195
+ const attvals = getAttValues(e, attrMap);
196
+ const edge = {
197
+ type: "edge",
198
+ id: String(e["@_id"] ?? `e${i}`),
199
+ sourceId: String(e["@_source"]),
200
+ targetId: String(e["@_target"]),
201
+ label: e["@_label"] ?? "",
202
+ data: attvals["data"] !== void 0 ? tryParseJSON(attvals["data"]) : void 0
203
+ };
204
+ const color = e["viz:color"];
205
+ if (color) {
206
+ const r = Number(color["@_r"] ?? 0);
207
+ const g = Number(color["@_g"] ?? 0);
208
+ const b = Number(color["@_b"] ?? 0);
209
+ edge.color = `#${hex(r)}${hex(g)}${hex(b)}`;
210
+ }
211
+ return edge;
212
+ });
213
+ return {
214
+ id: String(graphEl["@_id"] ?? ""),
215
+ type: graphType,
216
+ initialNodeId: null,
217
+ nodes,
218
+ edges,
219
+ data: void 0
220
+ };
221
+ }
222
+ function asArray(val) {
223
+ if (val === void 0) return [];
224
+ return Array.isArray(val) ? val : [val];
225
+ }
226
+ function getAttValues(el, attrMap) {
227
+ const result = {};
228
+ const attvalues = el?.attvalues?.attvalue;
229
+ for (const av of asArray(attvalues)) if (av?.["@_for"] != null) {
230
+ const title = attrMap.get(av["@_for"]) ?? av["@_for"];
231
+ result[title] = String(av["@_value"] ?? "");
232
+ }
233
+ return result;
234
+ }
235
+ function tryParseJSON(str) {
236
+ try {
237
+ return JSON.parse(str);
238
+ } catch {
239
+ return str;
240
+ }
241
+ }
242
+ function hex(n) {
243
+ return n.toString(16).padStart(2, "0");
244
+ }
245
+ /** Bidirectional converter for GEXF (Graph Exchange XML Format). */
246
+ const gexfConverter = createFormatConverter(toGEXF, fromGEXF);
247
+
248
+ //#endregion
249
+ export { fromGEXF, gexfConverter, toGEXF };
@@ -0,0 +1,9 @@
1
+ import { c as Graph, f as GraphFormatConverter } from "../../types-B6Tpeerk.mjs";
2
+
3
+ //#region src/formats/gml/index.d.ts
4
+ declare function toGML(graph: Graph): string;
5
+ declare function fromGML(gml: string): Graph;
6
+ /** Bidirectional converter for GML (Graph Modelling Language) format. */
7
+ declare const gmlConverter: GraphFormatConverter<string>;
8
+ //#endregion
9
+ export { fromGML, gmlConverter, toGML };