|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
A generic interface that defines an edge weighted, undirected graph.
Method Summary | |
---|---|
boolean |
addEdge(NodeType nodeA,
NodeType nodeB,
WeightType weight)
Adds an edge to the graph. |
boolean |
addEdge(NodeType nodeA,
NodeType nodeB,
WeightType weight,
java.lang.String desc)
Adds an edge to the graph. |
boolean |
addNode(NodeType node)
Adds a node to the graph. |
java.lang.Object |
clone()
Returns a clone of this object. |
int |
compareTo(Graph<NodeType,WeightType> g)
Compares graph g to this graph. |
int |
degreeOfNode(NodeType node)
Returns the degree (number of neighbors) of the node. |
Edge<NodeType,WeightType> |
getEdge(NodeType nodeA,
NodeType nodeB)
Returns a specific edge. |
java.lang.String |
getEdgeDescription(NodeType nodeA,
NodeType nodeB)
Returns a description of the edge implied by the two specified nodes. |
java.util.List<Edge<NodeType,WeightType>> |
getEdgeList()
|
java.util.Set<Edge<NodeType,WeightType>> |
getEdges()
Returns all edges in the graph. |
WeightType |
getEdgeWeight(NodeType nodeA,
NodeType nodeB)
Returns the weight of the edge implied by the two specified nodes. |
java.lang.String |
getId()
Returns the id of the graph. |
java.util.Set<NodeType> |
getNeighbors(NodeType node)
Returns a set all nodes adjacent to the specified node. |
java.util.Set<NodeType> |
getNodes()
Returns a set containing all nodes in the graph. |
WeightType |
getScore()
Returns the score of the graph. |
boolean |
isEdge(NodeType nodeA,
NodeType nodeB)
Indicates whether the specified nodes refer to a valid edge in the graph. |
boolean |
isNode(NodeType node)
Indicates whether the specified nodes is contained in the graph. |
int |
numberOfEdges()
Returns the number of edges in the graph. |
int |
numberOfNodes()
Returns the number of nodes in the graph. |
boolean |
removeEdge(NodeType nodeA,
NodeType nodeB)
|
boolean |
removeNode(NodeType node)
|
boolean |
setEdgeDescription(NodeType nodeA,
NodeType nodeB,
java.lang.String desc)
Sets a description for the edge implied by the two specified nodes. |
boolean |
setEdgeWeight(NodeType nodeA,
NodeType nodeB,
WeightType weight)
|
void |
setScore(WeightType f)
Sets the score of the graph. |
java.lang.String |
toString()
Returns a String representation of the graph format. |
Method Detail |
---|
boolean addNode(NodeType node)
node
- The node to add.
boolean addEdge(NodeType nodeA, NodeType nodeB, WeightType weight)
nodeA
- The beginning node of the edge to add.nodeB
- The ending node of the edge to add.weight
- The edge weight.
boolean addEdge(NodeType nodeA, NodeType nodeB, WeightType weight, java.lang.String desc)
nodeA
- The beginning node of the edge to add.nodeB
- The ending node of the edge to add.weight
- The edge weight.desc
- The edge description.
boolean isEdge(NodeType nodeA, NodeType nodeB)
nodeA
- The beginning node of the edge to check.nodeB
- The ending node of the edge to check.
boolean isNode(NodeType node)
node
- The node to check.
WeightType getEdgeWeight(NodeType nodeA, NodeType nodeB)
nodeA
- The beginning node of the edge.nodeB
- The ending node of the edge.
java.util.Set<NodeType> getNodes()
java.util.Set<NodeType> getNeighbors(NodeType node)
node
- The node whose neighbors we're requesting.
java.lang.String getId()
int numberOfNodes()
int numberOfEdges()
int degreeOfNode(NodeType node)
node
- The node whose degree we're requesting.
WeightType getScore()
void setScore(WeightType f)
f
- The score to set the graph to.int compareTo(Graph<NodeType,WeightType> g)
compareTo
in interface java.lang.Comparable<Graph<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>>
g
- Graph to compare this graph to.
java.lang.String getEdgeDescription(NodeType nodeA, NodeType nodeB)
nodeA
- The beginning node of the edge.nodeB
- The ending node of the edge.
boolean setEdgeDescription(NodeType nodeA, NodeType nodeB, java.lang.String desc)
nodeA
- The source node of the edge.nodeB
- The target node of the edge.desc
- The description of the edge.
Edge<NodeType,WeightType> getEdge(NodeType nodeA, NodeType nodeB)
nodeA
- The source node of the edge.nodeB
- The target node of the edge.
java.util.Set<Edge<NodeType,WeightType>> getEdges()
java.util.List<Edge<NodeType,WeightType>> getEdgeList()
java.lang.Object clone()
java.lang.String toString()
toString
in class java.lang.Object
boolean removeEdge(NodeType nodeA, NodeType nodeB)
boolean removeNode(NodeType node)
boolean setEdgeWeight(NodeType nodeA, NodeType nodeB, WeightType weight)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |