@Test public void twoSeparateTreesToRoots() { final LayeredGraph graph = new LayeredGraph(Graphs.TwoSeparateTreesToRoots); final LongestPathVertexLayerer layerer = new LongestPathVertexLayerer(); layerer.createLayers(graph); final List<GraphLayer> result = graph.getLayers(); Assertions.assertThat(result.size()) .as("TwoSeparateTreesToRoots graph vertices should be placed into three layers") .isEqualTo(3); match(new String[]{"A1", "A2"}, result.get(2)); match(new String[]{"B1", "C1", "B2", "C2", "D2"}, result.get(1)); match(new String[]{"D1", "E1", "E2", "F2"}, result.get(0)); }
@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);  }