|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.walend.digraph.AbstractMatrixGEDigraph
A GEDigraph backed by an ArrayList of nodes and a boolean[][] matrix that stores edges.
Nested Class Summary | |
protected class |
AbstractMatrixGEDigraph.MatrixEdgeIterator
|
protected class |
AbstractMatrixGEDigraph.NodeIterator
|
Field Summary | |
private int |
edgeCount
|
private boolean[][] |
edges
|
private int |
nodeCount
|
private java.util.ArrayList |
nodes
|
Fields inherited from interface net.walend.digraph.GEDigraph |
EMPTY |
Constructor Summary | |
protected |
AbstractMatrixGEDigraph(CEDigraph digraph)
|
protected |
AbstractMatrixGEDigraph(GEDigraph digraph)
|
protected |
AbstractMatrixGEDigraph(int nodeCapacity)
|
protected |
AbstractMatrixGEDigraph(UEDigraph digraph)
|
Method Summary | |
protected boolean |
addEdge(int fromIndex,
int toIndex)
|
protected boolean |
addEdge(java.lang.Object fromNode,
java.lang.Object toNode)
Return true if the digraph changes when this edge is added, false if the digraph is unchanged. |
protected boolean |
addNode(java.lang.Object node)
Return true if the node is added successfully, false if the digraph does not change. |
protected boolean |
addNodes(java.util.Set nodes)
Return true if adding the nodes changes the digraph. |
private void |
checkNode(java.lang.Object node)
|
protected void |
clear()
Remove all nodes and edges from the GEDigraph |
protected void |
clearEdges()
Remove all the edges from the GEDigraph. |
boolean |
containsEdge(int fromIndex,
int toIndex)
|
boolean |
containsEdge(java.lang.Object fromNode,
java.lang.Object toNode)
Returns true if the digraph contains any edge from fromNode to toNode. |
boolean |
containsGEDigraph(GEDigraph digraph)
Returns true if digraph is a subgraph of this GEDigraph. |
boolean |
containsNode(int index)
|
boolean |
containsNode(java.lang.Object node)
|
boolean |
containsNodes(java.util.Set nodes)
|
int |
countInboundEdges(int toIndex)
|
int |
countInboundEdges(java.lang.Object node)
|
int |
countOutboundEdges(int fromIndex)
|
int |
countOutboundEdges(java.lang.Object node)
|
int |
edgeCount()
This method scans the edges matrix to count them. |
EdgeNodeIterator |
edgeNodeIterator()
Returns an iterator that iterates across pairs of nodes that make edges. |
int[] |
getFromIndices(int toIndex)
|
java.util.Set |
getFromNodes(int toIndex)
|
java.util.Set |
getFromNodes(java.lang.Object node)
Returns the set of nodes that can reach this node by crossing one edge. |
java.lang.Object |
getNode(int index)
|
int |
getNodeIndex(java.lang.Object node)
|
java.util.Set |
getNodes()
|
java.lang.Class |
getPrincipleInterface()
Returns the class's principle interface for state comparisons. |
int[] |
getToIndices(int fromIndex)
|
java.util.Set |
getToNodes(int fromIndex)
|
java.util.Set |
getToNodes(java.lang.Object node)
Returns the set of nodes that can be reached from this node by crossing one edge. |
protected void |
growMatrix(int newSize)
This method doubles the size of the matrix |
IndexedEdgeNodeIterator |
indexedEdgeNodeIterator()
|
IndexedIterator |
indexedNodeIterator()
|
protected void |
insureCapacity(int capacity)
|
GEDigraph |
intersectWithGEDigraph(GEDigraph digraph)
Returns a new digraph that is the intersection of this with digraph. |
boolean |
isEdgeFree()
Returns true if this GEDigraph has no edges. |
boolean |
isEmpty()
|
int |
nodeCapacity()
Returns the maximum capacity for nodes in this IndexedDigraph. |
int |
nodeCount()
|
int[] |
nodeIndices()
Returns an array if ints that show which node indices are being used. |
java.util.Iterator |
nodeIterator()
Implementations should explicitly state how they interpret nodeIterator()'s remove method. |
private void |
putNodeInFirstNull(java.lang.Object node)
|
protected boolean |
removeEdge(int fromIndex,
int toIndex)
|
protected boolean |
removeEdge(java.lang.Object fromNode,
java.lang.Object toNode)
Return true if the digraph changes when the edge is removed, false if the digraph didn't have an edge between these two nodes. |
protected int |
removeGEDigraph(GEDigraph digraph)
Return the number of edges orphaned when digraph is removed |
protected int |
removeNode(int index)
|
protected int |
removeNode(java.lang.Object node)
Return the number of orphaned edges that were lost when this node is removed. |
protected int |
removeNodes(java.util.Set nodes)
Return the number of edges orphaned edges when these nodes are removed. |
protected int |
retainNodes(java.util.Set retainedNodes)
Return the number of orphaned edges when the nodes are removed. |
boolean |
sameGEDigraphAs(GEDigraph digraph)
Returns true if digraph is the same as this; that is, if this.containsGEDigraph(digraph) and digraph.containsGEDigraph(this). |
boolean |
sameStateAs(HasState victim)
If two HasStates have the same internal state, return true. |
protected java.lang.Object |
setNode(int index,
java.lang.Object node)
|
java.lang.String |
toString()
|
GEDigraph |
unionGEDigraph(GEDigraph digraph)
Returns a new digraph that is the union of this with digraph. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private int nodeCount
private java.util.ArrayList nodes
private int edgeCount
private boolean[][] edges
Constructor Detail |
protected AbstractMatrixGEDigraph(int nodeCapacity)
protected AbstractMatrixGEDigraph(GEDigraph digraph)
protected AbstractMatrixGEDigraph(CEDigraph digraph)
protected AbstractMatrixGEDigraph(UEDigraph digraph)
Method Detail |
public int nodeCount()
nodeCount
in interface Digraph
public int edgeCount()
edgeCount
in interface Digraph
public boolean isEmpty()
isEmpty
in interface Digraph
private void checkNode(java.lang.Object node)
public boolean containsNode(java.lang.Object node)
containsNode
in interface Digraph
public boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
containsEdge
in interface Digraph
NodeMissingException
- if either node is missing from the digraph.public int countInboundEdges(java.lang.Object node) throws NodeMissingException
countInboundEdges
in interface Digraph
NodeMissingException
- if node is not in the digraph.public int countOutboundEdges(java.lang.Object node) throws NodeMissingException
countOutboundEdges
in interface Digraph
NodeMissingException
- if node is not in the digraph.public java.util.Set getFromNodes(java.lang.Object node) throws NodeMissingException
getFromNodes
in interface Digraph
NodeMissingException
- if node is not in the digraph.public java.util.Set getToNodes(java.lang.Object node) throws NodeMissingException
getToNodes
in interface Digraph
NodeMissingException
- if node is not in the digraph.public java.util.Iterator nodeIterator()
nodeIterator
in interface Digraph
public EdgeNodeIterator edgeNodeIterator()
edgeNodeIterator
in interface Digraph
public java.util.Set getNodes()
getNodes
in interface Digraph
public boolean isEdgeFree()
isEdgeFree
in interface Digraph
public boolean containsNodes(java.util.Set nodes)
containsNodes
in interface Digraph
public boolean containsGEDigraph(GEDigraph digraph)
containsGEDigraph
in interface GEDigraph
public boolean sameGEDigraphAs(GEDigraph digraph)
sameGEDigraphAs
in interface GEDigraph
public GEDigraph intersectWithGEDigraph(GEDigraph digraph)
intersectWithGEDigraph
in interface GEDigraph
public GEDigraph unionGEDigraph(GEDigraph digraph)
unionGEDigraph
in interface GEDigraph
public java.lang.Class getPrincipleInterface()
getPrincipleInterface
in interface HasState
public boolean sameStateAs(HasState victim)
For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.
sameStateAs
in interface HasState
public int nodeCapacity()
nodeCapacity
in interface IndexedDigraph
public int[] nodeIndices()
nodeIndices
in interface IndexedDigraph
public boolean containsNode(int index)
containsNode
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public java.lang.Object getNode(int index)
getNode
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public int getNodeIndex(java.lang.Object node) throws NodeMissingException
getNodeIndex
in interface IndexedDigraph
a
- NodeMissingException if the node is not in the digraph.
NodeMissingException
public boolean containsEdge(int fromIndex, int toIndex)
containsEdge
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public int countInboundEdges(int toIndex)
countInboundEdges
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public int countOutboundEdges(int fromIndex)
countOutboundEdges
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public java.util.Set getFromNodes(int toIndex)
getFromNodes
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public int[] getFromIndices(int toIndex)
getFromIndices
in interface IndexedDigraph
public java.util.Set getToNodes(int fromIndex)
getToNodes
in interface IndexedDigraph
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndices() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.public int[] getToIndices(int fromIndex)
getToIndices
in interface IndexedDigraph
public IndexedEdgeNodeIterator indexedEdgeNodeIterator()
indexedEdgeNodeIterator
in interface IndexedDigraph
public IndexedIterator indexedNodeIterator()
indexedNodeIterator
in interface IndexedDigraph
protected void growMatrix(int newSize)
private void putNodeInFirstNull(java.lang.Object node)
protected boolean addNode(java.lang.Object node)
protected boolean addEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
NodeMissingException
- if either node is not in the digraph.protected int removeNode(java.lang.Object node) throws NodeMissingException
NodeMissingException
- if the node is not in the digraphprotected boolean removeEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
NodeMissingException
- if either node is not in the digraphprotected boolean addNodes(java.util.Set nodes)
protected int removeNodes(java.util.Set nodes)
protected int removeGEDigraph(GEDigraph digraph)
protected int retainNodes(java.util.Set retainedNodes)
protected void clear()
protected void clearEdges()
public java.lang.String toString()
toString
in class java.lang.Object
protected void insureCapacity(int capacity)
protected java.lang.Object setNode(int index, java.lang.Object node)
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndicies() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.protected boolean addEdge(int fromIndex, int toIndex)
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndicies() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.protected int removeNode(int index)
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndicies() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.protected boolean removeEdge(int fromIndex, int toIndex)
java.lang.ArrayIndexOutOfBoundsException
- if index does not have a node. Use nodeIndicies() or getNodeIndex() to avoid these. In your code, catch ArrayIndexOutOfBoundsException and throw a ConcurrentModificationException if you think that's the problem.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |