org.gersteinlab.tyna.core.graph
Interface Graph

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
AdvancedDirectedGraph, AdvancedGraph, AdvancedUndirectedGraph, DirectedGraph, MultiGraph, SimpleGraph, UndirectedGraph
All Known Implementing Classes:
AbstractGraph, AbstractMultiGraph, AbstractSimpleGraph, DirectedMultiGraph, DirectedSimpleGraph, UndirectedMultiGraph, UndirectedSimpleGraph

public interface Graph
extends java.io.Serializable

        This interface declares that each implemented class is a graph.

        In order to allow Graph objects to be serialized, it is attempted to
        have this interface as stable as possible. Thus it defines only the most
        basic methods. More advanced methods such as statistical methods are
        defined in AdvancedGraph.

        The methods are not synchronized for efficiency reasons. May need to
        change in the future if concurrent access is required.
        

Version:
1.0 (September 20, 2005) Change History: 1.0 - Initial version
Author:
Kevin Yuk-Lap Yip

Method Summary
 void addEdge(Edge edge, boolean addNodes)
          Add an edge to the graph.
 void addNode(Node node)
          Add a node to the graph.
 boolean containsEdge(Node node1, Node node2)
          Whether there is an edge between the two nodes.
 boolean containsNode(Node node)
          Whether a given node is in the graph.
 java.lang.Object getAttr(java.lang.Object attrName)
          Get the (possibly null) value of an attribute of the graph.
 java.util.Map getAttrs()
          Get the (possibly null) attribute map of the graph.
 int getEdgeCount()
          Get the number of edges in the graph.
 EdgeIterator getEdgeIterator()
          Return an iterator of the edges in the graph.
 java.util.List getEdgeNodePairs()
          Return a list of unique node pairs between which there is an edge from the first node to the second node.
 Node getNode(java.lang.Object nodeId)
          Get the node that has the input node ID.
 int getNodeCount()
          Get the number of nodes in the graph.
 NodeIterator getNodeIterator()
          Return an iterator of the nodes in the graph.
 void setAttr(java.lang.Object attrName, java.lang.Object attrVal)
          Set the value of an attribute of the graph.
 

Method Detail

addNode

void addNode(Node node)
             throws GraphTypeException,
                    java.lang.NullPointerException
Add a node to the graph. If the node already exists, the graph will keep only one copy. See Node for the definition of two nodes being equal.

Parameters:
node - The node
Throws:
GraphTypeException - If the addition of the node violdates some requirements of the graph type
java.lang.NullPointerException - If node == null

addEdge

void addEdge(Edge edge,
             boolean addNodes)
             throws GraphTypeException,
                    java.lang.NullPointerException
Add an edge to the graph. See Edge for the definition of two edges being equal.

Parameters:
edge - The edge
addNodes - Whether to add the nodes to the node list
Throws:
GraphTypeException - If the addition of the node violdates some requirements of the graph type
java.lang.NullPointerException - If edge == null

containsNode

boolean containsNode(Node node)
                     throws java.lang.NullPointerException
Whether a given node is in the graph.

Parameters:
node - The node
Returns:
Whether the node is in the graph
Throws:
java.lang.NullPointerException - If node == null

containsEdge

boolean containsEdge(Node node1,
                     Node node2)
                     throws java.lang.IllegalArgumentException,
                            java.lang.NullPointerException
Whether there is an edge between the two nodes. If the graph is directed, it is to ask whether there is an edge form the first node to the second node.

Parameters:
node1 - The first node
node2 - The second node
Returns:
Whether there is an edge between the nodes
Throws:
java.lang.IllegalArgumentException - If any of the nodes is not in the graph
java.lang.NullPointerException - If node1 == null or node2 == null

getNode

Node getNode(java.lang.Object nodeId)
Get the node that has the input node ID.

Parameters:
nodeId - The node ID
Returns:
The node if exist, null otherwise

getAttr

java.lang.Object getAttr(java.lang.Object attrName)
Get the (possibly null) value of an attribute of the graph.

Parameters:
attrName - The name of the attribute
Returns:
The value of the attribute

getAttrs

java.util.Map getAttrs()
Get the (possibly null) attribute map of the graph. A copy of the stored map is returned.

Returns:
The attribute map

setAttr

void setAttr(java.lang.Object attrName,
             java.lang.Object attrVal)
Set the value of an attribute of the graph.

Parameters:
attrName - The name of the attribute
attrVal - The value of the attribute

getNodeCount

int getNodeCount()
Get the number of nodes in the graph.

Returns:
The number of nodes in the graph.

getEdgeCount

int getEdgeCount()
Get the number of edges in the graph.

Returns:
The number of edges in the graph.

getNodeIterator

NodeIterator getNodeIterator()
Return an iterator of the nodes in the graph. Unless otherwise specified by the implemented class, the node order in the returned iterator needs not be predictable from the order in which the nodes are added and/or removed.

Returns:
The iterator

getEdgeIterator

EdgeIterator getEdgeIterator()
Return an iterator of the edges in the graph. Unless otherwise specified by the implemented class, the edge order in the returned iterator needs not be predictable from the order in which the edges are added and/or removed.

Returns:
The iterator

getEdgeNodePairs

java.util.List getEdgeNodePairs()
Return a list of unique node pairs between which there is an edge from the first node to the second node. For undirected graphs, the order is unimportant, but only one of the two possible orders will be returned.

Returns:
The list of node pairs, each as a Node[]