For add(Triple)
see GraphAdd.
Thread Safety: Can be called only by the AWT event thread.
V
set and a set of edges of type E
. Edges of this graph type have exactly two endpoints; whether these endpoints must be distinct depends on the implementation. This interface permits, but does not enforce, any of the following common variations of graphs:
Definitions (with respect to a given vertex v
):
v
: an edge that can be traversed from a neighbor of v
to reach v
outgoing edge of v
: an edge that can be traversed from v
to reach some neighbor of v
predecessor of v
: a vertex at the other end of an incoming edge of v
successor of v
: a vertex at the other end of an outgoing edge of v
This object exposes two URLs:
Title: Graph
Description: Represents a graph of verticies and edges
Copyright: Copyright (c) 2007
Company:
@author John Valentino II @version 1.0Graph
class provides a graphical component for the Processing Development Environment (PDE). It contains n graphs that are added and referenced via a unique key.EventListener
mechanism as demonstrated in the example of the {@link jaron.uavsim.UAVsim}.
@author jarontec gmail com
@version 1.2
@since 1.0
Graph
s may be equal (isomorphic) even if the set of triples are not. Implementations MUST be immutable and throw respective exceptions, when add/remove-methods are called.
@see org.apache.clerezza.rdf.core.impl.AbstractGraph
@author reto
Graph representation using the adjacency list form. See the book 'Introduction to Algorithms' by Cormen, Leiserson, and Rivest.
@author Abe White @since 1.0.0 @nojavadoc A graph object belongs to a graph model, which really contains the data. Graph objects are therefore only accessors, with all convinient methods to read and modify the structure. Hence, multiple Graph
objects can exists.
GraphController graphController = Lookup.getDefault().lookup(GraphController.class); GraphModel model = graphController.getModel(); Graph graph = model.getGraph();Note: This shows how to get the complete graph, for getting only the currently visualized graph, call
model.getGraphVisible()
instead. There is two different way to perform read locking:
readLock()
and readUnlock()
NodeIterable
and EdgeIterable
readUnlockAll()
to release all the locks. Note: Write locking is automatically done when modifying th graph (add, remove, ...). @author Mathieu Bastian
Graph g = ... ; g.setNodeFactory( new MyNodeFactory() ); g.addNode("root"); MyNode n = g.getNode("root"); for( MyNode node : g.getEachNode() ) { // Do something with node }
Graph elements (nodes and edges) can be accessed using their identifier or their index. Each node / edge has a unique string identifier assigned when the element is created. Each element has an automatically maintained unique index between 0 and {@link #getNodeCount()} - 1 or {@link #getEdgeCount()} -1. When a new element is added, its index is getNodeCount() - 1
or getEdgeCount() - 1
. When an element is removed, the element with the biggest index takes its place. Unlike identifiers, indices can change when the graph is modified, but they are always successive. A loop of the form
for (int i = 0; i < g.getNodeCount(); i++) { Node node = g.getNode(i); // Do something with node }will always iterate on all the nodes of
g
.
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
Graph
. The interface defines methods for adding and removing Nodes
and Edges
.
@see Node
@see Edge
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|