|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface specifies the methods for a Graph object, including a large number of methods to query/update the nodes and edges in the Graph. This interface uses the Set interface to specify a return type for many accessors.
Inner Class Summary | |
static interface |
Graph.Edge
Edge is an immutable inner class for storing edges in a graph; each consists of the origin and desination node in that graph. |
Method Summary | |
Graph |
addEdge(Graph.Edge edge,
Object edgeValue)
Add an edge to this graph, returning the new graph. |
Graph |
addEdge(String origin,
String destination,
Object edgeValue)
Add an edge to this graph, returning the new graph. |
Graph |
addNode(String nodeName)
Add a node to this graph, returning the new graph. |
void |
clear()
Remove all the nodes and edges from this graph. |
int |
degree(String nodeName)
Returns the degree of the specified node. |
Set |
getAllEdges()
Returns an UNMODIFIABLE set containing all the edges in the graph. |
Set |
getAllNodes()
Returns an UNMODIFIABLE set containing the names of all the nodes in the graph. |
int |
getEdgeCount()
Returns the number of edges in the Graph. |
Object |
getEdgeValue(Graph.Edge edge)
Returns the value associated with this edge (null if the edge is not in this graph). |
Object |
getEdgeValue(String origin,
String destination)
Returns the value associated with the edge with the specified origin and destination. |
EdgeValueIO |
getEdgeValueIO()
Return the EdgeValueIO object for this graph. |
Set |
getInEdges(String nodeName)
Returns an UNMODIFIABLE set containing all the edges in the graph whose destination node is destinationNodeName . |
Set |
getInNodes(String nodeName)
Returns an UNMODIFIABLE set containing the origin nodes that reach to destinationNodeName in the graph. |
int |
getNodeCount()
Returns the number of nodes in the Graph. |
Set |
getOutEdges(String nodeName)
Returns an UNMODIFIABLE set containing all the edges in the graph whose origin node is originNodeName . |
Set |
getOutNodes(String nodeName)
Returns an UNMODIFIABLE set containing the destination nodes reachable from originNodeName in the graph. |
boolean |
hasEdge(Graph.Edge edge)
Returns whether or not this graph stores an edge with the specified edge. |
boolean |
hasEdge(String origin,
String destination)
Returns whether or not this graph stores an edge with the specified origin and destination. |
boolean |
hasNode(String nodeName)
Return whether or not this graph stores a node. |
int |
inDegree(String nodeName)
Returns the in-degree of the specified node. |
Graph |
load(edu.cmu.cs.pattis.cs151xx.TypedBufferReader input,
char tokenSeparator)
Read this graph from a file, one line at at time, in the form: origin destination value (where each is separated from the other by tokenSeparator). |
int |
outDegree(String nodeName)
Returns the out-degree of the specified node. |
Graph |
removeEdge(Graph.Edge edge)
Remove an edge from this graph, returning the new graph. |
Graph |
removeEdge(String origin,
String destination)
Remove an edge from this graph, returning the new graph. |
Graph |
removeNode(String nodeName)
Remove a node from this graph, returning the new graph. |
void |
write(edu.cmu.cs.pattis.cs151xx.TypedBufferWriter output,
char tokenSeparator)
Write this graph into a file, one line at a time so that it can be read by the load method (in the form origin, destination, value; where each is separated from the other by tokenSeparator). |
Method Detail |
public void clear()
public Graph addNode(String nodeName)
nodeName
- - the name of the node to add to this graph.public Graph addEdge(String origin, String destination, Object edgeValue)
originNodeName
- - the origin node for the edge.destinationNodeName
- - the destination node for the edge.edgeValue
- - the value of the edge.public Graph addEdge(Graph.Edge edge, Object edgeValue)
edge
- - the edge to add to this graph.edgeValue
- - the value of the edge.public Graph removeNode(String nodeName)
nodeName
- - the name of the node to remove from this graph.public Graph removeEdge(String origin, String destination)
originNodeName
- - the origin node for the edge to remove from the graph.destinationNodeName
- - the destination node for the edge to remove from the graph.public Graph removeEdge(Graph.Edge edge)
edge
- - the edge to remove from this graph.public Graph load(edu.cmu.cs.pattis.cs151xx.TypedBufferReader input, char tokenSeparator)
input
- - file open for reading.tokeSeparator
- - character to use to separate origin, destination, and value.public void write(edu.cmu.cs.pattis.cs151xx.TypedBufferWriter output, char tokenSeparator)
output
- - file open for writing.tokeSeparator
- - character to use to separate origin, destination, and value.public EdgeValueIO getEdgeValueIO()
public int getNodeCount()
public int getEdgeCount()
public boolean hasNode(String nodeName)
nodeName
- - the name of the node to check.public boolean hasEdge(String origin, String destination)
originNodeName
- - the origin node for the edge to check.destinationNodeName
- - the destination node for the edge to check.public boolean hasEdge(Graph.Edge edge)
edge
- - the edge to check.public Object getEdgeValue(String origin, String destination)
origin
- - the origin node of the edge whose associated value is to be retrieved.destination
- - the destination of the edge whose associated value is to be retrieved.public Object getEdgeValue(Graph.Edge edge)
edge-
- the edge whose associated value is to be retrieved.public int inDegree(String nodeName)
nodeName
- - the name of the node to check.public int outDegree(String nodeName)
nodeName
- - the name of the node to check.public int degree(String nodeName)
nodeName
- - the name of the node to check.public Set getAllNodes()
public Set getAllEdges()
public Set getOutNodes(String nodeName)
originNodeName
in the graph.originNodeName
- - the name of the origin nodepublic Set getInNodes(String nodeName)
destinationNodeName
in the graph.destinationNodeName
- - the name of the origin nodepublic Set getOutEdges(String nodeName)
originNodeName
.originNodeName
- - the name of the origin node for the edgespublic Set getInEdges(String nodeName)
destinationNodeName
.destinationNodeName
- - the name of the destination node for the edges
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |