diff --git a/src/main/java/kieker/analysis/graph/impl/GraphImpl.java b/src/main/java/kieker/analysis/graph/impl/GraphImpl.java
index 8fde724fc010c2c6611bb2f2e39628b9b67c8e26..8bb08ffe0a90f9012cfe8c1ed5ce3391fb6399c0 100644
--- a/src/main/java/kieker/analysis/graph/impl/GraphImpl.java
+++ b/src/main/java/kieker/analysis/graph/impl/GraphImpl.java
@@ -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);
diff --git a/src/main/java/kieker/analysis/graph/impl/VertexImpl.java b/src/main/java/kieker/analysis/graph/impl/VertexImpl.java
index 8d0b1de8e83d5f9a4e7e8abde802c6a275c5b9b4..74f9dac661eb719d5d9d236a6a6b2324777fdf21 100644
--- a/src/main/java/kieker/analysis/graph/impl/VertexImpl.java
+++ b/src/main/java/kieker/analysis/graph/impl/VertexImpl.java
@@ -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();
 	}