public class Graph
extends java.lang.Object
Constructor and Description |
---|
Graph()
Basic constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public void addEdge(java.lang.String xName, java.lang.String yName)
public boolean addNode(java.lang.String name)
public Node getNode(java.lang.String name)
public void readFromFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public Node getExistingNode(java.lang.String name)
public void resetIterator()
public Node nextNode()
public void print()
public Node[] nodeArray()
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException