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;
}
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));
}
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);
}
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();
}
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));
}
Aggregations