Class Edge
- All Implemented Interfaces:
TetradSerializable,Serializable,Comparable<Edge>
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:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for Edge.Constructs a new edge by specifying the nodes it connects and the endpoint types.Constructs an Edge by specifying two nodes, their corresponding endpoints, and whether to flip the direction of the edge if it is pointing backwards. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEdgeTypeProbability.voidaddProperty(Edge.Property property) addProperty.intcompareTo.final booleanfinal EndpointgetDistalEndpoint(Node node) getDistalEndpoint.final NodegetDistalNode(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.Getter for the fieldedgeTypeProbabilities.final EndpointgetEndpoint(Node node) getProximalEndpoint.final EndpointGetter for the fieldendpoint1.final EndpointGetter for the fieldendpoint2.Getter for the fieldlineColor.final NodegetNode1()Getter for the fieldnode1.final NodegetNode2()Getter for the fieldnode2.doubleGetter for the fieldprobability.Getter for the fieldproperties.final inthashCode()hashCode.booleanisDirected.booleanisHighlighted.booleanisNull()isNull.booleanpointsTowards(Node node) pointsTowards.reverse()Reverses the edge, so that it if was X->Y it's now Y->X, or vice-versa.Flips this edge, so that if it's X->Y it's now Y<-X, or vice-versa.static EdgeGenerates a simple exemplar of this class to test serialization.final voidSetter for the fieldendpoint1.final voidSetter for the fieldendpoint2.voidsetHighlighted(boolean highlighted) Setter for the fieldhighlighted.voidsetProbability(double probability) Setter for the fieldprobability.final StringtoString()Produces a string representation of the edge.
-
Constructor Details
-
Edge
Constructs a new edge by specifying the nodes it connects and the endpoint types.- Parameters:
node1- the first nodenode2- the second node _endpoint1- the endpoint at the first nodeendpoint2- 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 nullnode2- the second node of the edge; must not be nullendpoint1- the endpoint type for the first node; must not be nullendpoint2- the endpoint type for the second node; must not be nullflipIfBackwards- 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
Constructor for Edge.
- Parameters:
edge- aEdgeobject
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
Edgeobject
-
getNode1
Getter for the field
node1.- Returns:
- the A node.
-
getNode2
Getter for the field
node2.- Returns:
- the B node.
-
getEndpoint1
Getter for the field
endpoint1.- Returns:
- the endpoint of the edge at the A node.
-
setEndpoint1
Setter for the field
endpoint1.- Parameters:
e- aEndpointobject
-
getEndpoint2
Getter for the field
endpoint2.- Returns:
- the endpoint of the edge at the B node.
-
setEndpoint2
Setter for the field
endpoint2.- Parameters:
e- aEndpointobject
-
getEndpoint
getProximalEndpoint.
- Parameters:
node- aNodeobject- Returns:
- the endpoint nearest to the given node.
- Throws:
IllegalArgumentException- if the given node is not along the edge.
-
getDistalEndpoint
getDistalEndpoint.
- Parameters:
node- aNodeobject- Returns:
- the endpoint furthest from the given node.
- Throws:
IllegalArgumentException- if the given node is not along the edge.
-
getDistalNode
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()isDirected.
- Returns:
- true just in case this edge is directed.
-
pointsTowards
pointsTowards.
- Parameters:
node- aNodeobject- Returns:
- true just in case the edge is pointing toward the given node-- that is, x --> node or x o--> node.
-
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
Flips this edge, so that if it's X->Y it's now Y<-X, or vice-versa.- Returns:
- The flipped edge.
-
toString
Produces a string representation of the edge. -
hashCode
public final int hashCode()hashCode.
-
equals
Two edges are equal just in case they connect the same nodes and have the same endpoints proximal to each node.
-
compareTo
compareTo.
- Specified by:
compareToin interfaceComparable<Edge>- Parameters:
_edge- aEdgeobject- Returns:
- a int
-
isNull
public boolean isNull()isNull.
- Returns:
- a boolean
-
getLineColor
Getter for the field
lineColor.- Returns:
- a
Colorobject
-
addProperty
addProperty.
- Parameters:
property- aEdge.Propertyobject
-
getProperties
Getter for the field
properties.- Returns:
- a
ArrayListobject
-
addEdgeTypeProbability
addEdgeTypeProbability.
- Parameters:
prob- aEdgeTypeProbabilityobject
-
getEdgeTypeProbabilities
Getter for the field
edgeTypeProbabilities.- Returns:
- a
Listobject
-
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
-