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

added getDepth to graph library

parent ba601cc9
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@ public interface Vertex extends GraphElement {
public void removeChildGraph();
public int getDepth();
public Iterable<Edge> getEdges(Direction direction);
public Iterable<Vertex> getVertices(Direction direction);
......
......@@ -40,6 +40,16 @@ class VertexImpl extends GraphElementImpl implements Vertex {
childGraph = null;
}
public int getDepth() {
int depth = 0;
GraphImpl graph = this.graph;
while (graph.parentVertex != null) {
graph = graph.parentVertex.graph;
depth++;
}
return depth;
}
@Override
public Iterable<Edge> getEdges(final Direction direction) {
if (direction.equals(Direction.OUT)) {
......
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