Skip to content
Snippets Groups Projects
Commit 61929863 authored by Sören Henning's avatar Sören Henning
Browse files

fix bugs

parent ad7089c3
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
Pipeline #
......@@ -80,20 +80,21 @@ public class GraphImpl extends ElementImpl implements Graph {
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex) {
Stack<VertexImpl> outVertexParents = new Stack<>();
for (VertexImpl parent = ((VertexImpl) outVertex).graph.parentVertex; parent != null; parent = parent.graph.parentVertex) {
for (VertexImpl parent = (VertexImpl) outVertex; parent != null; parent = parent.graph.parentVertex) {
outVertexParents.push(parent);
}
Stack<VertexImpl> inVertexParents = new Stack<>();
for (VertexImpl parent = ((VertexImpl) inVertex).graph.parentVertex; parent != null; parent = parent.graph.parentVertex) {
for (VertexImpl parent = (VertexImpl) inVertex; parent != null; parent = parent.graph.parentVertex) {
inVertexParents.push(parent);
}
if (outVertexParents.pop() != inVertexParents.pop()) {
if (outVertexParents.peek().graph != inVertexParents.peek().graph) {
// throw exception TODO
throw new IllegalStateException();
}
GraphImpl firstEqualParent = this;
while (outVertexParents.peek() == inVertexParents.pop()) {
GraphImpl firstEqualParent = null;
while (!outVertexParents.isEmpty() && !inVertexParents.isEmpty() && outVertexParents.peek().graph == inVertexParents.pop().graph) {
firstEqualParent = outVertexParents.pop().graph;
}
return firstEqualParent.addEdgeChecked(id, outVertex, inVertex);
......
......@@ -21,7 +21,7 @@ class VertexImpl extends GraphElementImpl implements Vertex {
@Override
public Graph addChildGraph() {
this.childGraph = new GraphImpl();
this.childGraph = new GraphImpl(this);
return getChildGraph();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment