Package org.apache.openjpa.lib.graph
Class Edge
java.lang.Object
org.apache.openjpa.lib.graph.Edge
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
FieldsModifier and TypeFieldDescriptionstatic final intAn edge (u, v) is a back edge if it creates a cycle back to an ancestor in the graph.static final intAn edge (u, v) is a forward edge if it is not a tree or back edge.static final intAn edge (u, v) is a tree edge if node v was first discovered by traversing the edge. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear traversal info.getCycle()List of edges forming a cycle.getFrom()Return the node the edge links from.Return the node on the opposite end of the given one, or null if the given node is not part of this edge.getTo()Return the node the edge links to.intgetType()Traversal bookkeeping info.Arbitrary user object associated with the edge.doubleReturn the weight of the edge.booleanReturn whether the edge is directed.booleanReturn true if this edge links from the given node.booleanReturns if this edge is (still) part of the graph.booleanReturn true if this edge links to the given node.voidList of edges forming a cycle.voidMark this edge as removed from the graph.voidsetType(int type) Traversal bookkeeping info.voidsetUserObject(Object obj) Arbitrary user object associated with the edge.voidsetWeight(double weight) Set the weight of the edge.toString()
-
Field Details
-
TYPE_TREE
public static final int TYPE_TREEAn edge (u, v) is a tree edge if node v was first discovered by traversing the edge.- See Also:
-
TYPE_BACK
public static final int TYPE_BACKAn edge (u, v) is a back edge if it creates a cycle back to an ancestor in the graph.- See Also:
-
TYPE_FORWARD
public static final int TYPE_FORWARDAn edge (u, v) is a forward edge if it is not a tree or back edge.- See Also:
-
-
Constructor Details
-
Edge
Constructor.- Parameters:
from- the node the edge comes fromto- the node the edge goes todirected- whether the edge is directed
-
Edge
Constructor.- Parameters:
from- the node the edge comes fromto- the node the edge goes todirected- whether the edge is directeduserObject- an associated object
-
-
Method Details
-
getFrom
Return the node the edge links from. -
getTo
Return the node the edge links to. -
getOther
Return the node on the opposite end of the given one, or null if the given node is not part of this edge. -
isTo
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
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
Arbitrary user object associated with the edge. -
setUserObject
Arbitrary user object associated with the edge. -
getType
public int getType()Traversal bookkeeping info. -
setType
public void setType(int type) Traversal bookkeeping info. -
getCycle
List of edges forming a cycle. Only set for TYPE_BACK and TYPE_FORWARD edges. -
setCycle
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
-