diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2020-04-18 15:09:39 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2020-04-18 15:09:39 +0100 |
commit | 08ce6c91fd37c904362a5ec6f054bcd3ee061b74 (patch) | |
tree | 02be7aa5059b9926a77c040480f3fd0346236120 /src/data | |
parent | 5ca0a2e48d0198102dabad4af5048a53e6938fe8 (diff) |
fixed pasting for paths
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/graph.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/data/graph.cpp b/src/data/graph.cpp index 979423e..74de24d 100644 --- a/src/data/graph.cpp +++ b/src/data/graph.cpp @@ -360,9 +360,33 @@ Graph *Graph::copyOfSubgraphWithNodes(QSet<Node *> nds) g->addNode(n1);
}
}
+
+ QMap<Edge*,Edge*> edgeTable;
foreach (Edge *e, edges()) {
if (nds.contains(e->source()) && nds.contains(e->target())) {
- g->addEdge(e->copy(&nodeTable));
+ Edge *e1 = e->copy(&nodeTable);
+ g->addEdge(e1);
+ edgeTable.insert(e,e1);
+ }
+ }
+
+ // add a copy of a path to the new graph if all of the edges are there
+ foreach (Path *p, paths()) {
+ bool allEdges = true;
+ Path *p1 = new Path();
+ foreach (Edge *e1, p->edges()) {
+ if (edgeTable.contains(e1)) {
+ p1->addEdge(edgeTable[e1]);
+ } else {
+ allEdges = false;
+ break;
+ }
+ }
+ if (allEdges) {
+ g->addPath(p1);
+ } else {
+ p1->removeEdges();
+ delete p1;
}
}
|