Package cdc.util.graphs.impl
Class BasicLightGraph<N,E extends GraphEdge<N>>
- java.lang.Object
-
- cdc.util.graphs.impl.BasicLightGraph<N,E>
-
- Type Parameters:
N- Node type.E- Edge type.
- All Implemented Interfaces:
GraphAdapter<N,E>
- Direct Known Subclasses:
BasicSuperLightGraph
public class BasicLightGraph<N,E extends GraphEdge<N>> extends Object implements GraphAdapter<N,E>
Basic and naive graph implementation using light nodes.Node can be any object.
- Author:
- Damien Carbonne
-
-
Constructor Summary
Constructors Constructor Description BasicLightGraph()BasicLightGraph(boolean sorted)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <X extends E>
XaddEdge(X edge)Adds an edge to this graph.<X extends N>
XaddNode(X node)Adds a node to this graph.voidclear()Clears this graph.booleancontainsEdge(E edge)booleancontainsEdge(N source, N target)Returntrueif this graph contains at least one edge between a source node and a target node.booleancontainsNode(N node)Iterable<E>getEdges()Iterable<? extends E>getEdges(N node, EdgeDirection direction)Iterable<N>getNodes()NgetTip(E edge, EdgeTip tip)booleanisLocked()voidremoveEdge(E edge)Removes an edge from this graph.voidremoveNode(N node)Remove a node from this graph.voidsetLocked(boolean locked)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cdc.util.graphs.GraphAdapter
getConnectivity, getEdges, getEdges, getEdgesCount, getEdgesCount, getEdgesCount, getEdgesStream, getEdgesStream, getEdgesStream, getLeaves, getNodes, getNodes, getNodesCount, getNodesStream, getRoots, hasEdge, hasEdges, hasEdges, hasEdges, hasNodes, isLeaf, isRoot
-
-
-
-
Method Detail
-
setLocked
public void setLocked(boolean locked)
-
isLocked
public boolean isLocked()
-
clear
public void clear()
Clears this graph.- Throws:
cdc.util.lang.InvalidStateException- When this graph is locked.
-
addNode
public <X extends N> X addNode(X node)
Adds a node to this graph.- Type Parameters:
X- The node type.- Parameters:
node- The node.- Returns:
- The passed
node. - Throws:
IllegalArgumentException- Whennodeisnullor is already contained in this graph.cdc.util.lang.InvalidStateException- When this graph is locked.
-
removeNode
public void removeNode(N node)
Remove a node from this graph.- Parameters:
node- The node.- Throws:
IllegalArgumentException- Whennodeisnullor is not contained in this graph.cdc.util.lang.InvalidStateException- When this graph is locked.
-
addEdge
public <X extends E> X addEdge(X edge)
Adds an edge to this graph.- Type Parameters:
X- The edge type.- Parameters:
edge- The edge.- Returns:
- The passed
edge. - Throws:
IllegalArgumentException- Whenedgeisnullor is already contained in this graph, oredgesource or target don't not belong to this graph.cdc.util.lang.InvalidStateException- When this graph is locked.
-
removeEdge
public void removeEdge(E edge)
Removes an edge from this graph.- Parameters:
edge- The edge.- Throws:
IllegalArgumentException- Whenedgeisnullor is not contained in this graph.cdc.util.lang.InvalidStateException- When this graph is locked.
-
containsNode
public final boolean containsNode(N node)
- Specified by:
containsNodein interfaceGraphAdapter<N,E extends GraphEdge<N>>
-
containsEdge
public final boolean containsEdge(E edge)
- Specified by:
containsEdgein interfaceGraphAdapter<N,E extends GraphEdge<N>>
-
containsEdge
public boolean containsEdge(N source, N target)
Returntrueif this graph contains at least one edge between a source node and a target node.- Parameters:
source- The source node.target- The target node.- Returns:
trueif this graph contains at least one edge betweensourceandtarget.
-
getEdges
public final Iterable<? extends E> getEdges(N node, EdgeDirection direction)
-
-