ir.webutils
Class Graph

java.lang.Object
  extended by ir.webutils.Graph

public class Graph
extends java.lang.Object

Graph data structure.


Constructor Summary
Graph()
          Basic constructor.
 
Method Summary
 void addEdge(java.lang.String xName, java.lang.String yName)
          Adds an edge from xName to yName.
 boolean addNode(java.lang.String name)
          Adds a node if it is not already present.
 Node getExistingNode(java.lang.String name)
          Returns the node with that name
 Node getNode(java.lang.String name)
          Returns the node with that name, creates one if not already present.
static void main(java.lang.String[] args)
           
 Node nextNode()
          Returns the next node in an iterator over the nodes of the graph
 Node[] nodeArray()
          Returns all the nodes of the graph.
 void print()
          Prints the entire graph on stdout.
 void readFromFile(java.lang.String fileName)
          Reads graph from file where each line consists of a node-name followed by a list of the names of nodes to which it points
 void resetIterator()
          Resets the iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph()
Basic constructor.

Method Detail

addEdge

public void addEdge(java.lang.String xName,
                    java.lang.String yName)
Adds an edge from xName to yName.


addNode

public boolean addNode(java.lang.String name)
Adds a node if it is not already present.


getNode

public Node getNode(java.lang.String name)
Returns the node with that name, creates one if not already present.


readFromFile

public void readFromFile(java.lang.String fileName)
                  throws java.io.IOException
Reads graph from file where each line consists of a node-name followed by a list of the names of nodes to which it points

Throws:
java.io.IOException

getExistingNode

public Node getExistingNode(java.lang.String name)
Returns the node with that name


resetIterator

public void resetIterator()
Resets the iterator.


nextNode

public Node nextNode()
Returns the next node in an iterator over the nodes of the graph


print

public void print()
Prints the entire graph on stdout.


nodeArray

public Node[] nodeArray()
Returns all the nodes of the graph.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException