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

add Blueprints exporter

parent 15bd424f
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
package kieker.analysis.graph;
import java.util.HashMap;
import java.util.Map;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
public class BlueprintsExporter {
private final Graph graph;
private final com.tinkerpop.blueprints.Graph exportGraph = new TinkerGraph();
private final Map<Vertex, com.tinkerpop.blueprints.Vertex> mappedVertices = new HashMap<>();
public BlueprintsExporter(final Graph graph) {
this.graph = graph;
}
public com.tinkerpop.blueprints.Graph exportGraph() {
mapVertices();
mapEdges();
return exportGraph;
}
private void mapVertices() {
for (final Vertex vertex : graph.getVertices()) {
com.tinkerpop.blueprints.Vertex mappedVertex = exportGraph.addVertex(vertex.getId());
mappedVertices.put(vertex, mappedVertex);
for (final String propertyKey : vertex.getPropertyKeys()) {
mappedVertex.setProperty(propertyKey, vertex.getProperty(propertyKey));
}
}
}
private void mapEdges() {
for (final Edge edge : graph.getEdges()) {
final com.tinkerpop.blueprints.Vertex mappedInVertex = mappedVertices.get(edge.getVertex(Direction.IN));
final com.tinkerpop.blueprints.Vertex mappedOutVertex = mappedVertices.get(edge.getVertex(Direction.OUT));
String label = edge.getProperty("label");
if (label == null) {
label = "";
}
com.tinkerpop.blueprints.Edge mappedEdge = exportGraph.addEdge(edge.getId(), mappedOutVertex, mappedInVertex, label);
for (final String propertyKey : edge.getPropertyKeys()) {
mappedEdge.setProperty(propertyKey, edge.getProperty(propertyKey));
}
}
}
}
...@@ -76,8 +76,8 @@ public class GraphTester { ...@@ -76,8 +76,8 @@ public class GraphTester {
// node2.addEdgeTo(node11); // node2.addEdgeTo(node11);
// Export to Blueprints // Export to Blueprints
// BlueprintsExporter blueprintsExporter = new BlueprintsExporter(graph); BlueprintsExporter blueprintsExporter = new BlueprintsExporter(graph);
// System.out.println(blueprintsExporter.exportGraph()); System.out.println(blueprintsExporter.exportGraph());
} }
......
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