/* A weighted node for an undirected or directed graph.
Copyright (c) 2001-2014 The University of Maryland
All rights reserved.
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the above
copyright notice and the following two paragraphs appear in all copies
of this software.
IN NO EVENT SHALL THE UNIVERSITY OF MARYLAND BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
THE UNIVERSITY OF MARYLAND HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
THE UNIVERSITY OF MARYLAND SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
MARYLAND HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
ENHANCEMENTS, OR MODIFICATIONS.
*/
package ptolemy.graph;
////////////////////////////////////////////////////////////////////////// //
//Node
/**
An optionally-weighted node for an undirected or directed graph. More
specifically, a node consists of an optional weight (an arbitrary
object that is associated with the node). We say that a node is
unweighted if it does not have an assigned weight. It is an error to
attempt to access the weight of an unweighted node. Node weights must be
genuine (non-null) objects.
@author Shuvra S. Bhattacharyya
@version $Id: Node.java 69607 2014-07-30 17:07:26Z cxh $
@since Ptolemy II 2.0
@Pt.ProposedRating Red (cxh)
@Pt.AcceptedRating Red (cxh)
@see ptolemy.graph.Edge
*/
public final class Node extends Element {
/** Construct an unweighted node.
*/
public Node() {
super();
}
/** Construct a node with a given node weight.
* @param weight The given weight.
* @exception IllegalArgumentException If the specified weight is
* null
.
*/
public Node(Object weight) {
super(weight);
}
///////////////////////////////////////////////////////////////////
//// public methods ////
/** A one-word description of the type of this graph element.
* @return The description.
*/
@Override
public String descriptor() {
return "node";
}
/** Return a string representation of the node.
* The string representation is simply a representation of the node
* weight (or the string "<unweighted node>"
if
* the node is unweighted.
*/
@Override
public String toString() {
if (_weight == null) {
return "";
} else {
return _weight.toString();
}
}
}