Package cdc.graphs
Interface GraphAdapter<N,E>
- Type Parameters:
N- Node class.E- Edge class.
public interface GraphAdapter<N,E>
Interface giving access to a heavy graph, where nodes and edges are represented as objects.
Graph algorithms can be built using this interface without forcing a graph implementation to implement this interface.
- Author:
- Damien Carbonne
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsEdge(E edge) Returnstrueif an edge belongs to this graph.booleancontainsNode(N node) Returnstrueif a node belongs to this graph.getConnectedNodes(N node) Returns a set of all nodes that are connected to a node.getConnectedNodes(N node, EdgeDirection direction) Returns an Iterable of edges attached to a node in a given direction.default NodeConnectivitygetConnectivity(N node) Returns the connectivity of a node.getEdges()getEdges(N node, EdgeDirection direction) Returns an Iterable of edges attached to a node in a given direction.getEdges(N node, EdgeDirection direction, Predicate<? super E> predicate) Returns an Iterable of edges attached to a node in a given direction and matching a predicate.default intdefault intgetEdgesCount(N node) Returns the number of edges attached to a node, in any direction.default intgetEdgesCount(N node, EdgeDirection direction) Returns the number of edges attached to a node, in one or any direction.getEdgesStream(N node) getEdgesStream(N node, EdgeDirection direction) getNodes()Return an Iterable of all nodes that match a predicate.default intgetRoots()Returns a tip of an edge.default booleanReturnstruewhen there is an edge between a source node and target node.default booleanhasEdges()default booleanReturnstruewhen there are edges attached to a node, in any direction.default booleanhasEdges(N node, EdgeDirection direction) Returnstruewhen there are edges attached to a node, in one or any direction.default booleanhasNodes()default booleanReturntrueif a node is a leaf: It has no outgoing edges.default booleanReturnstruewhen a node is a root: It has no ingoing edges.
-
Method Details
-
getNodes
- Returns:
- an Iterable of all nodes.
-
getNodesStream
-
getNodes
Return an Iterable of all nodes that match a predicate.- Parameters:
predicate- The predicate.- Returns:
- an Iterable of all nodes that match
predicate.
-
getNodesCount
default int getNodesCount()- Returns:
- The number of nodes in the graph.
-
hasNodes
default boolean hasNodes()- Returns:
trueif the graph has nodes.
-
containsNode
Returnstrueif a node belongs to this graph.- Parameters:
node- The node.- Returns:
trueifnodeis member of this graph.
-
getEdges
- Returns:
- an Iterable of all edges.
-
getEdgesStream
-
getEdges
- Parameters:
predicate- The predicate.- Returns:
- an Iterable of all edges that match
predicate.
-
getEdgesCount
default int getEdgesCount()- Returns:
- The number of edges in the graph.
-
hasEdges
default boolean hasEdges()- Returns:
trueif the graph has edges.
-
containsEdge
Returnstrueif an edge belongs to this graph.- Parameters:
edge- The edge.- Returns:
trueifedgeis member of graph.
-
getEdges
Returns an Iterable of edges attached to a node in a given direction.- Parameters:
node- The node. MUST NOT benull.direction- The direction. MAY benull. Ifnull, then all edges are returned.- Returns:
- An Iterable of edges attached to
nodeindirection.
-
getEdges
default Iterable<? extends E> getEdges(N node, EdgeDirection direction, Predicate<? super E> predicate) Returns an Iterable of edges attached to a node in a given direction and matching a predicate.- Parameters:
node- The node. MUST NOT benull.direction- The direction. MAY benull. Ifnull, then all edges are returned.predicate- The predicate to filter edges.- Returns:
- An Iterable of edges attached to
nodeindirectionand matchingpredicate.
-
getConnectedNodes
Returns an Iterable of edges attached to a node in a given direction.- Parameters:
node- The node. MUST NOT benull.direction- The direction. MAY benull.- Returns:
- A set of all nodes connected to
nodeindirection.
-
getConnectedNodes
Returns a set of all nodes that are connected to a node.- Parameters:
node- The node.- Returns:
- A set of all nodes that are connected to
node.
-
getEdgesStream
-
getEdges
- Parameters:
node- The node.- Returns:
- An Iterable of all edges attached to
node.
-
getEdges
- Parameters:
node- The node.predicate- The predicate.- Returns:
- An Iterable of all edges attached to
nodeand that matchpredicate.
-
getEdgesStream
-
getEdgesCount
Returns the number of edges attached to a node, in one or any direction.- Parameters:
node- The node.direction- The optional direction. MAY benullto indicate that direction does not matter.- Returns:
- The number of edges attached to
node, in one (if notnull) or any (ifnull)direction.
-
getEdgesCount
Returns the number of edges attached to a node, in any direction.- Parameters:
node- The node.- Returns:
- The number of edges attached to
node, in any direction.
-
hasEdges
Returnstruewhen there are edges attached to a node, in one or any direction.- Parameters:
node- The node.direction- The optional direction. MAY benullto indicate that direction does not matter.- Returns:
truewhen there are edges attached tonode, in one (if notnull) or any (ifnull)direction.
-
hasEdges
Returnstruewhen there are edges attached to a node, in any direction.- Parameters:
node- The node.- Returns:
truewhen there are edges attached tonode, in any direction.
-
getTip
Returns a tip of an edge.- Parameters:
edge- The edge. MUST NOT benull.tip- The tip. MUST NOT benull.- Returns:
- The node attached to edge for tip.
-
isRoot
Returnstruewhen a node is a root: It has no ingoing edges.- Parameters:
node- The node.- Returns:
truewhen node is a root.
-
isLeaf
Returntrueif a node is a leaf: It has no outgoing edges.- Parameters:
node- The node.- Returns:
truewhen node is a leaf.
-
getRoots
- Returns:
- A Set of all root nodes.
-
getLeaves
- Returns:
- A Set of all leaf nodes.
-
getConnectivity
Returns the connectivity of a node.- Parameters:
node- The node- Returns:
- The connectivity of
node.
-
hasEdge
Returnstruewhen there is an edge between a source node and target node.WARNING: order of passed arguments matters.
- Parameters:
source- The source node.target- The target node.- Returns:
truewhen there is an edge betweensourceandtarget.
-