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

Merge branch 'Trace-Aggr-Analysis' into 'Trace-Aggr-Analysis-Graph-Migration'

Trace aggr analysis



See merge request !15
parents 8367aa2f ad7089c3
No related branches found
No related tags found
3 merge requests!17Get impletemented stages and Java 8,!16Trace aggr analysis graph migration,!15Trace aggr analysis
Pipeline #
...@@ -3,6 +3,7 @@ package kieker.analysis.graph.impl; ...@@ -3,6 +3,7 @@ package kieker.analysis.graph.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Stack;
import kieker.analysis.graph.Direction; import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge; import kieker.analysis.graph.Edge;
...@@ -18,8 +19,14 @@ public class GraphImpl extends ElementImpl implements Graph { ...@@ -18,8 +19,14 @@ public class GraphImpl extends ElementImpl implements Graph {
protected Long currentDefaultId = 0l; protected Long currentDefaultId = 0l;
protected VertexImpl parentVertex = null;
public GraphImpl() {} public GraphImpl() {}
protected GraphImpl(final VertexImpl parentVertex) {
this.parentVertex = parentVertex;
}
@Override @Override
public Vertex addVertex(final Object id) { public Vertex addVertex(final Object id) {
String idString = null; String idString = null;
...@@ -71,6 +78,28 @@ public class GraphImpl extends ElementImpl implements Graph { ...@@ -71,6 +78,28 @@ public class GraphImpl extends ElementImpl implements Graph {
@Override @Override
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex) { 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; String idString;
if (id == null) { if (id == null) {
do { do {
...@@ -83,12 +112,6 @@ public class GraphImpl extends ElementImpl implements Graph { ...@@ -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); final Edge edge = new EdgeImpl(idString, outVertex, inVertex, this);
this.edges.put(edge.getId().toString(), edge); this.edges.put(edge.getId().toString(), edge);
((VertexImpl) outVertex).addOutEdge(edge); ((VertexImpl) outVertex).addOutEdge(edge);
......
...@@ -40,7 +40,7 @@ public class DotGraphWriter { ...@@ -40,7 +40,7 @@ public class DotGraphWriter {
} else { } else {
openToken = DotGraph.DIRECTED_START_TOKEN; openToken = DotGraph.DIRECTED_START_TOKEN;
} }
writer.writeln(openToken + ' ' + name + ' ' + DotGraph.START_GRAPH_BRACKET); writer.writeln(openToken + ' ' + '"' + name + '"' + ' ' + DotGraph.START_GRAPH_BRACKET);
writer.indent(); writer.indent();
state = DotWriterState.STARTED; state = DotWriterState.STARTED;
} }
...@@ -115,7 +115,7 @@ public class DotGraphWriter { ...@@ -115,7 +115,7 @@ public class DotGraphWriter {
public void addSubgraphStart(final String name) throws IOException { public void addSubgraphStart(final String name) throws IOException {
checkState(DotWriterState.STARTED); checkState(DotWriterState.STARTED);
writer.writeln(DotGraph.SUB_START_TOKEN + ' ' + name + ' ' + DotGraph.START_GRAPH_BRACKET); writer.writeln(DotGraph.SUB_START_TOKEN + ' ' + '"' + name + '"' + ' ' + DotGraph.START_GRAPH_BRACKET);
writer.indent(); writer.indent();
openSubgraphs++; openSubgraphs++;
} }
......
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