Search in sources :

Example 6 with GraphNode

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

the class TestCptInvariantUpdater method sampleBayesIm1.

private BayesIm sampleBayesIm1() {
    Node x = new GraphNode("x");
    Node z = new GraphNode("z");
    Dag graph = new Dag();
    graph.addNode(x);
    graph.addNode(z);
    graph.addDirectedEdge(x, z);
    BayesPm bayesPm = new BayesPm(graph);
    BayesIm bayesIm1 = new MlBayesIm(bayesPm);
    bayesIm1.setProbability(0, 0, 0, .3);
    bayesIm1.setProbability(0, 0, 1, .7);
    bayesIm1.setProbability(1, 0, 0, .8);
    bayesIm1.setProbability(1, 0, 1, .2);
    bayesIm1.setProbability(1, 1, 0, .4);
    bayesIm1.setProbability(1, 1, 1, .6);
    return bayesIm1;
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) GraphNode(edu.cmu.tetrad.graph.GraphNode) Dag(edu.cmu.tetrad.graph.Dag)

Example 7 with GraphNode

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

the class TestDag method checkAddRemoveNodes.

private void checkAddRemoveNodes(Dag graph) {
    Node x1 = new GraphNode("x1");
    Node x2 = new GraphNode("x2");
    Node x3 = new GraphNode("x3");
    Node x4 = new GraphNode("x4");
    Node x5 = new GraphNode("x5");
    graph.addNode(x1);
    graph.addNode(x2);
    graph.addNode(x3);
    graph.addNode(x4);
    graph.addNode(x5);
    graph.addDirectedEdge(x1, x2);
    graph.addDirectedEdge(x2, x3);
    graph.addDirectedEdge(x3, x4);
    graph.addDirectedEdge(x5, x4);
    List<Node> children = graph.getChildren(x1);
    List<Node> parents = graph.getParents(x4);
    assertTrue(children.contains(x2));
    assertTrue(parents.contains(x3));
    assertTrue(parents.contains(x5));
    assertTrue(graph.isDConnectedTo(x1, x3, Collections.EMPTY_LIST));
    assertTrue(graph.existsDirectedPathFromTo(x1, x4));
    assertTrue(!graph.existsDirectedPathFromTo(x1, x5));
    assertTrue(graph.isAncestorOf(x2, x4));
    assertTrue(!graph.isAncestorOf(x4, x2));
    assertTrue(graph.isDescendentOf(x4, x2));
    assertTrue(!graph.isDescendentOf(x2, x4));
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) GraphNode(edu.cmu.tetrad.graph.GraphNode)

Example 8 with GraphNode

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

the class Sextad method serializableInstance.

/**
 * Generates a simple exemplar of this class to test serialization.
 */
public static Sextad serializableInstance() {
    Node i = new GraphNode("i");
    Node j = new GraphNode("j");
    Node k = new GraphNode("k");
    Node l = new GraphNode("l");
    Node m = new GraphNode("m");
    Node n = new GraphNode("n");
    return new Sextad(i, j, k, l, m, n);
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) GraphNode(edu.cmu.tetrad.graph.GraphNode)

Example 9 with GraphNode

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

the class FgesDisplay method pasteSubsession.

public void pasteSubsession(List sessionElements, Point upperLeft) {
    getWorkbench().pasteSubgraph(sessionElements, upperLeft);
    getWorkbench().deselectAll();
    for (int i = 0; i < sessionElements.size(); i++) {
        Object o = sessionElements.get(i);
        if (o instanceof GraphNode) {
            Node modelNode = (Node) o;
            getWorkbench().selectNode(modelNode);
        }
    }
    getWorkbench().selectConnectingEdges();
}
Also used : GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) DisplayNode(edu.cmu.tetradapp.workbench.DisplayNode) GraphNode(edu.cmu.tetrad.graph.GraphNode)

Example 10 with GraphNode

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

the class TestIndependenceFacts method test1.

@Test
public void test1() {
    IndependenceFactsModel facts = new IndependenceFactsModel();
    Node x1 = new GraphNode("X1");
    Node x2 = new GraphNode("X2");
    Node x3 = new GraphNode("X3");
    Node x4 = new GraphNode("X4");
    Node x5 = new GraphNode("X5");
    Node x6 = new GraphNode("X6");
    facts.add(new IndependenceFact(x1, x2, x3));
    facts.add(new IndependenceFact(x2, x3));
    facts.add(new IndependenceFact(x2, x4, x1, x2));
    facts.add(new IndependenceFact(x2, x4, x1, x3, x5));
    facts.add(new IndependenceFact(x2, x4, x3));
    facts.add(new IndependenceFact(x2, x4, x3, x6));
    facts.remove(new IndependenceFact(x1, x2, x3));
    IndependenceFacts _facts = new IndependenceFacts(facts.getFacts());
    assertTrue(_facts.isIndependent(x4, x2, x1, x2));
    assertTrue(_facts.isIndependent(x4, x2, x5, x3, x1));
    List<Node> l = new ArrayList<>();
    l.add(x1);
    l.add(x2);
    assertTrue(_facts.isIndependent(x4, x2, l));
}
Also used : IndependenceFacts(edu.cmu.tetrad.data.IndependenceFacts) IndependenceFactsModel(edu.cmu.tetradapp.model.IndependenceFactsModel) GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) ArrayList(java.util.ArrayList) GraphNode(edu.cmu.tetrad.graph.GraphNode) IndependenceFact(edu.cmu.tetrad.graph.IndependenceFact) Test(org.junit.Test)

Aggregations

GraphNode (edu.cmu.tetrad.graph.GraphNode)41 Node (edu.cmu.tetrad.graph.Node)37 Dag (edu.cmu.tetrad.graph.Dag)20 Test (org.junit.Test)11 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)7 Graph (edu.cmu.tetrad.graph.Graph)7 DisplayNode (edu.cmu.tetradapp.workbench.DisplayNode)6 BayesIm (edu.cmu.tetrad.bayes.BayesIm)3 BayesPm (edu.cmu.tetrad.bayes.BayesPm)3 MlBayesIm (edu.cmu.tetrad.bayes.MlBayesIm)3 IndependenceFact (edu.cmu.tetrad.graph.IndependenceFact)3 ArrayList (java.util.ArrayList)3 FruchtermanReingoldLayout (edu.cmu.tetrad.graph.FruchtermanReingoldLayout)2 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)1 IndependenceFacts (edu.cmu.tetrad.data.IndependenceFacts)1 Endpoint (edu.cmu.tetrad.graph.Endpoint)1 SemGraph (edu.cmu.tetrad.graph.SemGraph)1 TimeLagGraph (edu.cmu.tetrad.graph.TimeLagGraph)1 IndependenceFactsModel (edu.cmu.tetradapp.model.IndependenceFactsModel)1 BufferedReader (java.io.BufferedReader)1