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

work on nested graph library

parent a5a953db
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
......@@ -5,6 +5,11 @@ package kieker.analysis;
import java.io.File;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
import teetime.framework.Execution;
/**
......@@ -21,6 +26,19 @@ public final class TraceAnalysis {
final Execution<TraceAnalysisConfiguration> analysis = new Execution<>(traceAnalysisConfiguration);
analysis.executeBlocking();
/*
*
*
*
* TODO
*/
Graph graph = new TinkerGraph();
Vertex vertex = graph.addVertex(101);
Edge edge = vertex.addEdge("Label", vertex);
}
}
......@@ -19,6 +19,16 @@ public class ComponentDependency {
components.put(componentCall.getIdentifier(), componentCall);
}
// TODO Better ->
// TODO Add method in OperationCall to receive the key/identifier
String componentKey = operationCall.getContainer() + ',' + operationCall.getComponent();
if (!components.containsKey(componentKey)) {
components.put(componentKey, new ComponentCall(operationCall));
}
// TODO Add data to this ComonentCall
}
public void addRelation(final OperationsDependencyRelation relation) {
......
......@@ -2,7 +2,7 @@ package kieker.analysis.graph.impl;
import kieker.analysis.graph.Edge;
class EdgeImp extends ElementImpl implements Edge {
class EdgeImpl extends ElementImpl implements Edge {
// public Vertex getVertex(Direction direction) throws IllegalArgumentException;
......
package kieker.analysis.graph.impl;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import kieker.analysis.graph.Element;
abstract class ElementImpl implements Element {
protected Map<String, Object> properties = new HashMap<String, Object>();
protected final String id;
protected final GraphImpl graph; // TODO Maybe Graph as type?
protected ElementImpl(final String id, final GraphImpl graph) {
this.graph = graph;
this.id = id;
}
@Override
@SuppressWarnings("unchecked")
public <T> T getProperty(final String key) {
// TODO Auto-generated method stub
return null;
return (T) this.properties.get(key);
}
@Override
public Set<String> getPropertyKeys() {
// TODO Auto-generated method stub
return null;
return new HashSet<String>(this.properties.keySet());
}
@Override
public void setProperty(final String key, final Object value) {
// TODO Auto-generated method stub
this.properties.put(key, value);
}
@Override
@SuppressWarnings("unchecked")
public <T> T removeProperty(final String key) {
// TODO Auto-generated method stub
return null;
return (T) this.properties.remove(key);
}
@Override
......@@ -38,8 +48,7 @@ abstract class ElementImpl implements Element {
@Override
public Object getId() {
// TODO Auto-generated method stub
return null;
return this.id;
}
}
......@@ -13,11 +13,26 @@ public class GraphImpl implements Graph {
protected Map<String, Vertex> vertices = new HashMap<String, Vertex>();
protected Map<String, Edge> edges = new HashMap<String, Edge>();
protected Long currentDefaultId = 0l;
public GraphImpl() {}
@Override
public Vertex addVertex(final Object id) {
// TODO Auto-generated method stub
String idString = null;
if (id == null) {
do {
idString = getDefaultId();
} while (vertices.containsKey(idString));
} else {
idString = id.toString();
if (vertices.containsKey(idString)) {
// TODO Throw Exception ExceptionFactory.vertexWithIdAlreadyExists(id)
}
}
Vertex vertex = new VertexImpl(idString, this);
vertices.put(vertex.getId().toString(), vertex);
return null;
}
......@@ -35,14 +50,34 @@ public class GraphImpl implements Graph {
@Override
public void removeVertex(final Vertex vertex) {
// TODO Auto-generated method stub
// TODO Check whether the vertex exists
// TODO Remove all edges
// TODO remove this vertex from map
}
@Override
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex) {
// TODO Auto-generated method stub
return null;
String idString = null;
if (id == null) {
do {
idString = getDefaultId();
} while (edges.containsKey(idString));
} else {
idString = id.toString();
if (edges.containsKey(idString)) {
// TODO Throw Exception ExceptionFactory.edgeWithIdAlreadyExists(id)
}
}
Edge edge = EdgeImpl(id, outVertex, inVertex, this);
edges.put(edge.getId().toString(), edge);
// TODO Add Edge to vertices
return edge;
}
@Override
......@@ -63,4 +98,13 @@ public class GraphImpl implements Graph {
}
private String getDefaultId() {
String idString;
do {
idString = currentDefaultId.toString();
currentDefaultId++;
} while (vertices.containsKey(idString) || edges.containsKey(idString));
return idString;
}
}
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