org.globus.cog.util.graph
Interface GraphInterface

All Superinterfaces:
Cloneable
All Known Implementing Classes:
Graph

public interface GraphInterface
extends Cloneable

Defines an interface for a directed graph structure. A graph can contain nodes and edges. Operations on the graph are done using references to the nodes and edges.

See Also:
org.globus.ogce.util.Graph, org.globus.ogce.util.GraphEdge, org.globus.ogce.util.GraphNode

Method Summary
 Edge addEdge(Node fromNode, Node toNode, Object contents)
          Adds an edge from FromNode to ToNode.
 void addGraphListener(GraphListener l)
          Adds a listener to listen for structural changes in the graph
 Node addNode()
          Creates a new node in the graph
 Node addNode(Object contents)
          Creates a new node storing Contents in it
 void clear()
          Removes all nodes and edges from this graph
 Object clone()
          Constructs a shallow copy of this graph.
 int edgeCount()
          Returns No of edges in the graph
 Edge findEdge(Object contents)
           
 Node findNode(Object contents)
          Finds the node that has the specified contents
 EdgeIterator getEdgesIterator()
          Returns an iterator with the edges in the graph
 Set getEdgesSet()
          Returns a list with the edges in the graph.
 NodeIterator getNodesIterator()
          Returns an iterator with all the nodes in the graph
 Set getNodesSet()
          Returns a list with the nodes in the graph.
 int nodeCount()
          Returns No of nodes in the graph
 void removeEdge(Edge edge)
          Removes an edge from the graph.
 void removeEdge(Node fromNode, Node toNode)
          Removes an edge going from FromNode to ToNode If multiple edges exist between the two nodes, multiple calls to this method should be made, until an EdgeNotFoundException is thrown.
 void removeGraphListener(GraphListener l)
          Removes a listener
 void removeNode(Node node)
          Removes the specified node from the graph It will also remove all the edges connected to the node
 

Method Detail

addNode

public Node addNode()
Creates a new node in the graph

Returns:
a reference to the newly created node

addNode

public Node addNode(Object contents)
Creates a new node storing Contents in it

Parameters:
contents - The object to be added to the Node
Returns:
a reference to the newly created node

addEdge

public Edge addEdge(Node fromNode,
                    Node toNode,
                    Object contents)
             throws NodeNotFoundException
Adds an edge from FromNode to ToNode. A NodeNotFoundException is thrown if any of the two nodes does not exist in this graph.

Parameters:
fromNode - The source node for the edge
toNode - The destination node for the edge
contents - The object to be stored in the edge
Returns:
A reference to the created edge
Throws:
NodeNotFoundException

edgeCount

public int edgeCount()
Returns No of edges in the graph

Returns:
Number of edges in the graph

nodeCount

public int nodeCount()
Returns No of nodes in the graph

Returns:
Number fo nodes in the graph

getNodesIterator

public NodeIterator getNodesIterator()
Returns an iterator with all the nodes in the graph

Returns:
The nodesIterator value

getNodesSet

public Set getNodesSet()
Returns a list with the nodes in the graph. The order of nodes is a given. New nodes are added at the end of the list. This method allows manipulation of the graph based on the indexes of nodes.

Returns:
the list of nodes in this graph

getEdgesIterator

public EdgeIterator getEdgesIterator()
Returns an iterator with the edges in the graph

Returns:
The edgesIterator value

getEdgesSet

public Set getEdgesSet()
Returns a list with the edges in the graph. The order of edges should not change between calls to this method, unless changes are made to the graph. New edges are added at the end of the list. This method allows manipulation of the graph based on the indexes of edges.

Returns:
the list of edges in this graph

findNode

public Node findNode(Object contents)
Finds the node that has the specified contents


findEdge

public Edge findEdge(Object contents)

removeNode

public void removeNode(Node node)
                throws NodeNotFoundException
Removes the specified node from the graph It will also remove all the edges connected to the node

Parameters:
node - The node to be removed
Throws:
NodeNotFoundException - thrown if the node was not found in this graph

removeEdge

public void removeEdge(Node fromNode,
                       Node toNode)
                throws EdgeNotFoundException
Removes an edge going from FromNode to ToNode If multiple edges exist between the two nodes, multiple calls to this method should be made, until an EdgeNotFoundException is thrown.

Parameters:
fromNode - Description of the Parameter
toNode - Description of the Parameter
Throws:
EdgeNotFoundException - this exception is thrown if no edge exists between the two nodes

removeEdge

public void removeEdge(Edge edge)
                throws EdgeNotFoundException
Removes an edge from the graph.

Parameters:
edge - The edge to be removed.
Throws:
EdgeNotFoundException - ... if the specified edge does not exist in this graph

addGraphListener

public void addGraphListener(GraphListener l)
Adds a listener to listen for structural changes in the graph

Parameters:
l - the listener to be added

removeGraphListener

public void removeGraphListener(GraphListener l)
Removes a listener

Parameters:
l -

clear

public void clear()
Removes all nodes and edges from this graph


clone

public Object clone()
Constructs a shallow copy of this graph. In the new graph the Node and Edge objects will not be the same as in the old graph, but their contents will.

Returns: