gcyphrq-ext-graphml 0.1.1 → 0.1.3
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.
|
@@ -19,6 +19,15 @@ function graphologyToGraphInput(graph, edgeTypeProperty, labelProperty) {
|
|
|
19
19
|
const edges = [];
|
|
20
20
|
for (const id of graph.nodes()) {
|
|
21
21
|
const attrs = { ...graph.getNodeAttributes(id) };
|
|
22
|
+
// When a GraphML <key> element lacks attr.name, graphology-graphml stores
|
|
23
|
+
// the data under an empty string key (""). Remap it to the expected property,
|
|
24
|
+
// or discard it if the named property already exists.
|
|
25
|
+
if (attrs[''] !== undefined) {
|
|
26
|
+
if (attrs[labelProperty] === undefined) {
|
|
27
|
+
attrs[labelProperty] = attrs[''];
|
|
28
|
+
}
|
|
29
|
+
delete attrs[''];
|
|
30
|
+
}
|
|
22
31
|
// GraphML stores the node label in a "label" data element by default.
|
|
23
32
|
// If the user provided a custom labelProperty and the node doesn't
|
|
24
33
|
// already have that property, remap the attribute name.
|
|
@@ -39,6 +48,15 @@ function graphologyToGraphInput(graph, edgeTypeProperty, labelProperty) {
|
|
|
39
48
|
}
|
|
40
49
|
graph.forEachEdge((edgeId, attrs, source, target) => {
|
|
41
50
|
const edgeAttrs = { ...attrs };
|
|
51
|
+
// When a GraphML <key> element lacks attr.name, graphology-graphml stores
|
|
52
|
+
// the data under an empty string key (""). Remap it to the expected property,
|
|
53
|
+
// or discard it if the named property already exists.
|
|
54
|
+
if (edgeAttrs[''] !== undefined) {
|
|
55
|
+
if (edgeAttrs[edgeTypeProperty] === undefined) {
|
|
56
|
+
edgeAttrs[edgeTypeProperty] = edgeAttrs[''];
|
|
57
|
+
}
|
|
58
|
+
delete edgeAttrs[''];
|
|
59
|
+
}
|
|
42
60
|
// GraphML stores the relationship type in a "type" data element by default.
|
|
43
61
|
// If the user provided a custom edgeTypeProperty and the edge doesn't
|
|
44
62
|
// already have that property, we don't need to remap — the graphml parser
|
package/package.json
CHANGED
|
File without changes
|