edu.ucla.stat.SOCR.touchgraph.graphlayout.graphelements
Class GraphEltSet

java.lang.Object
  extended by edu.ucla.stat.SOCR.touchgraph.graphlayout.graphelements.GraphEltSet
All Implemented Interfaces:
ImmutableGraphEltSet
Direct Known Subclasses:
Locality

public class GraphEltSet
extends java.lang.Object
implements ImmutableGraphEltSet

GraphEltSet contains data about the graph's components. Currently the only components are edges and nodes.

Version:
1.22-jre1.1 $Id: GraphEltSet.java,v 1.1 2010/01/20 20:38:32 jiecui Exp $
Author:
Alexander Shapiro, Murray Altheim (added support for IDs)

Field Summary
protected  java.util.Vector edges
           
protected  java.util.Hashtable nodeIDRegistry
          The Hashtable containing references to the Node IDs of the current graph.
protected  java.util.Vector nodes
           
 
Constructor Summary
GraphEltSet()
          Default constructor.
 
Method Summary
 void addEdge(Edge edge)
          Add the Edge edge to the graph.
 Edge addEdge(Node from, Node to, int tension)
          Add an Edge from Node from to Node to, with tension of int tension, returning the Edge.
 void addNode(Node node)
          Add the Node node to the graph, and registers the Node via its ID.
 void clearAll()
          Clear all nodes and edges.
 boolean contains(Edge edge)
          Returns true if the graph contains the Edge edge.
 boolean contains(Node node)
          Returns true if the graph contains the Node node.
 boolean deleteEdge(Edge edge)
          Delete the Edge edge.
 boolean deleteEdge(Node from, Node to)
          Delete the Edge spanning Node from to Node to, returning true if successful.
 void deleteEdges(java.util.Vector edgesToDelete)
          Delete the Edges contained within the Vector edgedToDelete.
 boolean deleteNode(Node node)
          Delete the Node node, returning true if successful.
 void deleteNodes(java.util.Vector nodesToDelete)
          Delete the Nodes contained within the Vector nodesToDelete.
protected  Edge edgeAt(int index)
          Return the Edge at int index, null if none are available.
 int edgeCount()
          Return the number of Edges in the cumulative Vector.
 int edgeNum()
          Deprecated. this method has been replaced by the edgeCount() method.
 Edge findEdge(Node from, Node to)
          Return an Edge spanning Node from to Node to.
 Node findNode(java.lang.String id)
          Return the Node whose ID matches the String id, null if no match is found.
 Node findNodeByURL(java.lang.String strURL)
          Return the Node whose URL matches the String strURL, null if no match is found.
 Node findNodeLabelContaining(java.lang.String substring)
          Return the first Nodes whose label contains the String substring, null if no match is found.
 void forAllEdges(TGForEachEdge fee)
          Iterates through Edges.
 void forAllNodePairs(TGForEachNodePair fenp)
          iterates through pairs of Nodes.
 void forAllNodes(TGForEachNode fen)
          A way of iterating through all the nodes.
 Node getFirstNode()
          Return the first Node, null if none exist.
 Node getRandomNode()
          Returns a random node, or null if none exist (for making random graphs).
protected  Node nodeAt(int i)
          Return the Node at int index, null if none are available.
 int nodeCount()
          Return the number of Nodes in the cumulative Vector.
 int nodeNum()
          Deprecated. this method has been replaced by the nodeCount() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

protected java.util.Vector nodes

edges

protected java.util.Vector edges

nodeIDRegistry

protected java.util.Hashtable nodeIDRegistry
The Hashtable containing references to the Node IDs of the current graph.

Constructor Detail

GraphEltSet

public GraphEltSet()
Default constructor.

Method Detail

nodeAt

protected Node nodeAt(int i)
Return the Node at int index, null if none are available.


nodeNum

public int nodeNum()
Deprecated. this method has been replaced by the nodeCount() method.

Return the number of Nodes in the cumulative Vector.

Specified by:
nodeNum in interface ImmutableGraphEltSet

nodeCount

public int nodeCount()
Return the number of Nodes in the cumulative Vector.

Specified by:
nodeCount in interface ImmutableGraphEltSet

addNode

public void addNode(Node node)
             throws TGException
Add the Node node to the graph, and registers the Node via its ID. If no ID exists, no registration occurs.

Throws:
TGException

contains

public boolean contains(Node node)
Returns true if the graph contains the Node node.


edgeAt

protected Edge edgeAt(int index)
Return the Edge at int index, null if none are available.


edgeNum

public int edgeNum()
Deprecated. this method has been replaced by the edgeCount() method.

Return the number of Edges in the cumulative Vector.

Specified by:
edgeNum in interface ImmutableGraphEltSet

edgeCount

public int edgeCount()
Return the number of Edges in the cumulative Vector.

Specified by:
edgeCount in interface ImmutableGraphEltSet

addEdge

public void addEdge(Edge edge)
Add the Edge edge to the graph.


addEdge

public Edge addEdge(Node from,
                    Node to,
                    int tension)
Add an Edge from Node from to Node to, with tension of int tension, returning the Edge.


contains

public boolean contains(Edge edge)
Returns true if the graph contains the Edge edge.


findNode

public Node findNode(java.lang.String id)
Return the Node whose ID matches the String id, null if no match is found.

Specified by:
findNode in interface ImmutableGraphEltSet

findNodeByURL

public Node findNodeByURL(java.lang.String strURL)
Return the Node whose URL matches the String strURL, null if no match is found.


findNodeLabelContaining

public Node findNodeLabelContaining(java.lang.String substring)
Return the first Nodes whose label contains the String substring, null if no match is found.

Specified by:
findNodeLabelContaining in interface ImmutableGraphEltSet

findEdge

public Edge findEdge(Node from,
                     Node to)
Return an Edge spanning Node from to Node to.

Specified by:
findEdge in interface ImmutableGraphEltSet

deleteEdge

public boolean deleteEdge(Edge edge)
Delete the Edge edge.


deleteEdges

public void deleteEdges(java.util.Vector edgesToDelete)
Delete the Edges contained within the Vector edgedToDelete.


deleteEdge

public boolean deleteEdge(Node from,
                          Node to)
Delete the Edge spanning Node from to Node to, returning true if successful.


deleteNode

public boolean deleteNode(Node node)
Delete the Node node, returning true if successful.


deleteNodes

public void deleteNodes(java.util.Vector nodesToDelete)
Delete the Nodes contained within the Vector nodesToDelete.


getRandomNode

public Node getRandomNode()
Returns a random node, or null if none exist (for making random graphs).

Specified by:
getRandomNode in interface ImmutableGraphEltSet

getFirstNode

public Node getFirstNode()
Return the first Node, null if none exist.

Specified by:
getFirstNode in interface ImmutableGraphEltSet

clearAll

public void clearAll()
Clear all nodes and edges.


forAllNodes

public void forAllNodes(TGForEachNode fen)
A way of iterating through all the nodes. Maybe too complex, and should be replaced by iterators.

Specified by:
forAllNodes in interface ImmutableGraphEltSet

forAllNodePairs

public void forAllNodePairs(TGForEachNodePair fenp)
iterates through pairs of Nodes.

Specified by:
forAllNodePairs in interface ImmutableGraphEltSet

forAllEdges

public void forAllEdges(TGForEachEdge fee)
Iterates through Edges.

Specified by:
forAllEdges in interface ImmutableGraphEltSet