Class Edges

java.lang.Object
edu.cmu.tetrad.graph.Edges

public final class Edges extends Object
This factory class produces edges of the types commonly used for Tetrad-style graphs. For each method in the class, one supplies a pair of nodes, and an edge is returned, connecting those nodes, of the specified type. Methods are also included to help determine whether a specified edge falls into one of the types produced by this factory. It's entirely possible to produce edges of these types other than by using this factory. For randomUtil, an edge counts as a directed edge just in case it has one null endpoint and one arrow endpoint. Any edge which has one null endpoint and one arrow endpoint will do, whether or not this factory produced it. These helper methods provide a uniform way of testing whether an edge is in fact, e.g., a directed edge (or any of the other types).
Author:
josephramsey
  • Constructor Details

    • Edges

      public Edges()
  • Method Details

    • bidirectedEdge

      public static Edge bidirectedEdge(Node nodeA, Node nodeB)
      Constructs a new bidirected edge from nodeA to nodeB (<->).
    • directedEdge

      public static Edge directedEdge(Node nodeA, Node nodeB)
      Constructs a new directed edge from nodeA to nodeB (-->).
    • partiallyOrientedEdge

      public static Edge partiallyOrientedEdge(Node nodeA, Node nodeB)
      Constructs a new partially oriented edge from nodeA to nodeB (o->).
    • nondirectedEdge

      public static Edge nondirectedEdge(Node nodeA, Node nodeB)
      Constructs a new nondirected edge from nodeA to nodeB (o-o).
    • undirectedEdge

      public static Edge undirectedEdge(Node nodeA, Node nodeB)
      Constructs a new undirected edge from nodeA to nodeB (--).
    • isBidirectedEdge

      public static boolean isBidirectedEdge(Edge edge)
      Returns:
      true iff an edge is a bidirected edge (<->).
    • isDirectedEdge

      public static boolean isDirectedEdge(Edge edge)
      Returns:
      true iff the given edge is a directed edge (-->).
    • isPartiallyOrientedEdge

      public static boolean isPartiallyOrientedEdge(Edge edge)
      Returns:
      true iff the given edge is a partially oriented edge (o->)
    • isNondirectedEdge

      public static boolean isNondirectedEdge(Edge edge)
      Returns:
      true iff some edge is an nondirected edge (o-o).
    • isUndirectedEdge

      public static boolean isUndirectedEdge(Edge edge)
      Returns:
      true iff some edge is an undirected edge (-).
    • traverse

      public static Node traverse(Node node, Edge edge)
      Returns:
      the node opposite the given node along the given edge.
    • traverseDirected

      public static Node traverseDirected(Node node, Edge edge)
      For A -> B, given A, returns B; otherwise returns null.
    • traverseReverseDirected

      public static Node traverseReverseDirected(Node node, Edge edge)
      For A -> B, given B, returns A; otherwise returns null.
    • traverseSemiDirected

      public static Node traverseSemiDirected(Node node, Edge edge)
      For A --* B or A o-* B, given A, returns B. For A <-* B, returns null. Added by ekorber, 2004/06/12.
    • getDirectedEdgeHead

      public static Node getDirectedEdgeHead(Edge edge)
      For a directed edge, returns the node adjacent to the arrow endpoint.
      Throws:
      IllegalArgumentException - if the given edge is not a directed edge.
    • getDirectedEdgeTail

      public static Node getDirectedEdgeTail(Edge edge)
      For a directed edge, returns the node adjacent to the null endpoint.
      Throws:
      IllegalArgumentException - if the given edge is not a directed edge.
    • sortEdges

      public static void sortEdges(List<Edge> edges)