Package jetbrains.buildServer.util.graph
Class WrappedDAG
- java.lang.Object
-
- jetbrains.buildServer.util.graph.DAG<Long>
-
- jetbrains.buildServer.util.graph.BaseModificationDAG
-
- jetbrains.buildServer.util.graph.WrappedDAG
-
public class WrappedDAG extends BaseModificationDAG
A DAG implementation which delegates all the calls to a DAG provided by a Supplier.- Since:
- 2024.12
-
-
Constructor Summary
Constructors Constructor Description WrappedDAG(Supplier<BaseModificationDAG> dagSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
breadthFirstSearch(Long start, BFSVisitor<Long> visitor)
Run breadth-first search from the specified start nodevoid
breadthFirstSearch(Set<Long> starts, BFSVisitor<Long> visitor)
boolean
containsNode(Long node)
Check if graph contains specified nodevoid
depthFirstSearch(Long start, DFSVisitor<Long> visitor)
Run depth-first search from the specified start nodeprotected void
ensureContainsNode(Long node)
DAG<Long>
exclude(Collection<Long> nodesToExclude)
Returns DAG which doesn't contain nodes in the specified collectionprotected void
fillSelfChildren(Long node, List<Long> accumulator)
DAG<Long>
filter(Filter<Long> filter)
Returns filtered DAG which contains only nodes accepted by specified filter, same as calling {@link #filter(jetbrains.buildServer.util.filters.Filter, false)}DAG<Long>
filter(Filter<Long> filter, boolean includeAcceptedNodeParents)
Returns filtered DAG which contains only nodes accepted by specified filter and, if includeAcceptedNodeParents is set to true, their parentsDAG<Long>
filter(Filter<Long> filter, boolean includeAcceptedNodeParents, boolean extrapolateEdges)
Set<Long>
getAllNodes()
List<Long>
getChildren(Long node)
Get children of the specified nodeList<Long>
getCommonAncestors(Long... nodes)
List<Long>
getCommonAncestors(List<Long> nodes)
Get list of common ancestors for collection of graph nodesModificationDagDFS
getDepthFirstSearch(Long start, DFSVisitor<Long> visitor)
Returns depth-first search from the specified start nodelong
getMaxNode()
Set<Long>
getNodesWithMissingParents()
Returns nodes where some parent nodes are missing.List<Long>
getNodesWithoutChildren()
Returns nodes without childrenList<Long>
getNodesWithoutParents()
Returns nodes without parentsList<Long>
getParents(Long node)
Get parents of the specified nodeDepthFirstSearch<Long>
getReverseDepthFirstSearch(Long start, DFSVisitor<Long> visitor)
protected List<Long>
getSelfParents(Long node)
boolean
hasParents(Long node)
Returns true if the given node has parentsDAG<Long>
include(Collection<Long> nodesToInclude)
Returns DAG which contains only nodes in the specified collectionDAG<Long>
include(Collection<Long> nodesToInclude, boolean extrapolateEdges)
boolean
isEmpty()
DAGIterator<Long>
iterator()
Get iterator through the nodes of the graph.DAGIterator<Long>
iterator(Long startNode)
Get iterator through the nodes of the graphDAGIterator<Long>
iterator(Collection<Long> startNodes)
Get iterator through the nodes of the graphprotected void
processNodesWithoutChildren(ItemProcessor<Long> nodesProcessor)
Passes nodes without children to the specified processor.void
reverseBreadthFirstSearch(Long start, BFSVisitor<Long> visitor)
void
reverseBreadthFirstSearch(Set<Long> starts, BFSVisitor<Long> visitor)
int
size()
Returns number of nodes in the graphList<DAG<Long>>
splitIsolatedDAGs()
List<Long>
toposort()
Get topologically sorted list of graph nodes (parents go before children)BaseModificationDAG
unwrap()
-
Methods inherited from class jetbrains.buildServer.util.graph.BaseModificationDAG
tailSize, toposortFrom
-
-
-
-
Constructor Detail
-
WrappedDAG
public WrappedDAG(@NotNull Supplier<BaseModificationDAG> dagSupplier)
-
-
Method Detail
-
toposort
@NotNull public List<Long> toposort()
Description copied from class:DAG
Get topologically sorted list of graph nodes (parents go before children)
-
getCommonAncestors
@NotNull public List<Long> getCommonAncestors(@NotNull List<Long> nodes)
Description copied from class:DAG
Get list of common ancestors for collection of graph nodes- Overrides:
getCommonAncestors
in classBaseModificationDAG
- Parameters:
nodes
- nodes of interest, they should be presented in the graph- Returns:
- least common ancestors or empty list if collection of nodes is empty or if there is no common ancestor between nodes.
-
getParents
@NotNull public List<Long> getParents(@NotNull Long node)
Description copied from class:DAG
Get parents of the specified node- Specified by:
getParents
in classDAG<Long>
- Parameters:
node
- node of interest- Returns:
- see above
-
fillSelfChildren
protected void fillSelfChildren(@NotNull Long node, @NotNull List<Long> accumulator)
- Specified by:
fillSelfChildren
in classDAG<Long>
-
filter
public DAG<Long> filter(@NotNull Filter<Long> filter, boolean includeAcceptedNodeParents, boolean extrapolateEdges)
- Overrides:
filter
in classBaseModificationDAG
-
containsNode
public boolean containsNode(@NotNull Long node)
Description copied from class:DAG
Check if graph contains specified node- Specified by:
containsNode
in classDAG<Long>
- Parameters:
node
- node to check- Returns:
- true if graph contains node, false otherwise
-
getNodesWithoutParents
@NotNull public List<Long> getNodesWithoutParents()
Description copied from class:DAG
Returns nodes without parents- Specified by:
getNodesWithoutParents
in classDAG<Long>
- Returns:
- see above
-
getNodesWithoutChildren
@NotNull public List<Long> getNodesWithoutChildren()
Description copied from class:DAG
Returns nodes without children- Overrides:
getNodesWithoutChildren
in classBaseModificationDAG
- Returns:
- see above
-
getMaxNode
public long getMaxNode()
- Specified by:
getMaxNode
in classBaseModificationDAG
- Returns:
- max node from the current DAG if it is not empty, otherwise returns 0
-
breadthFirstSearch
public void breadthFirstSearch(@NotNull Long start, @NotNull BFSVisitor<Long> visitor)
Description copied from class:DAG
Run breadth-first search from the specified start node- Overrides:
breadthFirstSearch
in classBaseModificationDAG
- Parameters:
start
- start node for the searchvisitor
- visitor
-
breadthFirstSearch
public void breadthFirstSearch(@NotNull Set<Long> starts, @NotNull BFSVisitor<Long> visitor)
- Overrides:
breadthFirstSearch
in classBaseModificationDAG
-
reverseBreadthFirstSearch
public void reverseBreadthFirstSearch(@NotNull Long start, @NotNull BFSVisitor<Long> visitor)
- Overrides:
reverseBreadthFirstSearch
in classBaseModificationDAG
-
reverseBreadthFirstSearch
public void reverseBreadthFirstSearch(@NotNull Set<Long> starts, @NotNull BFSVisitor<Long> visitor)
- Overrides:
reverseBreadthFirstSearch
in classBaseModificationDAG
-
getDepthFirstSearch
public ModificationDagDFS getDepthFirstSearch(@NotNull Long start, @NotNull DFSVisitor<Long> visitor)
Description copied from class:DAG
Returns depth-first search from the specified start node- Overrides:
getDepthFirstSearch
in classBaseModificationDAG
- Parameters:
start
- start node for the searchvisitor
- visitor- Returns:
- see above
-
getReverseDepthFirstSearch
public DepthFirstSearch<Long> getReverseDepthFirstSearch(@NotNull Long start, @NotNull DFSVisitor<Long> visitor)
- Overrides:
getReverseDepthFirstSearch
in classBaseModificationDAG
-
size
public int size()
Description copied from class:DAG
Returns number of nodes in the graph
-
getAllNodes
@NotNull public Set<Long> getAllNodes()
- Specified by:
getAllNodes
in classDAG<Long>
-
getSelfParents
@Nullable protected List<Long> getSelfParents(@NotNull Long node)
- Specified by:
getSelfParents
in classDAG<Long>
-
processNodesWithoutChildren
protected void processNodesWithoutChildren(@NotNull ItemProcessor<Long> nodesProcessor)
Description copied from class:DAG
Passes nodes without children to the specified processor.- Specified by:
processNodesWithoutChildren
in classDAG<Long>
-
hasParents
public boolean hasParents(@NotNull Long node)
Description copied from class:DAG
Returns true if the given node has parents- Overrides:
hasParents
in classDAG<Long>
- Parameters:
node
- node of interest- Returns:
- see above
-
iterator
@NotNull public DAGIterator<Long> iterator()
Description copied from class:DAG
Get iterator through the nodes of the graph. Same as iterator(getNodesWithoutChildren())- Overrides:
iterator
in classBaseModificationDAG
- Returns:
- see above
- See Also:
DAG.iterator(java.util.Collection)
-
iterator
@NotNull public DAGIterator<Long> iterator(@NotNull Long startNode)
Description copied from class:DAG
Get iterator through the nodes of the graph- Overrides:
iterator
in classBaseModificationDAG
- Parameters:
startNode
- start node for iteration- Returns:
- see above
-
iterator
@NotNull public DAGIterator<Long> iterator(@NotNull Collection<Long> startNodes)
Description copied from class:DAG
Get iterator through the nodes of the graph- Overrides:
iterator
in classBaseModificationDAG
- Parameters:
startNodes
- start nodes for iteration- Returns:
- see above
-
exclude
@NotNull public DAG<Long> exclude(@NotNull Collection<Long> nodesToExclude)
Description copied from class:DAG
Returns DAG which doesn't contain nodes in the specified collection
-
include
@NotNull public DAG<Long> include(@NotNull Collection<Long> nodesToInclude)
Description copied from class:DAG
Returns DAG which contains only nodes in the specified collection
-
include
@NotNull public DAG<Long> include(@NotNull Collection<Long> nodesToInclude, boolean extrapolateEdges)
-
filter
@NotNull public DAG<Long> filter(@NotNull Filter<Long> filter)
Description copied from class:DAG
Returns filtered DAG which contains only nodes accepted by specified filter, same as calling {@link #filter(jetbrains.buildServer.util.filters.Filter, false)}
-
filter
public DAG<Long> filter(@NotNull Filter<Long> filter, boolean includeAcceptedNodeParents)
Description copied from class:DAG
Returns filtered DAG which contains only nodes accepted by specified filter and, if includeAcceptedNodeParents is set to true, their parents
-
ensureContainsNode
protected void ensureContainsNode(@NotNull Long node)
- Overrides:
ensureContainsNode
in classDAG<Long>
-
splitIsolatedDAGs
public List<DAG<Long>> splitIsolatedDAGs()
- Overrides:
splitIsolatedDAGs
in classDAG<Long>
-
getChildren
@NotNull public List<Long> getChildren(@NotNull Long node)
Description copied from class:DAG
Get children of the specified node- Overrides:
getChildren
in classDAG<Long>
- Parameters:
node
- node of interest- Returns:
- see above
-
getCommonAncestors
@NotNull public List<Long> getCommonAncestors(@NotNull Long... nodes)
- Overrides:
getCommonAncestors
in classDAG<Long>
- See Also:
DAG.getCommonAncestors(java.util.List)
-
getNodesWithMissingParents
public Set<Long> getNodesWithMissingParents()
Description copied from class:DAG
Returns nodes where some parent nodes are missing. UnlikeDAG.getNodesWithoutParents()
also returns nodes where some parents are present and other parents are missing.- Overrides:
getNodesWithMissingParents
in classDAG<Long>
-
depthFirstSearch
public void depthFirstSearch(@NotNull Long start, @NotNull DFSVisitor<Long> visitor)
Description copied from class:DAG
Run depth-first search from the specified start node- Overrides:
depthFirstSearch
in classDAG<Long>
- Parameters:
start
- start node for the searchvisitor
- visitor
-
unwrap
@NotNull public BaseModificationDAG unwrap()
-
-