|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.walend.digraph.AbstractHashUEDigraph
This abstract class implements the UEDigraph interface using three HashMaps. It's great for sparse graphs. Subclass it as is for an immutable UEDigraph. Mix in the MutableUEDigraph interface for one you can change.
Nested Class Summary | |
protected class |
AbstractHashUEDigraph.HashEdgeIterator
|
protected class |
AbstractHashUEDigraph.IteratorWrapper
|
protected class |
AbstractHashUEDigraph.NodePair
|
Field Summary | |
private MutableMap |
edgesToFromNodes
|
private MutableMap |
edgesToToNodes
|
private MutableMap |
nodePairsToEdges
|
private MutableSet |
nodes
|
Fields inherited from interface net.walend.digraph.UEDigraph |
EMPTY |
Constructor Summary | |
protected |
AbstractHashUEDigraph(int nodeCapacity,
int edgeCapacity)
|
protected |
AbstractHashUEDigraph(UEDigraph digraph)
|
Method Summary | |
protected java.lang.Object |
addEdge(java.lang.Object fromNode,
java.lang.Object toNode,
java.lang.Object edge)
|
protected boolean |
addNode(java.lang.Object node)
|
protected boolean |
addNodes(Set nodesToAdd)
|
protected void |
clear()
|
protected void |
clearEdges()
|
boolean |
containsEdge(java.lang.Object edge)
Returns true if edge exists in the digraph anywhere |
boolean |
containsEdge(java.lang.Object fromNode,
java.lang.Object toNode)
Returns true if the digraph contains any edge from fromNode to toNode |
boolean |
containsEdge(java.lang.Object fromNode,
java.lang.Object toNode,
java.lang.Object edge)
Returns true if edge links fromNode to toNode |
boolean |
containsEdges(Set edges)
|
boolean |
containsNode(java.lang.Object node)
|
boolean |
containsNodes(Set nodes)
|
boolean |
containsUEDigraph(UEDigraph digraph)
Returns true if digraph is a subgraph of this UEDigraph. |
int |
countInboundEdges(java.lang.Object node)
Inefficient. |
int |
countOutboundEdges(java.lang.Object node)
Inefficient. |
int |
edgeCount()
|
EdgeIterator |
edgeIterator()
Since HashUEDigraph is immutable, edgeIterator()'s remove() method throws an UnsupportedOperationException. |
java.lang.Object |
getEdge(java.lang.Object fromNode,
java.lang.Object toNode)
Returns null if either node is not in the digraph or if no edge links fromNode to toNode |
Set |
getEdges()
|
java.lang.Object |
getFromNode(java.lang.Object edge)
Returns null if edge is not in the digraph. |
Set |
getFromNodes(java.lang.Object node)
Returns the set of nodes that can reach this node by crossing one edge. |
Set |
getInboundEdges(java.lang.Object node)
Returns the empty set if node is not in the digraph, or if node has no inbound edges. |
Set |
getNodes()
|
Set |
getOutboundEdges(java.lang.Object node)
Returns the empty set if node is not in the digraph, or if node has no outbound edges. |
java.lang.Class |
getPrincipleInterface()
Returns the class's principle interface for state comparisons. |
java.lang.Object |
getToNode(java.lang.Object edge)
Returns null if edge is not in the digraph |
Set |
getToNodes(java.lang.Object node)
Returns the set of nodes that can be reached from this node by crossing one edge. |
UEDigraph |
intersectWithUEDigraph(UEDigraph digraph)
Returns a new digraph that is the intersection of this with digraph. |
boolean |
isEdgeFree()
Returns true if this UEDigraph has no edges. |
boolean |
isEmpty()
|
int |
nodeCount()
|
java.util.Iterator |
nodeIterator()
Since HashUEDigraph is immutable, nodeIterator()'s remove() method throws an UnsupportedOperationException. |
protected boolean |
removeEdge(java.lang.Object edge)
|
protected java.lang.Object |
removeEdge(java.lang.Object fromNode,
java.lang.Object toNode)
|
protected boolean |
removeEdges(Set edges)
|
protected Set |
removeNode(java.lang.Object node)
|
protected Set |
removeNodes(Set nodesToRemove)
|
protected Set |
removeUEDigraph(UEDigraph digraph)
|
protected boolean |
retainEdges(Set retainedEdges)
|
protected Set |
retainNodes(Set retainedNodes)
|
boolean |
sameStateAs(HasState victem)
If two HasStates have the same internal state, return true. |
boolean |
sameUEDigraphAs(UEDigraph digraph)
Returns true if digraph is the same as this, and all their contents have the same state. |
java.lang.String |
toString()
|
UEDigraph |
unionUEDigraph(UEDigraph 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 MutableSet nodes
private MutableMap nodePairsToEdges
private MutableMap edgesToToNodes
private MutableMap edgesToFromNodes
Constructor Detail |
protected AbstractHashUEDigraph(int nodeCapacity, int edgeCapacity)
protected AbstractHashUEDigraph(UEDigraph digraph)
Method Detail |
public int nodeCount()
nodeCount
in interface UEDigraph
public int edgeCount()
edgeCount
in interface UEDigraph
public boolean isEmpty()
isEmpty
in interface UEDigraph
public boolean containsNode(java.lang.Object node)
containsNode
in interface UEDigraph
public boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
UEDigraph
containsEdge
in interface UEDigraph
public boolean containsEdge(java.lang.Object fromNode, java.lang.Object toNode, java.lang.Object edge) throws NodeMissingException
containsEdge
in interface UEDigraph
public boolean containsEdge(java.lang.Object edge)
containsEdge
in interface UEDigraph
public int countInboundEdges(java.lang.Object node) throws NodeMissingException
countInboundEdges
in interface UEDigraph
public int countOutboundEdges(java.lang.Object node) throws NodeMissingException
countOutboundEdges
in interface UEDigraph
public Set getInboundEdges(java.lang.Object node) throws NodeMissingException
Inefficient. Iterates through all the edges.
getInboundEdges
in interface UEDigraph
public Set getOutboundEdges(java.lang.Object node) throws NodeMissingException
Inefficient. Iterates through all the edges.
getOutboundEdges
in interface UEDigraph
public java.lang.Object getFromNode(java.lang.Object edge) throws EdgeMissingException
getFromNode
in interface UEDigraph
public java.lang.Object getToNode(java.lang.Object edge) throws EdgeMissingException
getToNode
in interface UEDigraph
public java.lang.Object getEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
getEdge
in interface UEDigraph
public Set getFromNodes(java.lang.Object node) throws NodeMissingException
Inefficient. Iterates through all the edges.
getFromNodes
in interface UEDigraph
public Set getToNodes(java.lang.Object node) throws NodeMissingException
Inefficient. Iterates through all the edges.
getToNodes
in interface UEDigraph
public java.util.Iterator nodeIterator()
nodeIterator
in interface UEDigraph
public EdgeIterator edgeIterator()
edgeIterator
in interface UEDigraph
public Set getNodes()
getNodes
in interface UEDigraph
public Set getEdges()
getEdges
in interface UEDigraph
public boolean isEdgeFree()
isEdgeFree
in interface UEDigraph
public boolean containsNodes(Set nodes)
containsNodes
in interface UEDigraph
public boolean containsEdges(Set edges)
containsEdges
in interface UEDigraph
public boolean containsUEDigraph(UEDigraph digraph)
containsUEDigraph
in interface UEDigraph
public boolean sameUEDigraphAs(UEDigraph digraph)
sameUEDigraphAs
in interface UEDigraph
public UEDigraph intersectWithUEDigraph(UEDigraph digraph)
intersectWithUEDigraph
in interface UEDigraph
public UEDigraph unionUEDigraph(UEDigraph digraph)
unionUEDigraph
in interface UEDigraph
public java.lang.Class getPrincipleInterface()
HasState
getPrincipleInterface
in interface HasState
public boolean sameStateAs(HasState victem)
HasState
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
protected boolean addNode(java.lang.Object node)
protected java.lang.Object addEdge(java.lang.Object fromNode, java.lang.Object toNode, java.lang.Object edge) throws NodeMissingException, EdgeNotUniqueException
protected Set removeNode(java.lang.Object node) throws NodeMissingException
protected boolean removeEdge(java.lang.Object edge)
protected java.lang.Object removeEdge(java.lang.Object fromNode, java.lang.Object toNode) throws NodeMissingException
protected boolean addNodes(Set nodesToAdd)
protected Set removeNodes(Set nodesToRemove)
protected boolean removeEdges(Set edges)
protected Set removeUEDigraph(UEDigraph digraph)
protected Set retainNodes(Set retainedNodes)
protected boolean retainEdges(Set retainedEdges)
protected void clear()
protected void clearEdges()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |