Package com.ibm.wala.util.graph
Class AbstractGraph<T>
- java.lang.Object
-
- com.ibm.wala.util.graph.AbstractGraph<T>
-
- All Implemented Interfaces:
EdgeManager<T>,Graph<T>,NodeManager<T>,Iterable<T>
- Direct Known Subclasses:
AbstractLabeledGraph,AbstractNumberedGraph,BasicGraph,InvertedGraph,SelfLoopAddedGraph
public abstract class AbstractGraph<T> extends Object implements Graph<T>
Basic functionality for aGraphthat delegates node and edge management.
-
-
Constructor Summary
Constructors Constructor Description AbstractGraph()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddEdge(T src, T dst)voidaddNode(T n)add a node to this graphbooleancontainsNode(@Nullable T n)protected StringedgeString(T from, T to)protected abstract EdgeManager<T>getEdgeManager()protected abstract NodeManager<T>getNodeManager()intgetNumberOfNodes()intgetPredNodeCount(T n)Return the number ofimmediate predecessornodes of nIterator<T>getPredNodes(@Nullable T n)Return anIteratorover the immediate predecessor nodes of nintgetSuccNodeCount(T n)Return the number ofimmediate successornodes of this Node in the GraphIterator<T>getSuccNodes(@Nullable T n)Return an Iterator over the immediate successor nodes of nbooleanhasEdge(@Nullable T src, @Nullable T dst)Iterator<T>iterator()protected StringnodeString(T n, boolean forEdge)voidremoveAllIncidentEdges(T node)voidremoveEdge(T src, T dst)voidremoveIncomingEdges(T node)voidremoveNode(T n)remove a node from this graphvoidremoveNodeAndEdges(T N)remove a node and all its incident edgesvoidremoveOutgoingEdges(T node)Stream<T>stream()StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getNodeManager
protected abstract NodeManager<T> getNodeManager()
- Returns:
- the object which manages nodes in the graph
-
getEdgeManager
protected abstract EdgeManager<T> getEdgeManager()
- Returns:
- the object which manages edges in the graph
-
stream
public Stream<T> stream()
- Specified by:
streamin interfaceNodeManager<T>- Returns:
- a
Streamof the nodes in this graph
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceNodeManager<T>- Returns:
- an
Iteratorof the nodes in this graph - See Also:
NodeManager.iterator()
-
getNumberOfNodes
public int getNumberOfNodes()
- Specified by:
getNumberOfNodesin interfaceNodeManager<T>- Returns:
- the number of nodes in this graph
- See Also:
NodeManager.getNumberOfNodes()
-
getPredNodeCount
public int getPredNodeCount(T n) throws IllegalArgumentException
Description copied from interface:EdgeManagerReturn the number ofimmediate predecessornodes of n- Specified by:
getPredNodeCountin interfaceEdgeManager<T>- Returns:
- the number of immediate predecessors of n.
- Throws:
IllegalArgumentException- See Also:
EdgeManager.getPredNodeCount(java.lang.Object)
-
getPredNodes
public Iterator<T> getPredNodes(@Nullable T n) throws IllegalArgumentException
Description copied from interface:EdgeManagerReturn anIteratorover the immediate predecessor nodes of nThis method never returns
null.- Specified by:
getPredNodesin interfaceEdgeManager<T>- Returns:
- an
Iteratorover the immediate predecessor nodes of this Node. - Throws:
IllegalArgumentException- See Also:
EdgeManager.getPredNodes(java.lang.Object)
-
getSuccNodeCount
public int getSuccNodeCount(T n) throws IllegalArgumentException
Description copied from interface:EdgeManagerReturn the number ofimmediate successornodes of this Node in the Graph- Specified by:
getSuccNodeCountin interfaceEdgeManager<T>- Returns:
- the number of immediate successor Nodes of this Node in the Graph.
- Throws:
IllegalArgumentException- See Also:
EdgeManager.getSuccNodeCount(java.lang.Object)
-
getSuccNodes
public Iterator<T> getSuccNodes(@Nullable T n) throws IllegalArgumentException
Description copied from interface:EdgeManagerReturn an Iterator over the immediate successor nodes of nThis method never returns
null.- Specified by:
getSuccNodesin interfaceEdgeManager<T>- Returns:
- an Iterator over the immediate successor nodes of n
- Throws:
IllegalArgumentException- See Also:
EdgeManager.getSuccNodes(java.lang.Object)
-
addNode
public void addNode(T n)
Description copied from interface:NodeManageradd a node to this graph- Specified by:
addNodein interfaceNodeManager<T>- See Also:
NodeManager.addNode(Object)
-
addEdge
public void addEdge(T src, T dst) throws IllegalArgumentException
- Specified by:
addEdgein interfaceEdgeManager<T>- Throws:
IllegalArgumentException- See Also:
EdgeManager.addEdge(Object, Object)
-
removeEdge
public void removeEdge(T src, T dst) throws IllegalArgumentException
- Specified by:
removeEdgein interfaceEdgeManager<T>- Throws:
IllegalArgumentException- See Also:
EdgeManager.removeEdge(java.lang.Object, java.lang.Object)
-
hasEdge
public boolean hasEdge(@Nullable T src, @Nullable T dst)
- Specified by:
hasEdgein interfaceEdgeManager<T>- See Also:
EdgeManager.hasEdge(java.lang.Object, java.lang.Object)
-
removeAllIncidentEdges
public void removeAllIncidentEdges(T node) throws IllegalArgumentException
- Specified by:
removeAllIncidentEdgesin interfaceEdgeManager<T>- Throws:
IllegalArgumentException- See Also:
EdgeManager.removeAllIncidentEdges(Object)
-
removeIncomingEdges
public void removeIncomingEdges(T node) throws IllegalArgumentException
- Specified by:
removeIncomingEdgesin interfaceEdgeManager<T>- Throws:
IllegalArgumentException- See Also:
EdgeManager.removeAllIncidentEdges(Object)
-
removeOutgoingEdges
public void removeOutgoingEdges(T node) throws IllegalArgumentException
- Specified by:
removeOutgoingEdgesin interfaceEdgeManager<T>- Throws:
IllegalArgumentException- See Also:
EdgeManager.removeAllIncidentEdges(Object)
-
removeNodeAndEdges
public void removeNodeAndEdges(T N) throws IllegalArgumentException
Description copied from interface:Graphremove a node and all its incident edges- Specified by:
removeNodeAndEdgesin interfaceGraph<T>- Throws:
IllegalArgumentException- See Also:
NodeManager.removeNode(Object)
-
removeNode
public void removeNode(T n) throws IllegalArgumentException
Description copied from interface:NodeManagerremove a node from this graph- Specified by:
removeNodein interfaceNodeManager<T>- Throws:
IllegalArgumentException- See Also:
NodeManager.removeNode(Object)
-
containsNode
public boolean containsNode(@Nullable T n)
- Specified by:
containsNodein interfaceNodeManager<T>- Returns:
- true iff the graph contains the specified node
- See Also:
NodeManager.containsNode(Object)
-
-