Search in sources :

Example 1 with ComponentsProcessor

use of org.eclipse.elk.alg.force.ComponentsProcessor in project elk by eclipse.

the class ForceImportTest method testDoNotSeparateConnectedComponents.

/**
 * Ensure that a single {@link FGraph} is imported if connected components shall not be split.
 */
@Test
public void testDoNotSeparateConnectedComponents() {
    ComponentsProcessor cp = new ComponentsProcessor();
    FGraph graph = createTwoComponentsGraph();
    graph.setProperty(ForceOptions.SEPARATE_CONNECTED_COMPONENTS, false);
    List<FGraph> graphs = cp.split(graph);
    assertThat(graphs.size(), is(1));
    FGraph fGraph = graphs.get(0);
    assertThat(fGraph.getNodes().size(), is(6));
    assertThat(fGraph.getEdges().size(), is(4));
    assertThat(fGraph.getLabels().size(), is(4));
}
Also used : FGraph(org.eclipse.elk.alg.force.graph.FGraph) ComponentsProcessor(org.eclipse.elk.alg.force.ComponentsProcessor) Test(org.junit.Test)

Example 2 with ComponentsProcessor

use of org.eclipse.elk.alg.force.ComponentsProcessor in project elk by eclipse.

the class ForceImportTest method testSeparateConnectedComponents.

/**
 * Ensure that connected components are split when desired.
 *
 * Also verifies that the split graphs have the correct number of nodes, edges, and labels.
 */
@Test
public void testSeparateConnectedComponents() {
    ComponentsProcessor cp = new ComponentsProcessor();
    FGraph graph = createTwoComponentsGraph();
    graph.setProperty(ForceOptions.SEPARATE_CONNECTED_COMPONENTS, true);
    List<FGraph> graphs = cp.split(graph);
    assertThat(graphs.size(), is(2));
    graphs.forEach(g -> checkSimpleGraph(g));
}
Also used : FGraph(org.eclipse.elk.alg.force.graph.FGraph) ComponentsProcessor(org.eclipse.elk.alg.force.ComponentsProcessor) Test(org.junit.Test)

Aggregations

ComponentsProcessor (org.eclipse.elk.alg.force.ComponentsProcessor)2 FGraph (org.eclipse.elk.alg.force.graph.FGraph)2 Test (org.junit.Test)2