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.

Version:
$Id: $Id
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(Node node1, Node node2, Endpoint endpoint1, Endpoint endpoint2, boolean flipIfBackwards)
      Constructs an Edge by specifying two nodes, their corresponding endpoints, and whether to flip the direction of the edge if it is pointing backwards.
      Parameters:
      node1 - the first node of the edge; must not be null
      node2 - the second node of the edge; must not be null
      endpoint1 - the endpoint type for the first node; must not be null
      endpoint2 - the endpoint type for the second node; must not be null
      flipIfBackwards - a boolean indicating whether to flip the nodes and endpoints if the edge is considered to be pointing backwards
      Throws:
      NullPointerException - if any of the nodes or endpoints are null
    • Edge

      public Edge(Edge edge)

      Constructor for Edge.

      Parameters:
      edge - a Edge object
  • Method Details

    • serializableInstance

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

      public final Node getNode1()

      Getter for the field node1.

      Returns:
      the A node.
    • getNode2

      public final Node getNode2()

      Getter for the field node2.

      Returns:
      the B node.
    • getEndpoint1

      public final Endpoint getEndpoint1()

      Getter for the field endpoint1.

      Returns:
      the endpoint of the edge at the A node.
    • setEndpoint1

      public final void setEndpoint1(Endpoint e)

      Setter for the field endpoint1.

      Parameters:
      e - a Endpoint object
    • getEndpoint2

      public final Endpoint getEndpoint2()

      Getter for the field endpoint2.

      Returns:
      the endpoint of the edge at the B node.
    • setEndpoint2

      public final void setEndpoint2(Endpoint e)

      Setter for the field endpoint2.

      Parameters:
      e - a Endpoint object
    • getEndpoint

      public final Endpoint getEndpoint(Node node)

      getProximalEndpoint.

      Parameters:
      node - a Node object
      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)

      getDistalEndpoint.

      Parameters:
      node - a Node object
      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.
      Parameters:
      node - a Node object
      Returns:
      a Node object
    • isDirected

      public boolean isDirected()

      isDirected.

      Returns:
      true just in case this edge is directed.
    • pointsTowards

      public boolean pointsTowards(Node node)

      pointsTowards.

      Parameters:
      node - a Node object
      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()
      Reverses the edge, so that it if was X->Y it's now Y->X, or vice-versa.
      Returns:
      the edge with endpoints reversed.
    • sameEdgeFlippedDirection

      public Edge sameEdgeFlippedDirection()
      Flips this edge, so that if it's X->Y it's now Y<-X, or vice-versa.
      Returns:
      The flipped edge.
    • toString

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

      public final int hashCode()

      hashCode.

      Overrides:
      hashCode in class Object
      Returns:
      a int
    • 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)

      compareTo.

      Specified by:
      compareTo in interface Comparable<Edge>
      Parameters:
      _edge - a Edge object
      Returns:
      a int
    • isNull

      public boolean isNull()

      isNull.

      Returns:
      a boolean
    • getLineColor

      public Color getLineColor()

      Getter for the field lineColor.

      Returns:
      a Color object
    • addProperty

      public void addProperty(Edge.Property property)

      addProperty.

      Parameters:
      property - a Edge.Property object
    • getProperties

      public ArrayList<Edge.Property> getProperties()

      Getter for the field properties.

      Returns:
      a ArrayList object
    • addEdgeTypeProbability

      public void addEdgeTypeProbability(EdgeTypeProbability prob)

      addEdgeTypeProbability.

      Parameters:
      prob - a EdgeTypeProbability object
    • getEdgeTypeProbabilities

      public List<EdgeTypeProbability> getEdgeTypeProbabilities()

      Getter for the field edgeTypeProbabilities.

      Returns:
      a List object
    • getProbability

      public double getProbability()

      Getter for the field probability.

      Returns:
      a double
    • setProbability

      public void setProbability(double probability)

      Setter for the field probability.

      Parameters:
      probability - a double
    • isHighlighted

      public boolean isHighlighted()

      isHighlighted.

      Returns:
      a boolean
    • setHighlighted

      public void setHighlighted(boolean highlighted)

      Setter for the field highlighted.

      Parameters:
      highlighted - a boolean