示例#1
0
  private void uncorrelationExogenousVariables() {
    Graph graph = getWorkbench().getGraph();

    Set<Edge> edges = graph.getEdges();

    for (Edge edge : edges) {
      if (Edges.isBidirectedEdge(edge)) {
        try {
          graph.removeEdge(edge);
        } catch (Exception e) {
          // Ignore.
        }
      }
    }
  }
示例#2
0
  private void correlateExogenousVariables() {
    Graph graph = getWorkbench().getGraph();

    if (graph instanceof Dag) {
      JOptionPane.showMessageDialog(
          JOptionUtils.centeringComp(), "Cannot add bidirected edges to DAG's.");
      return;
    }

    List<Node> nodes = graph.getNodes();

    List<Node> exoNodes = new LinkedList<Node>();

    for (int i = 0; i < nodes.size(); i++) {
      Node node = nodes.get(i);
      if (graph.isExogenous(node)) {
        exoNodes.add(node);
      }
    }

    for (int i = 0; i < exoNodes.size(); i++) {

      loop:
      for (int j = i + 1; j < exoNodes.size(); j++) {
        Node node1 = exoNodes.get(i);
        Node node2 = exoNodes.get(j);
        List<Edge> edges = graph.getEdges(node1, node2);

        for (int k = 0; k < edges.size(); k++) {
          Edge edge = edges.get(k);
          if (Edges.isBidirectedEdge(edge)) {
            continue loop;
          }
        }

        graph.addBidirectedEdge(node1, node2);
      }
    }
  }