Search in sources :

Example 1 with FgesOrienter

use of edu.cmu.tetrad.search.FgesOrienter in project tetrad by cmu-phil.

the class Mmhc method search.

/**
 * Runs PC starting with a fully connected graph over all of the variables in the domain of the independence test.
 */
public Graph search() {
    List<Node> variables = independenceTest.getVariables();
    Mmmb mmmb = new Mmmb(independenceTest, getDepth(), true);
    Map<Node, List<Node>> pc = new HashMap<>();
    for (Node x : variables) {
        pc.put(x, mmmb.getPc(x));
    }
    Graph graph = new EdgeListGraph();
    for (Node x : variables) {
        graph.addNode(x);
    }
    for (Node x : variables) {
        for (Node y : pc.get(x)) {
            if (!graph.isAdjacentTo(x, y)) {
                graph.addUndirectedEdge(x, y);
            }
        }
    }
    FgesOrienter orienter = new FgesOrienter(data);
    orienter.orient(graph);
    return graph;
}
Also used : FgesOrienter(edu.cmu.tetrad.search.FgesOrienter) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) Graph(edu.cmu.tetrad.graph.Graph) HashMap(java.util.HashMap) Node(edu.cmu.tetrad.graph.Node) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) List(java.util.List)

Aggregations

EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)1 Graph (edu.cmu.tetrad.graph.Graph)1 Node (edu.cmu.tetrad.graph.Node)1 FgesOrienter (edu.cmu.tetrad.search.FgesOrienter)1 HashMap (java.util.HashMap)1 List (java.util.List)1