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

Add label to graph

parent e631980e
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
......@@ -6,6 +6,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
......@@ -13,7 +15,7 @@ import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import kieker.analysis.trace.traversal.NamedGraph;
import kieker.tools.traceAnalysis.filter.visualization.util.dot.DotFactory;
import kieker.analysis.util.DotBuilder;
import teetime.framework.AbstractConsumerStage;
......@@ -39,39 +41,25 @@ public class DotGraphWriter extends AbstractConsumerStage<NamedGraph> {
private String createDotGraph(final Graph graph) {
StringBuilder dotGraph = new StringBuilder();
DotBuilder dotGraph = new DotBuilder();
Map<String, String> nodeProperties = new HashMap<>();
nodeProperties.put("shape", "none");
dotGraph.setDefaultNodeProperties(nodeProperties);
dotGraph.append(createDotGraphHead());
for (Vertex vertex : graph.getVertices()) {
dotGraph.append(createDotGraphVertex(vertex));
String label = vertex.getProperty("label");
dotGraph.addNode(String.valueOf(vertex.getId()), label);
}
for (Edge edge : graph.getEdges()) {
dotGraph.append(createDotGraphEdge(edge));
String source = edge.getVertex(Direction.OUT).getId().toString();
String target = edge.getVertex(Direction.IN).getId().toString();
dotGraph.addEdge(source, target, edge.getLabel());
}
dotGraph.append(createDotGraphFoot());
return dotGraph.toString();
}
private String createDotGraphHead() {
return "digraph g {";
}
private String createDotGraphFoot() {
return "}";
}
// TODO Using DotFactory?
private String createDotGraphVertex(final Vertex vertex) {
return DotFactory.createNode("", String.valueOf(vertex.getId()), vertex.getProperty("label"),
null, null, null, null, null, 0, null, null, null).toString();
}
// TODO Using DotFactory?
private String createDotGraphEdge(final Edge edge) {
String source = edge.getVertex(Direction.OUT).getId().toString();
String target = edge.getVertex(Direction.IN).getId().toString();
return DotFactory.createConnection("", source, target, 0, 0);
return dotGraph.get();
}
private void writeDotGraphFile(final String dotGraph, final String fileName) throws IOException {
......
......@@ -27,7 +27,8 @@ public class AggrTraceToGraphTransformer extends AbstractTraceToGraphTransformer
return null;
}
return graph.addEdge(null, parentVertex, thisVertex, "");
// TODO Add label
return graph.addEdge(null, parentVertex, thisVertex, "ID");
}
}
......@@ -26,7 +26,8 @@ public class TraceToGraphTransformer extends AbstractTraceToGraphTransformer<Ope
return null;
}
return graph.addEdge(null, parentVertex, thisVertex, "");
// TODO Add label
return graph.addEdge(null, parentVertex, thisVertex, "ID");
}
}
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