|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.graph.Element
ptolemy.graph.Edge
public final class Edge
A weighted or unweighted edge for a directed or undirected graph. The connectivity of edges is specified by source nodes and sink nodes. A directed edge is directed from its source node to its sink node. For an undirected edge, the source node is simply the first node that was specified when the edge was created, and the sink node is the second node. This convention allows undirected edges to later be converted in a consistent manner to directed edges, if desired.
On creation of an edge, an arbitrary object can be associated with the edge as the weight of the edge. We say that an edge is unweighted if it does not have an assigned weight. It is an error to attempt to access the weight of an unweighted edge.
Self-loop edges (edges whose source and sink nodes are identical) are allowed.
Once an edge is created, its source node and sink node cannot be changed.
Node
Red (cxh) |
Red (cxh) |
Field Summary | |
---|---|
private Node |
_sink
|
private Node |
_source
|
Fields inherited from class ptolemy.graph.Element |
---|
_weight |
Constructor Summary | |
---|---|
Edge(Node source,
Node sink)
Construct an unweighted edge with a specified source node and sink node. |
|
Edge(Node source,
Node sink,
java.lang.Object weight)
Construct a weighted edge with a specified source node, sink node, and edge weight. |
Method Summary | |
---|---|
java.lang.String |
descriptor()
A one-word description of the type of this graph element. |
boolean |
isSelfLoop()
Return true if this is a self-loop edge. |
Node |
sink()
Return the sink node of the edge. |
Node |
source()
Return the source node of the edge. |
java.lang.String |
toString()
Return a string representation of the edge, including information about the edge weight. |
java.lang.String |
toString(boolean showWeight)
Return a string representation of the edge, optionally including information about the edge weight. |
Methods inherited from class ptolemy.graph.Element |
---|
getWeight, hasWeight, removeWeight, setWeight |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Node _sink
private Node _source
Constructor Detail |
---|
public Edge(Node source, Node sink)
source
- The source node.sink
- The sink node.public Edge(Node source, Node sink, java.lang.Object weight)
source
- The source node.sink
- The sink node.weight
- The edge weight.
java.lang.IllegalArgumentException
- If the specified weight is
null
.Method Detail |
---|
public java.lang.String descriptor()
descriptor
in class Element
public boolean isSelfLoop()
public Node sink()
public Node source()
public java.lang.String toString(boolean showWeight)
(source, sink, weight)
,
where source
, sink
, and
weight
are string representations
of the source node, sink node, and edge weight, respectively.
If the edge is unweighted or the showWeight
argument is
false, then the string representation is simply
(source, sink)
.
showWeight
- True to include a string representation of the edge
weight in the string representation of the edge.
public java.lang.String toString()
toString
in class java.lang.Object
toString(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |