Package cdc.graphs.impl
Class BasicLightGraph<N,E extends GraphEdge<N>>
java.lang.Object
cdc.graphs.impl.BasicLightGraph<N,E>
- Type Parameters:
N- Node type.E- Edge type.
- All Implemented Interfaces:
GraphAdapter<N,E>
- Direct Known Subclasses:
BasicSuperLightGraph,TestLightGraph
Basic and naive graph implementation using light nodes.
Node can be any object.
- Author:
- Damien Carbonne
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBasicLightGraph(boolean sorted, BasicLightGraph.CollectionKind collectionKind) BasicLightGraph(BasicLightGraph.CollectionKind collectionKind) -
Method Summary
Modifier and TypeMethodDescription<X extends E>
XaddEdge(X edge) Adds an edge to this graph.<X extends E>
voidaddEdgeIfMissing(X edge) Adds an edge if not already contained.voidaddEdges(Collection<? extends E> edges) voidaddEdgesIfMissing(Collection<? extends E> edges) <X extends N>
XaddNode(X node) Adds a node to this graph.<X extends N>
voidaddNodeIfMissing(X node) Ads a node if not already contained.voidaddNodes(Collection<? extends N> nodes) voidaddNodesIfMissing(Collection<? extends N> nodes) voidclear()Clears this graph.voidClears all edges of this graph.final booleancontainsEdge(E edge) booleancontainsEdge(N source, N target) Returntrueif this graph contains at least one edge between a source node and a target node.final booleancontainsNode(N node) getEdges()getEdges(N node, EdgeDirection direction) getNodes()final NbooleanisLocked()voidremoveEdge(E edge) Removes an edge from this graph.voidremoveEdges(Collection<? extends E> edges) voidremoveNode(N node) Remove a node from this graph.voidremoveNodes(Collection<? extends N> nodes) voidsetChecksEnabled(boolean enabled) voidsetLocked(boolean locked) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface cdc.graphs.GraphAdapter
getConnectedNodes, getConnectedNodes, getConnectivity, getEdges, getEdges, getEdges, getEdges, getEdgesCount, getEdgesCount, getEdgesCount, getEdgesStream, getEdgesStream, getEdgesStream, getLeaves, getNodes, getNodesCount, getNodesStream, getRoots, hasEdge, hasEdges, hasEdges, hasEdges, hasNodes, isLeaf, isRoot
-
Constructor Details
-
BasicLightGraph
-
BasicLightGraph
-
BasicLightGraph
public BasicLightGraph()
-
-
Method Details
-
setChecksEnabled
public void setChecksEnabled(boolean enabled) -
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.
-
clearEdges
public void clearEdges()Clears all edges of this graph.- Throws:
cdc.util.lang.InvalidStateException- When this graph is locked.
-
addNode
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.
-
addNodes
-
addNodeIfMissing
Ads a node if not already contained.- Type Parameters:
X- The node type.- Parameters:
node- The node.
-
addNodesIfMissing
-
removeNode
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.
-
removeNodes
-
addEdge
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.
-
addEdges
-
addEdgeIfMissing
Adds an edge if not already contained.- Type Parameters:
X- The edge type.- Parameters:
edge- The edge.
-
addEdgesIfMissing
-
removeEdge
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.
-
removeEdges
-
getNodes
-
containsNode
- Specified by:
containsNodein interfaceGraphAdapter<N,E extends GraphEdge<N>>
-
getEdges
-
containsEdge
- Specified by:
containsEdgein interfaceGraphAdapter<N,E extends GraphEdge<N>>
-
containsEdge
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
-
getTip
-