|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdigraphs.Digraph
public class Digraph
A class for representing directed graphs.
| Field Summary | |
|---|---|
protected java.util.ArrayList<DigraphEdge> |
digraphEdges
|
protected java.util.ArrayList<DigraphNode> |
digraphNodes
|
protected static java.lang.String |
EdgeClassName
|
| Constructor Summary | |
|---|---|
Digraph()
Initializes a new Digraph with empty lists of nodes and edges. |
|
| Method Summary | |
|---|---|
DigraphEdge |
addEdgeFromNodeToNode(DigraphNode node1,
DigraphNode node2)
Adds a new edge of the appropriate DigraphEdge subclass to connect two given nodes, provided the two nodes are nodes of the receiver Digraph. |
DigraphEdge |
addEdgeFromTo(int nodeIndex1,
int nodeIndex2)
Adds a new edge of the appropriate DigraphEdge subclass to connect two given nodes indicated by their indices (0, 1, 2, ... |
DigraphNode |
addNode()
Adds a new node to the Digraph and returns it. |
Digraph |
copyDigraph()
Returns a copy of the receiver Digraph, without sharing of nodes or edges. |
DigraphEdge |
edgeAt(int pos)
Returns the DigraphEdge at given position in the list of edges; null if no such edge. |
java.util.ArrayList<DigraphEdge> |
getEdges()
Returns the ArrayList of DigraphEdges in the Digraph |
java.util.ArrayList<DigraphNode> |
getNodes()
Returns the ArrayList of DigraphNodes in the Digraph |
boolean |
isCyclic()
Returns true of the Digraph has cycles; false if not |
DigraphNode |
nodeAt(int pos)
Returns the DigraphNode at given position in the list of nodes; null if no such node. |
int |
numberOfEdges()
Returns the number of edges in the Digraph |
int |
numberOfNodes()
Returns the number of nodes in the Digraph |
DigraphEdge |
removeEdge(DigraphEdge aDigraphEdge)
Removes a given edge, provided it is in the Digraph. |
DigraphNode |
removeNode(DigraphNode aDigraphNode)
Removes a given node, provided it is in the Digraph, after first removing all edges in and out of it. |
java.util.ArrayList<DigraphNode> |
sinks()
Returns an ArrayList containing the DigraphNodes in the Digraph that have no outgoing edges. |
java.util.ArrayList<DigraphNode> |
sources()
Returns an ArrayList containing the DigraphNodes in the Digraph that have no incoming edges. |
java.lang.String |
toString()
Returns a string that represents the Digraph in the following form: - the number of nodes in digraphNodes; - a parenthesized list of edge representations, each a parenthesized pair: (fromNodeNumber, toNodeNumber) where fromNodeNumber and toNodeNumber are indices of nodes in digraphNodes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.ArrayList<DigraphEdge> digraphEdges
protected java.util.ArrayList<DigraphNode> digraphNodes
protected static java.lang.String EdgeClassName
| Constructor Detail |
|---|
public Digraph()
| Method Detail |
|---|
public DigraphEdge addEdgeFromTo(int nodeIndex1,
int nodeIndex2)
throws java.lang.ClassNotFoundException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessException
public DigraphEdge addEdgeFromNodeToNode(DigraphNode node1,
DigraphNode node2)
throws java.lang.ClassNotFoundException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
node1 - the node that the edge is to go fromnode2 - the node that the edge is to go to
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessExceptionpublic DigraphNode addNode()
public Digraph copyDigraph()
throws java.lang.ClassNotFoundException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessExceptionpublic DigraphEdge edgeAt(int pos)
pos - the index of the edge to be foundpublic java.util.ArrayList<DigraphEdge> getEdges()
public java.util.ArrayList<DigraphNode> getNodes()
public boolean isCyclic()
throws java.lang.ClassNotFoundException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessExceptionpublic DigraphNode nodeAt(int pos)
pos - the index of the node to be foundpublic int numberOfEdges()
public int numberOfNodes()
public DigraphEdge removeEdge(DigraphEdge aDigraphEdge)
aDigraphEdge - the edge to be removed
public DigraphNode removeNode(DigraphNode aDigraphNode)
aDigraphNode - the node to be removed
public java.util.ArrayList<DigraphNode> sinks()
public java.util.ArrayList<DigraphNode> sources()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||