Class Edge

java.lang.Object
edu.cmu.tetrad.graph.Edge
All Implemented Interfaces:
TetradSerializable, Serializable, Comparable<Edge>

public class Edge extends Object implements TetradSerializable, Comparable<Edge>
Represents an edge node1 *-# node2 where * and # are endpoints of type Endpoint--that is, Endpoint.TAIL, Endpoint.ARROW, or Endpoint.CIRCLE.

Note that because speed is of the essence, and Edge cannot be compared to an object of any other type; this will throw an exception.

Author:
josephramsey
See Also:
  • Constructor Details

    • Edge

      public Edge(Node node1, Node node2, Endpoint endpoint1, Endpoint endpoint2)
      Constructs a new edge by specifying the nodes it connects and the endpoint types.
      Parameters:
      node1 - the first node
      node2 - the second node _
      endpoint1 - the endpoint at the first node
      endpoint2 - the endpoint at the second node
    • Edge

      public Edge(Edge edge)
  • Method Details

    • serializableInstance

      public static Edge serializableInstance()
      Generates a simple exemplar of this class to test serialization.
    • getNode1

      public final Node getNode1()
      Returns:
      the A node.
    • getNode2

      public final Node getNode2()
      Returns:
      the B node.
    • getEndpoint1

      public final Endpoint getEndpoint1()
      Returns:
      the endpoint of the edge at the A node.
    • setEndpoint1

      public final void setEndpoint1(Endpoint e)
    • getEndpoint2

      public final Endpoint getEndpoint2()
      Returns:
      the endpoint of the edge at the B node.
    • setEndpoint2

      public final void setEndpoint2(Endpoint e)
    • getProximalEndpoint

      public final Endpoint getProximalEndpoint(Node node)
      Returns:
      the endpoint nearest to the given node.
      Throws:
      IllegalArgumentException - if the given node is not along the edge.
    • getDistalEndpoint

      public final Endpoint getDistalEndpoint(Node node)
      Returns:
      the endpoint furthest from the given node.
      Throws:
      IllegalArgumentException - if the given node is not along the edge.
    • getDistalNode

      public final Node getDistalNode(Node node)
      Traverses the edge in an undirected fashion--given one node along the edge, returns the node at the opposite end of the edge.
    • isDirected

      public boolean isDirected()
      Returns:
      true just in case this edge is directed.
    • pointsTowards

      public boolean pointsTowards(Node node)
      Returns:
      true just in case the edge is pointing toward the given node-- that is, x --> node or x o--> node.
    • reverse

      public Edge reverse()
      Returns:
      the edge with endpoints reversed.
    • toString

      public final String toString()
      Produces a string representation of the edge.
      Overrides:
      toString in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object o)
      Two edges are equal just in case they connect the same nodes and have the same endpoints proximal to each node.
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Edge _edge)
      Specified by:
      compareTo in interface Comparable<Edge>
    • isNull

      public boolean isNull()
    • getLineColor

      public Color getLineColor()
    • addProperty

      public void addProperty(Edge.Property property)
    • getProperties

      public ArrayList<Edge.Property> getProperties()
    • addEdgeTypeProbability

      public void addEdgeTypeProbability(EdgeTypeProbability prob)
    • getEdgeTypeProbabilities

      public List<EdgeTypeProbability> getEdgeTypeProbabilities()
    • getProbability

      public double getProbability()
    • setProbability

      public void setProbability(double probability)
    • isHighlighted

      public boolean isHighlighted()
    • setHighlighted

      public void setHighlighted(boolean highlighted)