Package org.apache.openjpa.lib.graph
Class Edge
- java.lang.Object
-
- org.apache.openjpa.lib.graph.Edge
-
public class Edge extends java.lang.Object
A graph edge. Includes the from and to nodes, an arbitrary user object, and a weight. Edges can be either directed or undirected.
- Since:
- 1.0.0
- Author:
- Abe White
-
-
Field Summary
Fields Modifier and Type Field Description static int
TYPE_BACK
An edge (u, v) is a back edge if it creates a cycle back to an ancestor in the graph.static int
TYPE_FORWARD
An edge (u, v) is a forward edge if it is not a tree or back edge.static int
TYPE_TREE
An edge (u, v) is a tree edge if node v was first discovered by traversing the edge.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearTraversal()
Clear traversal info.java.util.List<Edge>
getCycle()
List of edges forming a cycle.java.lang.Object
getFrom()
Return the node the edge links from.java.lang.Object
getOther(java.lang.Object node)
Return the node on the opposite end of the given one, or null if the given node is not part of this edge.java.lang.Object
getTo()
Return the node the edge links to.int
getType()
Traversal bookkeeping info.java.lang.Object
getUserObject()
Arbitrary user object associated with the edge.double
getWeight()
Return the weight of the edge.boolean
isDirected()
Return whether the edge is directed.boolean
isFrom(java.lang.Object node)
Return true if this edge links from the given node.boolean
isRemovedFromGraph()
Returns if this edge is (still) part of the graph.boolean
isTo(java.lang.Object node)
Return true if this edge links to the given node.void
setCycle(java.util.List<Edge> cycle)
List of edges forming a cycle.void
setRemovedFromGraph()
Mark this edge as removed from the graph.void
setType(int type)
Traversal bookkeeping info.void
setUserObject(java.lang.Object obj)
Arbitrary user object associated with the edge.void
setWeight(double weight)
Set the weight of the edge.java.lang.String
toString()
-
-
-
Field Detail
-
TYPE_TREE
public static final int TYPE_TREE
An edge (u, v) is a tree edge if node v was first discovered by traversing the edge.- See Also:
- Constant Field Values
-
TYPE_BACK
public static final int TYPE_BACK
An edge (u, v) is a back edge if it creates a cycle back to an ancestor in the graph.- See Also:
- Constant Field Values
-
TYPE_FORWARD
public static final int TYPE_FORWARD
An edge (u, v) is a forward edge if it is not a tree or back edge.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Edge
public Edge(java.lang.Object from, java.lang.Object to, boolean directed)
Constructor.- Parameters:
from
- the node the edge comes fromto
- the node the edge goes todirected
- whether the edge is directed
-
Edge
public Edge(java.lang.Object from, java.lang.Object to, boolean directed, java.lang.Object userObject)
Constructor.- Parameters:
from
- the node the edge comes fromto
- the node the edge goes todirected
- whether the edge is directeduserObject
- an associated object
-
-
Method Detail
-
getFrom
public java.lang.Object getFrom()
Return the node the edge links from.
-
getTo
public java.lang.Object getTo()
Return the node the edge links to.
-
getOther
public java.lang.Object getOther(java.lang.Object node)
Return the node on the opposite end of the given one, or null if the given node is not part of this edge.
-
isTo
public boolean isTo(java.lang.Object node)
Return true if this edge links to the given node. For undirected edges, this method returns true if either side is equal to the given node.
-
isFrom
public boolean isFrom(java.lang.Object node)
Return true if this edge links from the given node. For undirected edges, this method returns true if either side is equal to the given node.
-
isDirected
public boolean isDirected()
Return whether the edge is directed.
-
getWeight
public double getWeight()
Return the weight of the edge.
-
setWeight
public void setWeight(double weight)
Set the weight of the edge.
-
getUserObject
public java.lang.Object getUserObject()
Arbitrary user object associated with the edge.
-
setUserObject
public void setUserObject(java.lang.Object obj)
Arbitrary user object associated with the edge.
-
getType
public int getType()
Traversal bookkeeping info.
-
setType
public void setType(int type)
Traversal bookkeeping info.
-
getCycle
public java.util.List<Edge> getCycle()
List of edges forming a cycle. Only set for TYPE_BACK and TYPE_FORWARD edges.
-
setCycle
public void setCycle(java.util.List<Edge> cycle)
List of edges forming a cycle. Only set for TYPE_BACK and TYPE_FORWARD edges.
-
isRemovedFromGraph
public boolean isRemovedFromGraph()
Returns if this edge is (still) part of the graph.
-
setRemovedFromGraph
public void setRemovedFromGraph()
Mark this edge as removed from the graph.
-
clearTraversal
public void clearTraversal()
Clear traversal info.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-