Search in sources :

Example 1 with FruchtermanReingoldLayout

use of edu.cmu.tetrad.graph.FruchtermanReingoldLayout in project tetrad by cmu-phil.

the class TestFruchtermanReingoldLayout method testLayout2.

@Test
public void testLayout2() {
    Dag dag = new Dag();
    GraphNode x1 = new GraphNode("X1");
    GraphNode x2 = new GraphNode("X2");
    x1.setCenter(40, 5);
    x2.setCenter(50, 5);
    dag.addNode(x1);
    dag.addNode(x2);
    dag.addDirectedEdge(x1, x2);
    Dag dag2 = new Dag(dag);
    FruchtermanReingoldLayout layout = new FruchtermanReingoldLayout(dag);
    layout.doLayout();
    assertEquals(dag, dag2);
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Dag(edu.cmu.tetrad.graph.Dag) FruchtermanReingoldLayout(edu.cmu.tetrad.graph.FruchtermanReingoldLayout) Test(org.junit.Test)

Example 2 with FruchtermanReingoldLayout

use of edu.cmu.tetrad.graph.FruchtermanReingoldLayout in project tetrad by cmu-phil.

the class TestFruchtermanReingoldLayout method testLayout.

@Test
public void testLayout() {
    // Dag dag = DataGraphUtils.createRandomDag(40, 0, 80, 6, 6, 6, true);
    Dag dag = new Dag();
    GraphNode x1 = new GraphNode("X1");
    GraphNode x2 = new GraphNode("X2");
    GraphNode x3 = new GraphNode("X3");
    GraphNode x4 = new GraphNode("X4");
    GraphNode x5 = new GraphNode("X5");
    GraphNode x6 = new GraphNode("X6");
    GraphNode x7 = new GraphNode("X7");
    dag.addNode(x1);
    dag.addNode(x2);
    dag.addNode(x3);
    dag.addNode(x4);
    dag.addNode(x5);
    dag.addNode(x6);
    dag.addNode(x7);
    dag.addDirectedEdge(x1, x2);
    dag.addDirectedEdge(x2, x3);
    dag.addDirectedEdge(x4, x5);
    dag.addDirectedEdge(x5, x6);
    Dag dag2 = new Dag(dag);
    GraphUtils.circleLayout(dag, 200, 200, 150);
    FruchtermanReingoldLayout layout = new FruchtermanReingoldLayout(dag);
    layout.doLayout();
    assertEquals(dag, dag2);
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Dag(edu.cmu.tetrad.graph.Dag) FruchtermanReingoldLayout(edu.cmu.tetrad.graph.FruchtermanReingoldLayout) Test(org.junit.Test)

Aggregations

Dag (edu.cmu.tetrad.graph.Dag)2 FruchtermanReingoldLayout (edu.cmu.tetrad.graph.FruchtermanReingoldLayout)2 GraphNode (edu.cmu.tetrad.graph.GraphNode)2 Test (org.junit.Test)2