Search in sources :

Example 1 with EdgeListGraphSingleConnections

use of edu.cmu.tetrad.graph.EdgeListGraphSingleConnections in project tetrad by cmu-phil.

the class JsonUtils method parseJSONObjectToTetradGraph.

public static Graph parseJSONObjectToTetradGraph(JSONObject jObj) {
    // Node
    List<Node> nodes = parseJSONArrayToTetradNodes(jObj.getJSONArray("nodes"));
    EdgeListGraphSingleConnections graph = new EdgeListGraphSingleConnections(nodes);
    // Edge
    Set<Edge> edges = parseJSONArrayToTetradEdges(graph, jObj.getJSONArray("edgesSet"));
    for (Edge edge : edges) {
        graph.addEdge(edge);
    }
    // ambiguousTriples
    Set<Triple> ambiguousTriples = parseJSONArrayToTetradTriples(jObj.getJSONArray("ambiguousTriples"));
    for (Triple triple : ambiguousTriples) {
        graph.addAmbiguousTriple(triple.getX(), triple.getY(), triple.getZ());
    }
    // underLineTriples
    Set<Triple> underLineTriples = parseJSONArrayToTetradTriples(jObj.getJSONArray("underLineTriples"));
    for (Triple triple : underLineTriples) {
        graph.addUnderlineTriple(triple.getX(), triple.getY(), triple.getZ());
    }
    // dottedUnderLineTriples
    Set<Triple> dottedUnderLineTriples = parseJSONArrayToTetradTriples(jObj.getJSONArray("dottedUnderLineTriples"));
    for (Triple triple : dottedUnderLineTriples) {
        graph.addDottedUnderlineTriple(triple.getX(), triple.getY(), triple.getZ());
    }
    // stuffRemovedSinceLastTripleAccess
    boolean stuffRemovedSinceLastTripleAccess = jObj.getBoolean("stuffRemovedSinceLastTripleAccess");
    graph.setStuffRemovedSinceLastTripleAccess(stuffRemovedSinceLastTripleAccess);
    // highlightedEdges
    Set<Edge> highlightedEdges = parseJSONArrayToTetradEdges(graph, jObj.getJSONArray("highlightedEdges"));
    for (Edge edge : highlightedEdges) {
        graph.setHighlighted(edge, true);
    }
    return graph;
}
Also used : Triple(edu.cmu.tetrad.graph.Triple) GraphNode(edu.cmu.tetrad.graph.GraphNode) Node(edu.cmu.tetrad.graph.Node) EdgeListGraphSingleConnections(edu.cmu.tetrad.graph.EdgeListGraphSingleConnections) Edge(edu.cmu.tetrad.graph.Edge)

Example 2 with EdgeListGraphSingleConnections

use of edu.cmu.tetrad.graph.EdgeListGraphSingleConnections in project tetrad by cmu-phil.

the class MagToPag method convert.

public Graph convert() {
    logger.log("info", "Starting DAG to PAG_of_the_true_DAG.");
    setMaxPathLength(maxPathLength);
    Graph graph = new EdgeListGraphSingleConnections(mag);
    graph.reorientAllWith(Endpoint.CIRCLE);
    FciOrient fciOrient = new FciOrient(new DagSepsets(mag));
    fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed);
    return fciOrient.orient(graph);
}
Also used : Graph(edu.cmu.tetrad.graph.Graph) EdgeListGraphSingleConnections(edu.cmu.tetrad.graph.EdgeListGraphSingleConnections)

Aggregations

EdgeListGraphSingleConnections (edu.cmu.tetrad.graph.EdgeListGraphSingleConnections)2 Edge (edu.cmu.tetrad.graph.Edge)1 Graph (edu.cmu.tetrad.graph.Graph)1 GraphNode (edu.cmu.tetrad.graph.GraphNode)1 Node (edu.cmu.tetrad.graph.Node)1 Triple (edu.cmu.tetrad.graph.Triple)1