Each node or edge may have a weight associated with it (see {@link Edge} and {@link Node}). The nodes (edges) in a graph are always distinct, but their weights need not be.
Each node (edge) has a unique, integer label associated with it. These labels can be used, for example, to index arrays and matrixes whose rows/columns correspond to nodes (edges). See {@link #nodeLabel(Node)}( {@link #edgeLabel(Edge)}) for details.
Both directed and undirected graphs can be implemented using this class. In directed graphs, the order of nodes specified to the addEdge
method is relevant, whereas in undirected graphs, the order is unimportant. Support for both undirected and directed graphs follows from the combined support for these in the underlying {@link Node} and {@link Edge} classes. For more thorough support for directedgraphs, see {@link DirectedGraph}.
The same node can exist in multiple graphs, but any given graph can contain only one instance of the node. Node labels, however, are local to individual graphs. Thus, the same node may have different labels in different graphs. Furthermore, the label assigned in a given graph to a node may change over time (if the set of nodes in the graph changes). If a node is contained in multiple graphs, it has the same weight in all of the graphs. All of this holds for edges as well. The same weight may be shared among multiple nodes and edges.
Multiple edges in a graph can connect the same pair of nodes. Thus, multigraphs are supported.
Once assigned, node and edge weights should not be changed in ways that affect comparison under the equals
method. Otherwise, unpredictable behavior may result.
In discussions of complexity, n and e refers to the number of graph nodes and edges, respectively.
In derived classes, the following methods need special attention regarding whether or not they should be overridden:
{@link #validEdgeWeight(Object)} {@link #validNodeWeight(Object)}
@author Shuvra S. Bhattacharyya, Ming-Yung Ko, Fuat Keceli,Shahrooz Shahparnia, Yuhong Xiong, Jie Liu.
@version $Id: Graph.java,v 1.161 2006/10/25 14:23:48 cxh Exp $
@since Ptolemy II 0.2
@Pt.ProposedRating Red (cxh)
@Pt.AcceptedRating Red (cxh)
@see ptolemy.graph.Edge
@see ptolemy.graph.Node
|
|
|
|
|
|
|
|