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

work on nested graph library

parent d3fa05f1
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
package kieker.analysis.graph;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
public class GraphTester {
public static void main(final String[] args) {
Graph graph1 = new TinkerGraph();
Graph graph2 = new TinkerGraph();
com.tinkerpop.blueprints.Vertex g1n1 = graph1.addVertex("g1::n1");
com.tinkerpop.blueprints.Vertex g2n1 = graph2.addVertex("g2::n1");
com.tinkerpop.blueprints.Edge edge = g1n1.addEdge("...", g2n1);
System.out.println(graph1);
System.out.println(graph2);
/*
* Graph graph = new GraphImpl();
*
* Vertex node1 = graph.addVertex("n1");
*
* Vertex node2 = graph.addVertex("n2");
*
* Graph subgraph = node1.addSubgraph();
*
* Vertex node11 = subgraph.addVertex("n1::n1");
*
* node2.addEdgeTo(node11);*
*
*/
}
}
......@@ -6,10 +6,14 @@ public interface Vertex extends Element {
public Graph getSubgraph();
public Graph addSubgraph();
// public Iterable<Edge> getEdges(Direction direction, String... labels);
// public Iterable<Vertex> getVertices(Direction direction, String... labels);
// public Edge addEdge(String label, Vertex inVertex);
public Edge addEdge(Vertex inVertex);
public Edge addEdge(Object id, Vertex inVertex);
}
package kieker.analysis.graph.impl;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Vertex;
class EdgeImpl extends ElementImpl implements Edge {
private final Vertex outVertex;
private final Vertex inVertex;
protected EdgeImpl(final String id, final Vertex outVertex, final Vertex inVertex, final GraphImpl graph) {
super(id, graph);
this.outVertex = outVertex;
this.inVertex = inVertex;
}
@Override
public void remove() {
this.graph.removeEdge(this);
}
// public Vertex getVertex(Direction direction) throws IllegalArgumentException;
}
......@@ -41,10 +41,7 @@ abstract class ElementImpl implements Element {
}
@Override
public void remove() {
// TODO Auto-generated method stub
}
abstract public void remove();
@Override
public Object getId() {
......
......@@ -33,7 +33,7 @@ public class GraphImpl implements Graph {
Vertex vertex = new VertexImpl(idString, this);
vertices.put(vertex.getId().toString(), vertex);
return null;
return vertex;
}
@Override
......@@ -72,7 +72,7 @@ public class GraphImpl implements Graph {
}
}
Edge edge = EdgeImpl(id, outVertex, inVertex, this);
Edge edge = new EdgeImpl(idString, outVertex, inVertex, this);
edges.put(edge.getId().toString(), edge);
// TODO Add Edge to vertices
......
package kieker.analysis.graph.impl;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
class VertexImpl extends ElementImpl implements Vertex {
protected VertexImpl(final String id, final GraphImpl graph) {
super(id, graph);
}
@Override
public Boolean hasSubgraph() {
// TODO Auto-generated method stub
......@@ -17,4 +22,24 @@ class VertexImpl extends ElementImpl implements Vertex {
return null;
}
@Override
public Graph addSubgraph() {
// TODO Auto-generated method stub
return null;
}
@Override
public Edge addEdge(final Vertex inVertex) {
return addEdge(null, inVertex);
}
@Override
public Edge addEdge(final Object id, final Vertex inVertex) {
return this.graph.addEdge(id, this, inVertex);
}
@Override
public void remove() {
graph.removeVertex(this);
}
}
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