nct.graph
Interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>

All Superinterfaces:
java.lang.Cloneable, java.lang.Comparable<Graph<NodeType,WeightType>>
All Known Subinterfaces:
DistanceGraph<NodeType,WeightType>, KPartiteGraph<NodeType,WeightType,PartitionType>, SequenceGraph<NodeType,WeightType>
All Known Implementing Classes:
BasicDistanceGraph, BasicGraph, BasicKPartiteGraph, BlastGraph, CompatibilityGraph, FastaGraph, HomologyGraph, InteractionGraph, PathGraph

public interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>
extends java.lang.Comparable<Graph<NodeType,WeightType>>, java.lang.Cloneable

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

addNode

boolean addNode(NodeType node)
Adds a node to the graph.

Parameters:
node - The node to add.
Returns:
true if node successfully added, false otherwise.

addEdge

boolean addEdge(NodeType nodeA,
                NodeType nodeB,
                WeightType weight)
Adds an edge to the graph.

Parameters:
nodeA - The beginning node of the edge to add.
nodeB - The ending node of the edge to add.
weight - The edge weight.
Returns:
true if edge successfully added, false otherwise.

addEdge

boolean addEdge(NodeType nodeA,
                NodeType nodeB,
                WeightType weight,
                java.lang.String desc)
Adds an edge to the graph.

Parameters:
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.
Returns:
true if edge successfully added, false otherwise.

isEdge

boolean isEdge(NodeType nodeA,
               NodeType nodeB)
Indicates whether the specified nodes refer to a valid edge in the graph.

Parameters:
nodeA - The beginning node of the edge to check.
nodeB - The ending node of the edge to check.
Returns:
true if edge exists, false otherwise.

isNode

boolean isNode(NodeType node)
Indicates whether the specified nodes is contained in the graph.

Parameters:
node - The node to check.
Returns:
true if node exists, false otherwise.

getEdgeWeight

WeightType getEdgeWeight(NodeType nodeA,
                         NodeType nodeB)
Returns the weight of the edge implied by the two specified nodes.

Parameters:
nodeA - The beginning node of the edge.
nodeB - The ending node of the edge.
Returns:
The weight of the edge.

getNodes

java.util.Set<NodeType> getNodes()
Returns a set containing all nodes in the graph.

Returns:
A set of all nodes in the graph.

getNeighbors

java.util.Set<NodeType> getNeighbors(NodeType node)
Returns a set all nodes adjacent to the specified node.

Parameters:
node - The node whose neighbors we're requesting.
Returns:
A set of all neighbor nodes.

getId

java.lang.String getId()
Returns the id of the graph.

Returns:
The id of the graph.

numberOfNodes

int numberOfNodes()
Returns the number of nodes in the graph.

Returns:
The number of nodes in the graph.

numberOfEdges

int numberOfEdges()
Returns the number of edges in the graph.

Returns:
The number of edges in the graph.

degreeOfNode

int degreeOfNode(NodeType node)
Returns the degree (number of neighbors) of the node.

Parameters:
node - The node whose degree we're requesting.
Returns:
The degree of the node.

getScore

WeightType getScore()
Returns the score of the graph.

Returns:
The score of the graph.

setScore

void setScore(WeightType f)
Sets the score of the graph.

Parameters:
f - The score to set the graph to.

compareTo

int compareTo(Graph<NodeType,WeightType> g)
Compares graph g to this graph.

Specified by:
compareTo in interface java.lang.Comparable<Graph<NodeType extends java.lang.Comparable<? super NodeType>,WeightType extends java.lang.Comparable<? super WeightType>>>
Parameters:
g - Graph to compare this graph to.
Returns:
-1 if less, 0 if equal, 1 if greater - what those mean are left to the implementer.

getEdgeDescription

java.lang.String getEdgeDescription(NodeType nodeA,
                                    NodeType nodeB)
Returns a description of the edge implied by the two specified nodes.

Parameters:
nodeA - The beginning node of the edge.
nodeB - The ending node of the edge.
Returns:
The description of the edge.

setEdgeDescription

boolean setEdgeDescription(NodeType nodeA,
                           NodeType nodeB,
                           java.lang.String desc)
Sets a description for the edge implied by the two specified nodes.

Parameters:
nodeA - The source node of the edge.
nodeB - The target node of the edge.
desc - The description of the edge.
Returns:
Whether or not the descriptinon was successfully set.

getEdge

Edge<NodeType,WeightType> getEdge(NodeType nodeA,
                                  NodeType nodeB)
Returns a specific edge.

Parameters:
nodeA - The source node of the edge.
nodeB - The target node of the edge.
Returns:
The edge object described by the two node parameters.

getEdges

java.util.Set<Edge<NodeType,WeightType>> getEdges()
Returns all edges in the graph.

Returns:
A set of edge objects containing all edges in the graph.

getEdgeList

java.util.List<Edge<NodeType,WeightType>> getEdgeList()

clone

java.lang.Object clone()
Returns a clone of this object.

Returns:
A clone of this object.

toString

java.lang.String toString()
Returns a String representation of the graph format.

Overrides:
toString in class java.lang.Object

removeEdge

boolean removeEdge(NodeType nodeA,
                   NodeType nodeB)

removeNode

boolean removeNode(NodeType node)

setEdgeWeight

boolean setEdgeWeight(NodeType nodeA,
                      NodeType nodeB,
                      WeightType weight)