Skip to content

Commit dba371d

Browse files
author
Marius Brill
committed
Fix bug in external node resolution
1 parent 9c8969f commit dba371d

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/processing/graph_generator.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ class GraphGenerator {
195195

196196
source = this._resolveSubstitute(source);
197197
target = this._resolveSubstitute(target);
198-
199198
if (source === target) {
200199
return undefined;
201200
}
@@ -362,8 +361,12 @@ class GraphGenerator {
362361
filteredGraph.nodes = _.filter(graph.nodes, (node) => {
363362
const id = node.data.id;
364363

365-
// don't filter connected elements
366-
if (_.some(graph.edges, { source: id }) || _.some(graph.edges, { target: id })) {
364+
// don't filter connected elements and parents
365+
if (
366+
_.some(graph.edges, { source: id }) ||
367+
_.some(graph.edges, { target: id }) ||
368+
node.data.type === EnGraphNodeType.PARENT
369+
) {
367370
return true;
368371
}
369372

@@ -390,7 +393,6 @@ class GraphGenerator {
390393
const nodes = this._createNodes(graphData);
391394

392395
const edges = this._createEdges(graphData);
393-
394396
const graph: IntGraph = {
395397
nodes,
396398
edges,

src/processing/node_substitutor.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ class NodeSubstitutor {
55
private _substitutionMap: any;
66

77
constructor() {
8-
this._substitutionMap = {};
8+
this._substitutionMap = new Map();
99
}
1010

1111
add(node: IntGraphNode) {
1212
const nameSpace = node.data.namespace;
1313
if (nameSpace && nameSpace.length > 0) {
14-
var currentValue = nameSpace.pop();
14+
var currentValue = nameSpace;
1515
var currentKey = node.data.label;
16-
this._substitutionMap[currentKey] = currentValue;
17-
while (nameSpace.length > 0) {
18-
currentKey = currentValue;
19-
currentValue = nameSpace.pop();
20-
this._substitutionMap[currentKey] = currentValue;
21-
}
16+
this._substitutionMap.set(currentKey, currentValue);
2217
}
2318
}
2419

2520
substituteUntilLayer(nodeName: string, layer: number, maxLayer: number) {
26-
var currentSubstitution = nodeName;
27-
for (let i = maxLayer; i > layer; i--) {
28-
currentSubstitution = this._substitutionMap[currentSubstitution];
21+
if (!this._substitutionMap.has(nodeName)) {
22+
return nodeName;
2923
}
30-
return currentSubstitution;
24+
const nameSpace = this._substitutionMap.get(nodeName);
25+
const nsLeng = nameSpace.length;
26+
if (nsLeng - 1 < layer) {
27+
return nodeName;
28+
}
29+
30+
return nameSpace[layer];
3131
}
3232
}
3333

0 commit comments

Comments
 (0)