|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--net.walend.digraph.AbstractMatrixGEDigraph
|
+--net.walend.digraph.AbstractLMGEDigraph
|
+--net.walend.digraph.MutableLMGEDigraph
This class implements the GEDigraph interface using an ArrayList and a boolean matrix and keeps an additional int[][] that shows what nodes can be reached from what other nodes. This speeds up the getFromIndices[] method to constant time and the EdgeIterator to O(e) time. It also slows down the removeEdge to O(n) and the removeNode method to O(n^2).
| Nested Class Summary |
| Nested classes inherited from class net.walend.digraph.AbstractLMGEDigraph |
AbstractLMGEDigraph.LMEdgeNodeIterator |
| Nested classes inherited from class net.walend.digraph.AbstractMatrixGEDigraph |
AbstractMatrixGEDigraph.MatrixEdgeIterator, AbstractMatrixGEDigraph.NodeIterator |
| Field Summary | |
private static int |
DEFAULTSIZE
|
| Fields inherited from class net.walend.digraph.AbstractLMGEDigraph |
|
| Fields inherited from class net.walend.digraph.AbstractMatrixGEDigraph |
|
| Fields inherited from interface net.walend.digraph.GEDigraph |
EMPTY |
| Constructor Summary | |
MutableLMGEDigraph()
|
|
MutableLMGEDigraph(CEDigraph digraph)
|
|
MutableLMGEDigraph(GEDigraph digraph)
|
|
MutableLMGEDigraph(int nodeCapacity)
|
|
MutableLMGEDigraph(UEDigraph digraph)
|
|
| Method Summary | |
boolean |
addEdge(int fromIndex,
int toIndex)
|
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. |
boolean |
addNode(java.lang.Object node)
Return true if the node is added successfully, false if the digraph does not change. |
boolean |
addNodes(java.util.Set nodes)
Return true if adding the nodes changes the digraph. |
void |
clear()
Remove all nodes and edges from the GEDigraph |
void |
clearEdges()
Remove all the edges from the GEDigraph. |
void |
insureCapacity(int capacity)
|
boolean |
removeEdge(int fromIndex,
int toIndex)
|
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. |
int |
removeGEDigraph(GEDigraph digraph)
Return the number of edges orphaned when digraph is removed |
int |
removeNode(int index)
|
int |
removeNode(java.lang.Object node)
Return the number of orphaned edges that were lost when this node is removed. |
int |
removeNodes(java.util.Set nodes)
Return the number of edges orphaned edges when these nodes are removed. |
int |
retainNodes(java.util.Set nodes)
Return the number of orphaned edges when the nodes are removed. |
java.lang.Object |
setNode(int index,
java.lang.Object node)
|
| Methods inherited from class net.walend.digraph.AbstractLMGEDigraph |
countInboundEdges, getFromIndices, growMatrix |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.walend.digraph.GEDigraph |
containsGEDigraph, intersectWithGEDigraph, sameGEDigraphAs, unionGEDigraph |
| Methods inherited from interface net.walend.digraph.Digraph |
containsEdge, containsNode, containsNodes, countInboundEdges, countOutboundEdges, edgeCount, edgeNodeIterator, getFromNodes, getNodes, getToNodes, isEdgeFree, isEmpty, nodeCount, nodeIterator |
| Methods inherited from interface net.walend.collection.HasState |
getPrincipleInterface, sameStateAs |
| Methods inherited from interface net.walend.digraph.IndexedDigraph |
containsEdge, containsNode, countInboundEdges, countOutboundEdges, getFromIndices, getFromNodes, getNode, getNodeIndex, getToIndices, getToNodes, indexedEdgeNodeIterator, indexedNodeIterator, nodeCapacity, nodeIndices |
| Field Detail |
private static final int DEFAULTSIZE
| Constructor Detail |
public MutableLMGEDigraph()
public MutableLMGEDigraph(int nodeCapacity)
public MutableLMGEDigraph(GEDigraph digraph)
public MutableLMGEDigraph(CEDigraph digraph)
public MutableLMGEDigraph(UEDigraph digraph)
| Method Detail |
public boolean addNode(java.lang.Object node)
MutableGEDigraph
addNode in interface MutableGEDigraphaddNode in class AbstractMatrixGEDigraph
public boolean addEdge(java.lang.Object fromNode,
java.lang.Object toNode)
throws NodeMissingException
MutableGEDigraph
addEdge in interface MutableGEDigraphaddEdge in class AbstractMatrixGEDigraphNodeMissingException - if either node is not in the digraph.
public int removeNode(java.lang.Object node)
throws NodeMissingException
MutableGEDigraph
removeNode in interface MutableGEDigraphremoveNode in class AbstractMatrixGEDigraphNodeMissingException - if the node is not in the digraph
public boolean removeEdge(java.lang.Object fromNode,
java.lang.Object toNode)
throws NodeMissingException
MutableGEDigraph
removeEdge in interface MutableGEDigraphremoveEdge in class AbstractMatrixGEDigraphNodeMissingException - if either node is not in the digraphpublic boolean addNodes(java.util.Set nodes)
MutableGEDigraph
addNodes in interface MutableGEDigraphaddNodes in class AbstractMatrixGEDigraphpublic int removeNodes(java.util.Set nodes)
MutableGEDigraph
removeNodes in interface MutableGEDigraphremoveNodes in class AbstractMatrixGEDigraphpublic int removeGEDigraph(GEDigraph digraph)
MutableGEDigraph
removeGEDigraph in interface MutableGEDigraphremoveGEDigraph in class AbstractMatrixGEDigraphpublic int retainNodes(java.util.Set nodes)
MutableGEDigraph
retainNodes in interface MutableGEDigraphretainNodes in class AbstractMatrixGEDigraphpublic void clear()
MutableGEDigraph
clear in interface MutableGEDigraphclear in class AbstractMatrixGEDigraphpublic void clearEdges()
MutableGEDigraph
clearEdges in interface MutableGEDigraphclearEdges in class AbstractLMGEDigraphpublic void insureCapacity(int capacity)
insureCapacity in interface IndexedMutableGEDigraphinsureCapacity in class AbstractMatrixGEDigraph
public java.lang.Object setNode(int index,
java.lang.Object node)
setNode in interface IndexedMutableGEDigraphsetNode in class AbstractMatrixGEDigraphjava.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.
public boolean addEdge(int fromIndex,
int toIndex)
addEdge in interface IndexedMutableGEDigraphaddEdge in class AbstractLMGEDigraphjava.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.public int removeNode(int index)
removeNode in interface IndexedMutableGEDigraphremoveNode in class AbstractLMGEDigraphjava.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.
public boolean removeEdge(int fromIndex,
int toIndex)
removeEdge in interface IndexedMutableGEDigraphremoveEdge in class AbstractLMGEDigraphjava.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 | ||||||||||