示例#1
0
文件: Lofs.java 项目: jdramsey/tetrad
  public Graph orient() {
    Graph skeleton = GraphUtils.undirectedGraph(getPattern());
    Graph graph = new EdgeListGraph(skeleton.getNodes());

    List<Node> nodes = skeleton.getNodes();
    //        Collections.shuffle(nodes);

    if (isR1Done()) {
      ruleR1(skeleton, graph, nodes);
    }

    for (Edge edge : skeleton.getEdges()) {
      if (!graph.isAdjacentTo(edge.getNode1(), edge.getNode2())) {
        graph.addUndirectedEdge(edge.getNode1(), edge.getNode2());
      }
    }

    if (isR2Done()) {
      ruleR2(skeleton, graph);
    }

    if (isMeekDone()) {
      new MeekRules().orientImplied(graph);
    }

    return graph;
  }
示例#2
0
文件: PcMax.java 项目: renjiey/tetrad
 public Set<Edge> getNonadjacencies() {
   Graph complete = GraphUtils.completeGraph(graph);
   Set<Edge> nonAdjacencies = complete.getEdges();
   Graph undirected = GraphUtils.undirectedGraph(graph);
   nonAdjacencies.removeAll(undirected.getEdges());
   return new HashSet<Edge>(nonAdjacencies);
 }
  public static List<Dag> getAllDagsInUndirectedGraph(Graph graph) {
    Graph undirected = GraphUtils.undirectedGraph(graph);

    DagIterator iterator = new DagIterator(undirected);
    List<Dag> dags = new ArrayList<Dag>();

    while (iterator.hasNext()) {
      Graph _graph = iterator.next();

      try {
        Dag dag = new Dag(_graph);
        dags.add(dag);
      } catch (IllegalArgumentException e) {
        //
      }
    }

    return dags;
  }