public class Graph
extends java.lang.Object
| Constructor and Description |
|---|
Graph()
Constructor for class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(Edge edge)
Add edge to list of nodes.
|
void |
addNode(Node node)
Add node to list of nodes.
|
void |
copyGraph(Graph graph)
Copy a graph to the current graph object.
|
Node |
getFinalNode()
Get the final node
|
Node |
getInitialNode()
Get the initial node
|
Node |
getNode(int index)
Get node at the specified position in the list.
|
boolean |
hasMoreEdges() |
boolean |
hasMoreNodes() |
int |
indexOf(Node node)
Gets the index of a particular node in the graph.
|
void |
insertGraph(Graph graph,
Node node)
Insert a graph in the current graph, replacing a particular node.
|
boolean |
isEdgeInGraph(Edge edge)
Check if an edge is in the graph.
|
boolean |
isFinalNode(Node node)
Returns whether the given node is the final node in this graph.
|
boolean |
isInitialNode(Node node)
Returns whether the given node is the initial node in this graph.
|
boolean |
isNodeInGraph(Node node)
Check if a node is in the graph.
|
Edge |
linkNodes(Node sourceNode,
Node destinationNode)
Link two nodes.
|
Edge |
nextEdge() |
Node |
nextNode() |
Node[] |
nodeToArray()
Gets an array containing the nodes in this graph.
|
void |
printGraph()
Prints out the graph.
|
void |
setFinalNode(Node node)
Set the final node
|
void |
setInitialNode(Node node)
Set the initial node
|
int |
size()
Get this graph's size.
|
void |
startEdgeIterator()
Start iterator for edges.
|
void |
startNodeIterator()
Start iterator for nodes.
|
boolean |
validate()
Validate the graph.
|
public void setInitialNode(Node node) throws java.lang.IllegalArgumentException
node - nodejava.lang.IllegalArgumentException - if node is not in the graphpublic void setFinalNode(Node node) throws java.lang.IllegalArgumentException
node - nodejava.lang.IllegalArgumentException - if node is not in the graphpublic Node getInitialNode()
public Node getFinalNode()
public int size()
public Node getNode(int index)
index - index of item to retunpublic Node[] nodeToArray()
public int indexOf(Node node)
node - the nodepublic boolean isInitialNode(Node node)
node - the node we want to comparepublic boolean isFinalNode(Node node)
node - the node we want to comparepublic Edge linkNodes(Node sourceNode, Node destinationNode)
sourceNode - source nodedestinationNode - destination nodepublic void addNode(Node node)
node - node to addpublic void addEdge(Edge edge)
edge - edge to addpublic boolean isNodeInGraph(Node node)
node - node to checkpublic boolean isEdgeInGraph(Edge edge)
edge - edge to checkpublic void startNodeIterator()
public boolean hasMoreNodes()
public Node nextNode()
public void startEdgeIterator()
public boolean hasMoreEdges()
public Edge nextEdge()
public void copyGraph(Graph graph)
graph - the graph to copy frompublic void insertGraph(Graph graph, Node node)
graph - the graph to insertnode - the node that this graph will replacepublic boolean validate()
public void printGraph()