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

work on nested graph library

parent 67ad2f80
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
...@@ -27,6 +27,44 @@ public class GraphTester { ...@@ -27,6 +27,44 @@ public class GraphTester {
assert node1 == node1snd; assert node1 == node1snd;
System.out.println("Master graph");
for (Vertex vertex : graph.getVertices()) {
System.out.println(vertex.getId());
}
for (Edge edge : graph.getEdges()) {
System.out.println(edge.getId());
}
// BlueprintsExporter blueprintsExporter = new BlueprintsExporter(graph);
// System.out.println(blueprintsExporter.exportGraph());
node1snd.remove();
for (Vertex vertex : graph.getVertices()) {
System.out.println(vertex.getId());
}
node1.addChildGraph();
Vertex node1sub1 = node1.getChildGraph().addVertex("n1::s1");
Vertex node1sub2 = node1.getChildGraph().addVertex("n1::s2");
Vertex node1sub3 = node1.getChildGraph().addVertex("n1::s3");
node1sub3.addEdge("wormhole", node4);
System.out.println("Node 1's child graph");
for (Vertex vertex : node1.getChildGraph().getVertices()) {
System.out.println(vertex.getId());
}
for (Edge edge : node1.getChildGraph().getEdges()) {
System.out.println(edge.getId());
}
System.out.println("Master graph");
for (Vertex vertex : graph.getVertices()) { for (Vertex vertex : graph.getVertices()) {
System.out.println(vertex.getId()); System.out.println(vertex.getId());
} }
...@@ -37,6 +75,10 @@ public class GraphTester { ...@@ -37,6 +75,10 @@ public class GraphTester {
// node2.addEdgeTo(node11); // node2.addEdgeTo(node11);
// Export to Blueprints
// BlueprintsExporter blueprintsExporter = new BlueprintsExporter(graph);
// System.out.println(blueprintsExporter.exportGraph());
} }
} }
package kieker.analysis.graph;
public interface Subgraph {
}
...@@ -2,10 +2,12 @@ package kieker.analysis.graph; ...@@ -2,10 +2,12 @@ package kieker.analysis.graph;
public interface Vertex extends Element { public interface Vertex extends Element {
public Graph getChildGraph();
public Graph addChildGraph(); public Graph addChildGraph();
public boolean hasChildGraph();
public Graph getChildGraph();
public Iterable<Edge> getEdges(Direction direction); public Iterable<Edge> getEdges(Direction direction);
public Iterable<Vertex> getVertices(Direction direction); public Iterable<Vertex> getVertices(Direction direction);
......
...@@ -11,7 +11,7 @@ abstract class ElementImpl implements Element { ...@@ -11,7 +11,7 @@ abstract class ElementImpl implements Element {
protected Map<String, Object> properties = new HashMap<String, Object>(); protected Map<String, Object> properties = new HashMap<String, Object>();
protected final String id; protected final String id;
protected final GraphImpl graph; // TODO Maybe Graph as type? protected final GraphImpl graph;
protected ElementImpl(final String id, final GraphImpl graph) { protected ElementImpl(final String id, final GraphImpl graph) {
this.graph = graph; this.graph = graph;
......
...@@ -57,7 +57,10 @@ public class GraphImpl implements Graph { ...@@ -57,7 +57,10 @@ public class GraphImpl implements Graph {
throw ExceptionFactory.vertexWithIdDoesNotExist(vertex.getId()); throw ExceptionFactory.vertexWithIdDoesNotExist(vertex.getId());
} }
for (Edge edge : vertex.getEdges(Direction.BOTH)) { for (Edge edge : vertex.getEdges(Direction.IN)) {
this.removeEdge(edge);
}
for (Edge edge : vertex.getEdges(Direction.OUT)) {
this.removeEdge(edge); this.removeEdge(edge);
} }
......
...@@ -13,6 +13,7 @@ class VertexImpl extends ElementImpl implements Vertex { ...@@ -13,6 +13,7 @@ class VertexImpl extends ElementImpl implements Vertex {
protected Map<String, Edge> outEdges = new HashMap<String, Edge>(); protected Map<String, Edge> outEdges = new HashMap<String, Edge>();
protected Map<String, Edge> inEdges = new HashMap<String, Edge>(); protected Map<String, Edge> inEdges = new HashMap<String, Edge>();
private Graph childGraph;
protected VertexImpl(final String id, final GraphImpl graph) { protected VertexImpl(final String id, final GraphImpl graph) {
super(id, graph); super(id, graph);
...@@ -20,14 +21,18 @@ class VertexImpl extends ElementImpl implements Vertex { ...@@ -20,14 +21,18 @@ class VertexImpl extends ElementImpl implements Vertex {
@Override @Override
public Graph addChildGraph() { public Graph addChildGraph() {
// TODO Auto-generated method stub this.childGraph = new GraphImpl();
return null; return getChildGraph();
}
@Override
public boolean hasChildGraph() {
return (this.childGraph == null);
} }
@Override @Override
public Graph getChildGraph() { public Graph getChildGraph() {
// TODO Auto-generated method stub return childGraph;
return null;
} }
@Override @Override
......
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