|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.util.GraphSet
A Set-based implementation of the Graph interface.
Once you've added a node to this graph, you must not mutate the node in a way
that affects its equals(Object) and hashCode()
methods.
This class permits the null node.
This implementation is not synchronized..
| Nested Class Summary |
| Nested classes inherited from class com.arsdigita.util.Graph |
Graph.Edge |
| Constructor Summary | |
GraphSet()
|
|
| Method Summary | |
void |
addEdge(Graph.Edge edge)
Adds an edge to the graph. |
void |
addEdge(Object tail,
Object head,
Object label)
A convenient shortcut for addEdge(new Graph.Edge(tail, head,
label)). |
void |
addNode(Object name)
Adds a node to the graph. |
Graph |
copy()
Creates a copy of this graph. |
List |
getIncomingEdges(Object node)
|
String |
getLabel()
Returns the graph's label. |
List |
getNodes()
Returns a list of nodes that this graph has. |
List |
getOutgoingEdges(Object node)
Returns a list of outgoing edges leaving this node. |
boolean |
hasEdge(Graph.Edge edge)
Returns true if the graph has this edge. |
boolean |
hasNode(Object nodeName)
Returns true if the graph has this node. |
int |
incomingEdgeCount(Object node)
|
int |
nodeCount()
Returns the count of nodes in this graph. |
int |
outgoingEdgeCount(Object node)
Returns the number of outgoing edges this node has. |
void |
removeAll()
Removes all nodes and edges. |
boolean |
removeEdge(Graph.Edge edge)
Removes specified edge. |
boolean |
removeEdge(Object tail,
Object head,
Object label)
A convenient shortcut for removeEdge(new Graph.Edge(tail, head,
label)). |
boolean |
removeNode(Object nodeName)
Removes specified node and all edges incident to it. |
void |
setLabel(String label)
Sets the graph's label. |
String |
toString()
Returns a printable representation of the graph that has the following form. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public GraphSet()
| Method Detail |
public Graph copy()
Graph
copy in interface Graphpublic void setLabel(String label)
Graph
setLabel in interface Graphpublic String getLabel()
Graph
getLabel in interface Graphpublic void addNode(Object name)
Graph
addNode in interface Graphpublic boolean hasNode(Object nodeName)
Graphtrue if the graph has this node.
hasNode in interface Graphpublic boolean hasEdge(Graph.Edge edge)
Graphtrue if the graph has this edge.
hasEdge in interface Graphpublic int nodeCount()
Graph
nodeCount in interface Graphpublic void addEdge(Graph.Edge edge)
Graph
addEdge in interface Graph
public void addEdge(Object tail,
Object head,
Object label)
GraphaddEdge(new Graph.Edge(tail, head,
label)).
addEdge in interface GraphGraph.addEdge(Graph.Edge)public List getNodes()
Graph
getNodes in interface Graphpublic boolean removeNode(Object nodeName)
Graph
removeNode in interface Graph
public boolean removeEdge(Object tail,
Object head,
Object label)
GraphremoveEdge(new Graph.Edge(tail, head,
label)).
removeEdge in interface GraphGraph.removeEdge(Graph.Edge)public boolean removeEdge(Graph.Edge edge)
Graph
removeEdge in interface Graphpublic void removeAll()
Graph
removeAll in interface Graphpublic List getOutgoingEdges(Object node)
Graph
getOutgoingEdges in interface Graphpublic int outgoingEdgeCount(Object node)
GraphgetOutgoingEdges(node).size().
outgoingEdgeCount in interface GraphGraph.getOutgoingEdges(Object)public int incomingEdgeCount(Object node)
incomingEdgeCount in interface GraphGraph.outgoingEdgeCount(Object)public List getIncomingEdges(Object node)
getIncomingEdges in interface GraphGraph.getOutgoingEdges(Object)public String toString()
digraph foo {
Boston -> New_York [label="214 miles"];
Boston -> Chicago [label="983 miles"];
New_York -> Chicago [label="787 miles"];
Boston -> Westford [label="35 miles"];
Raleigh -> Westford [label="722 miles"];
}
Note that to get a neat printable representation, each node and edge label must have a short printable representation.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||