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

worked on #29

parent 206b4d17
No related branches found
No related tags found
3 merge requests!17Get impletemented stages and Java 8,!15Trace aggr analysis,!14worked on #29
Pipeline #
......@@ -3,6 +3,7 @@ package kieker.analysis.graph.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge;
......@@ -18,8 +19,14 @@ public class GraphImpl extends ElementImpl implements Graph {
protected Long currentDefaultId = 0l;
protected VertexImpl parentVertex = null;
public GraphImpl() {}
protected GraphImpl(final VertexImpl parentVertex) {
this.parentVertex = parentVertex;
}
@Override
public Vertex addVertex(final Object id) {
String idString = null;
......@@ -71,6 +78,28 @@ public class GraphImpl extends ElementImpl implements Graph {
@Override
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) {
outVertexParents.push(parent);
}
Stack<VertexImpl> inVertexParents = new Stack<>();
for (VertexImpl parent = ((VertexImpl) inVertex).graph.parentVertex; parent != null; parent = parent.graph.parentVertex) {
inVertexParents.push(parent);
}
if (outVertexParents.pop() != inVertexParents.pop()) {
// throw exception TODO
}
GraphImpl firstEqualParent = this;
while (outVertexParents.peek() == inVertexParents.pop()) {
firstEqualParent = outVertexParents.pop().graph;
}
return firstEqualParent.addEdgeChecked(id, outVertex, inVertex);
}
protected Edge addEdgeChecked(final Object id, final Vertex outVertex, final Vertex inVertex) {
String idString;
if (id == null) {
do {
......@@ -83,12 +112,6 @@ public class GraphImpl extends ElementImpl implements Graph {
}
}
// TODO Check whether both vertices have the same root graph
// TODO If not, don't add the edge and throw exception
// TODO Check whether both vertices are in the same graph
// TODO If not, add edge to the "higher" one
final Edge edge = new EdgeImpl(idString, outVertex, inVertex, this);
this.edges.put(edge.getId().toString(), edge);
((VertexImpl) outVertex).addOutEdge(edge);
......
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