diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html
index c6c65cd78..d7a5cee31 100644
--- a/cypress/platform/knsv.html
+++ b/cypress/platform/knsv.html
@@ -31,16 +31,18 @@ flowchart TD
subcontainer-child--> subcontainer-sibling
end
-
+
flowchart TB
- subgraph container_Beta
- process_C-->Process_D
- end
- subgraph container_Alpha
- process_A-->process_B
- process_A-->|messages|process_C
+ b-->B
+ a-->c
+ subgraph B
+ c
+ end
+ subgraph A
+ a
+ b
+ B
end
- process_B-->|via_AWSBatch|container_Beta
flowchart TB
diff --git a/src/diagrams/flowchart/flowDb.js b/src/diagrams/flowchart/flowDb.js
index ea591b1a0..a5e89a515 100644
--- a/src/diagrams/flowchart/flowDb.js
+++ b/src/diagrams/flowchart/flowDb.js
@@ -414,7 +414,6 @@ export const defaultStyle = function() {
* Clears the internal graph db so that a new graph can be parsed.
*/
export const addSubGraph = function(_id, list, _title) {
- // logger.warn('addSubgraph', _id, list, _title);
let id = _id.trim();
let title = _title;
if (_id === _title && _title.match(/\s/)) {
@@ -454,8 +453,25 @@ export const addSubGraph = function(_id, list, _title) {
subCount = subCount + 1;
const subGraph = { id: id, nodes: nodeList, title: title.trim(), classes: [] };
+ console.log('Adding', subGraph.id, subGraph.nodes);
+
+ /**
+ * Deletes an id from all subgraphs
+ */
+ // const del = _id => {
+ // subGraphs.forEach(sg => {
+ // const pos = sg.nodes.indexOf(_id);
+ // if (pos >= 0) {
+ // sg.nodes.splice(pos, 1);
+ // }
+ // });
+ // };
+
+ // // Removes the members of this subgraph from any other subgraphs, a node only belong to one subgraph
+ // subGraph.nodes.forEach(_id => del(_id));
+
// Remove the members in the new subgraph if they already belong to another subgraph
- subGraph.nodes.nodes = makeUniq(subGraph, subGraphs);
+ subGraph.nodes = makeUniq(subGraph, subGraphs).nodes;
subGraphs.push(subGraph);
subGraphLookup[id] = subGraph;
return id;
@@ -670,7 +686,6 @@ const exists = (allSgs, _id) => {
const makeUniq = (sg, allSubgraphs) => {
const res = [];
sg.nodes.forEach((_id, pos) => {
- console.log('Checking: ', _id);
if (!exists(allSubgraphs, _id)) {
res.push(sg.nodes[pos]);
}
diff --git a/src/diagrams/flowchart/parser/subgraph.spec.js b/src/diagrams/flowchart/parser/subgraph.spec.js
index 6a7fefb71..0c435a2c4 100644
--- a/src/diagrams/flowchart/parser/subgraph.spec.js
+++ b/src/diagrams/flowchart/parser/subgraph.spec.js
@@ -244,8 +244,9 @@ describe('when parsing subgraphs', function() {
const res = flow.parser.parse(`flowchart TB
subgraph A
b-->B
- a-->c
+ a
end
+ a-->c
subgraph B
c
end`);