@Test public void simple4Layers() { final LayeredGraph graph = new LayeredGraph(); graph.addEdge("A", "B"); graph.addEdge("A", "C"); graph.addEdge("B", "F"); graph.addEdge("C", "E"); graph.addEdge("C", "G"); graph.addEdge("C", "H"); graph.addEdge("B", "I"); graph.addEdge("H", "I"); graph.addEdge("G", "I"); final LongestPathVertexLayerer layerer = new LongestPathVertexLayerer(); layerer.createLayers(graph); final List<GraphLayer> result = graph.getLayers(); assertEquals(4, result.size()); final GraphLayer layer01 = result.get(0); match(new String[]{"A"}, layer01); final GraphLayer layer02 = result.get(1); match(new String[]{"C"}, layer02); final GraphLayer layer03 = result.get(2); match(new String[]{"B", "G", "H"}, layer03); final GraphLayer layer04 = result.get(3); match(new String[]{"F", "I", "E"}, layer04); }
@Override public void createLayers(final ReorderedGraph graph) { this.graph = (LayeredGraph) graph; this.vertices = new Vertex[this.graph.getVertices().size()]; for (int i = 0; i < this.graph.getVertices().size(); i++) { final String v = this.graph.getVertices().get(i); this.vertices[i] = new Vertex(v); this.vertexHeight.put(v, -1); } for (final Vertex vertex : this.vertices) { visit(vertex); } }
LongestPathVertexLayerer implements VertexLayerer { @Override public void createLayers(final ReorderedGraph graph) { this.graph = (LayeredGraph) graph; this.vertices = new Vertex[this.graph.getVertices().size()]; for (int i = 0; i < this.graph.getVertices().size(); i++) { final String v = this.graph.getVertices().get(i); this.vertices[i] = new Vertex(v); this.vertexHeight.put(v, -1); } for (final Vertex vertex : this.vertices) { visit(vertex); } } }
LongestPathVertexLayerer implements VertexLayerer { @Override public void createLayers(final ReorderedGraph graph) { this.graph = (LayeredGraph) graph; this.vertices = new Vertex[this.graph.getVertices().size()]; for (int i = 0; i < this.graph.getVertices().size(); i++) { final String v = this.graph.getVertices().get(i); this.vertices[i] = new Vertex(v); this.vertexHeight.put(v, -1); } for (final Vertex vertex : this.vertices) { visit(vertex); } } LongestPathVertexLayerer(); }
LongestPathVertexLayerer implements VertexLayerer { @Override public void createLayers(final ReorderedGraph graph) { this.graph = (LayeredGraph) graph; this.vertices = new Vertex[this.graph.getVertices().size()]; for (int i = 0; i < this.graph.getVertices().size(); i++) { final String v = this.graph.getVertices().get(i); this.vertices[i] = new Vertex(v); this.vertexHeight.put(v, -1); } for (final Vertex vertex : this.vertices) { visit(vertex); } } LongestPathVertexLayerer(); @Override void createLayers(final ReorderedGraph graph); }
LongestPathVertexLayerer implements VertexLayerer { @Override public void createLayers(final ReorderedGraph graph) { this.graph = (LayeredGraph) graph; this.vertices = new Vertex[this.graph.getVertices().size()]; for (int i = 0; i < this.graph.getVertices().size(); i++) { final String v = this.graph.getVertices().get(i); this.vertices[i] = new Vertex(v); this.vertexHeight.put(v, -1); } for (final Vertex vertex : this.vertices) { visit(vertex); } } LongestPathVertexLayerer(); @Override void createLayers(final ReorderedGraph graph);  }