/** Returns the pattern to which the given DAG belongs. */ public static Graph patternFromDag(Graph dag) { Graph graph = new EdgeListGraph(dag); SearchGraphUtils.basicPattern(graph); MeekRules rules = new MeekRules(); rules.orientImplied(graph); return graph; }
/** * Completes a pattern that was modified by an insertion/deletion operator Based on the algorithm * described on Appendix C of (Chickering, 2002). */ private void rebuildPattern(Graph graph) { SearchGraphUtils.basicPattern(graph, false); addRequiredEdges(graph); meekOrient(graph, getKnowledge()); if (TetradLogger.getInstance().isEventActive("rebuiltPatterns")) { TetradLogger.getInstance().log("rebuiltPatterns", "Rebuilt pattern = " + graph); } }
private Graph pickDag(Graph graph) { SearchGraphUtils.basicPattern(graph, false); addRequiredEdges(graph); boolean containsUndirected; do { containsUndirected = false; for (Edge edge : graph.getEdges()) { if (Edges.isUndirectedEdge(edge)) { containsUndirected = true; graph.removeEdge(edge); Edge _edge = Edges.directedEdge(edge.getNode1(), edge.getNode2()); graph.addEdge(_edge); } } meekOrient(graph, getKnowledge()); } while (containsUndirected); return graph; }