nct.networkblast
Class PathGraph<NodeType extends java.lang.Comparable<? super NodeType>>

java.lang.Object
  extended by nct.networkblast.PathGraph<NodeType>
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<Graph<NodeType,java.lang.Double>>, Graph<NodeType,java.lang.Double>

public class PathGraph<NodeType extends java.lang.Comparable<? super NodeType>>
extends java.lang.Object
implements Graph<NodeType,java.lang.Double>, java.lang.Comparable<Graph<NodeType,java.lang.Double>>, java.lang.Cloneable


Constructor Summary
PathGraph(NodeType n)
           
 
Method Summary
 boolean addEdge(NodeType nodeA, NodeType nodeB, java.lang.Double weight)
          Adds an edge to the graph.
 boolean addEdge(NodeType nodeA, NodeType nodeB, java.lang.Double 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,java.lang.Double> g)
          Compares graph g to this graph.
 int degreeOfNode(NodeType node)
          Returns the degree (number of neighbors) of the node.
 Edge<NodeType,java.lang.Double> 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,java.lang.Double>> getEdgeList()
           
 java.util.Set<Edge<NodeType,java.lang.Double>> getEdges()
          Returns all edges in the graph.
 java.lang.Double 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.
 java.lang.Double 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, java.lang.Double weight)
           
 void setScore(java.lang.Double f)
          Sets the score of the graph.
 java.lang.String toString()
          Returns a String representation of the graph format.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathGraph

public PathGraph(NodeType n)
Method Detail

addNode

public boolean addNode(NodeType node)
Description copied from interface: Graph
Adds a node to the graph.

Specified by:
addNode in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
node - The node to add.
Returns:
true if node successfully added, false otherwise.

addEdge

public boolean addEdge(NodeType nodeA,
                       NodeType nodeB,
                       java.lang.Double weight)
Description copied from interface: Graph
Adds an edge to the graph.

Specified by:
addEdge in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public boolean addEdge(NodeType nodeA,
                       NodeType nodeB,
                       java.lang.Double weight,
                       java.lang.String desc)
Description copied from interface: Graph
Adds an edge to the graph.

Specified by:
addEdge in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public boolean isEdge(NodeType nodeA,
                      NodeType nodeB)
Description copied from interface: Graph
Indicates whether the specified nodes refer to a valid edge in the graph.

Specified by:
isEdge in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public boolean isNode(NodeType node)
Description copied from interface: Graph
Indicates whether the specified nodes is contained in the graph.

Specified by:
isNode in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
node - The node to check.
Returns:
true if node exists, false otherwise.

getEdgeWeight

public java.lang.Double getEdgeWeight(NodeType nodeA,
                                      NodeType nodeB)
Description copied from interface: Graph
Returns the weight of the edge implied by the two specified nodes.

Specified by:
getEdgeWeight in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
nodeA - The beginning node of the edge.
nodeB - The ending node of the edge.
Returns:
The weight of the edge.

getNodes

public java.util.Set<NodeType> getNodes()
Description copied from interface: Graph
Returns a set containing all nodes in the graph.

Specified by:
getNodes in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
A set of all nodes in the graph.

getNeighbors

public java.util.Set<NodeType> getNeighbors(NodeType node)
Description copied from interface: Graph
Returns a set all nodes adjacent to the specified node.

Specified by:
getNeighbors in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
node - The node whose neighbors we're requesting.
Returns:
A set of all neighbor nodes.

getId

public java.lang.String getId()
Description copied from interface: Graph
Returns the id of the graph.

Specified by:
getId in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
The id of the graph.

numberOfNodes

public int numberOfNodes()
Description copied from interface: Graph
Returns the number of nodes in the graph.

Specified by:
numberOfNodes in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
The number of nodes in the graph.

numberOfEdges

public int numberOfEdges()
Description copied from interface: Graph
Returns the number of edges in the graph.

Specified by:
numberOfEdges in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
The number of edges in the graph.

degreeOfNode

public int degreeOfNode(NodeType node)
Description copied from interface: Graph
Returns the degree (number of neighbors) of the node.

Specified by:
degreeOfNode in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
node - The node whose degree we're requesting.
Returns:
The degree of the node.

getScore

public java.lang.Double getScore()
Description copied from interface: Graph
Returns the score of the graph.

Specified by:
getScore in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
The score of the graph.

setScore

public void setScore(java.lang.Double f)
Description copied from interface: Graph
Sets the score of the graph.

Specified by:
setScore in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
f - The score to set the graph to.

compareTo

public int compareTo(Graph<NodeType,java.lang.Double> g)
Description copied from interface: Graph
Compares graph g to this graph.

Specified by:
compareTo in interface java.lang.Comparable<Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>>
Specified by:
compareTo in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public java.lang.String getEdgeDescription(NodeType nodeA,
                                           NodeType nodeB)
Description copied from interface: Graph
Returns a description of the edge implied by the two specified nodes.

Specified by:
getEdgeDescription in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Parameters:
nodeA - The beginning node of the edge.
nodeB - The ending node of the edge.
Returns:
The description of the edge.

setEdgeDescription

public boolean setEdgeDescription(NodeType nodeA,
                                  NodeType nodeB,
                                  java.lang.String desc)
Description copied from interface: Graph
Sets a description for the edge implied by the two specified nodes.

Specified by:
setEdgeDescription in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public Edge<NodeType,java.lang.Double> getEdge(NodeType nodeA,
                                               NodeType nodeB)
Description copied from interface: Graph
Returns a specific edge.

Specified by:
getEdge in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
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

public java.util.Set<Edge<NodeType,java.lang.Double>> getEdges()
Description copied from interface: Graph
Returns all edges in the graph.

Specified by:
getEdges in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Returns:
A set of edge objects containing all edges in the graph.

getEdgeList

public java.util.List<Edge<NodeType,java.lang.Double>> getEdgeList()
Specified by:
getEdgeList in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>

clone

public java.lang.Object clone()
Description copied from interface: Graph
Returns a clone of this object.

Specified by:
clone in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Overrides:
clone in class java.lang.Object
Returns:
A clone of this object.

toString

public java.lang.String toString()
Description copied from interface: Graph
Returns a String representation of the graph format.

Specified by:
toString in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>
Overrides:
toString in class java.lang.Object

removeEdge

public boolean removeEdge(NodeType nodeA,
                          NodeType nodeB)
Specified by:
removeEdge in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>

removeNode

public boolean removeNode(NodeType node)
Specified by:
removeNode in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>

setEdgeWeight

public boolean setEdgeWeight(NodeType nodeA,
                             NodeType nodeB,
                             java.lang.Double weight)
Specified by:
setEdgeWeight in interface Graph<NodeType extends java.lang.Comparable<? super NodeType>,java.lang.Double>