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 voidbreadthFirstSearch(Long start, BFSVisitor<Long> visitor)Run breadth-first search from the specified start nodevoidbreadthFirstSearch(Set<Long> starts, BFSVisitor<Long> visitor)booleancontainsNode(Long node)Check if graph contains specified nodevoiddepthFirstSearch(Long start, DFSVisitor<Long> visitor)Run depth-first search from the specified start nodeprotected voidensureContainsNode(Long node)DAG<Long>exclude(Collection<Long> nodesToExclude)Returns DAG which doesn't contain nodes in the specified collectionprotected voidfillSelfChildren(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 nodesModificationDagDFSgetDepthFirstSearch(Long start, DFSVisitor<Long> visitor)Returns depth-first search from the specified start nodelonggetMaxNode()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)booleanhasParents(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)booleanisEmpty()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 voidprocessNodesWithoutChildren(ItemProcessor<Long> nodesProcessor)Passes nodes without children to the specified processor.voidreverseBreadthFirstSearch(Long start, BFSVisitor<Long> visitor)voidreverseBreadthFirstSearch(Set<Long> starts, BFSVisitor<Long> visitor)intsize()Returns number of nodes in the graphList<DAG<Long>>splitIsolatedDAGs()List<Long>toposort()Get topologically sorted list of graph nodes (parents go before children)BaseModificationDAGunwrap()-
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:DAGGet topologically sorted list of graph nodes (parents go before children)
-
getCommonAncestors
@NotNull public List<Long> getCommonAncestors(@NotNull List<Long> nodes)
Description copied from class:DAGGet list of common ancestors for collection of graph nodes- Overrides:
getCommonAncestorsin 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:DAGGet parents of the specified node- Specified by:
getParentsin classDAG<Long>- Parameters:
node- node of interest- Returns:
- see above
-
fillSelfChildren
protected void fillSelfChildren(@NotNull Long node, @NotNull List<Long> accumulator)- Specified by:
fillSelfChildrenin classDAG<Long>
-
filter
public DAG<Long> filter(@NotNull Filter<Long> filter, boolean includeAcceptedNodeParents, boolean extrapolateEdges)
- Overrides:
filterin classBaseModificationDAG
-
containsNode
public boolean containsNode(@NotNull Long node)Description copied from class:DAGCheck if graph contains specified node- Specified by:
containsNodein 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:DAGReturns nodes without parents- Specified by:
getNodesWithoutParentsin classDAG<Long>- Returns:
- see above
-
getNodesWithoutChildren
@NotNull public List<Long> getNodesWithoutChildren()
Description copied from class:DAGReturns nodes without children- Overrides:
getNodesWithoutChildrenin classBaseModificationDAG- Returns:
- see above
-
getMaxNode
public long getMaxNode()
- Specified by:
getMaxNodein 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:DAGRun breadth-first search from the specified start node- Overrides:
breadthFirstSearchin classBaseModificationDAG- Parameters:
start- start node for the searchvisitor- visitor
-
breadthFirstSearch
public void breadthFirstSearch(@NotNull Set<Long> starts, @NotNull BFSVisitor<Long> visitor)- Overrides:
breadthFirstSearchin classBaseModificationDAG
-
reverseBreadthFirstSearch
public void reverseBreadthFirstSearch(@NotNull Long start, @NotNull BFSVisitor<Long> visitor)- Overrides:
reverseBreadthFirstSearchin classBaseModificationDAG
-
reverseBreadthFirstSearch
public void reverseBreadthFirstSearch(@NotNull Set<Long> starts, @NotNull BFSVisitor<Long> visitor)- Overrides:
reverseBreadthFirstSearchin classBaseModificationDAG
-
getDepthFirstSearch
public ModificationDagDFS getDepthFirstSearch(@NotNull Long start, @NotNull DFSVisitor<Long> visitor)
Description copied from class:DAGReturns depth-first search from the specified start node- Overrides:
getDepthFirstSearchin 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:
getReverseDepthFirstSearchin classBaseModificationDAG
-
size
public int size()
Description copied from class:DAGReturns number of nodes in the graph
-
getAllNodes
@NotNull public Set<Long> getAllNodes()
- Specified by:
getAllNodesin classDAG<Long>
-
getSelfParents
@Nullable protected List<Long> getSelfParents(@NotNull Long node)
- Specified by:
getSelfParentsin classDAG<Long>
-
processNodesWithoutChildren
protected void processNodesWithoutChildren(@NotNull ItemProcessor<Long> nodesProcessor)Description copied from class:DAGPasses nodes without children to the specified processor.- Specified by:
processNodesWithoutChildrenin classDAG<Long>
-
hasParents
public boolean hasParents(@NotNull Long node)Description copied from class:DAGReturns true if the given node has parents- Overrides:
hasParentsin classDAG<Long>- Parameters:
node- node of interest- Returns:
- see above
-
iterator
@NotNull public DAGIterator<Long> iterator()
Description copied from class:DAGGet iterator through the nodes of the graph. Same as iterator(getNodesWithoutChildren())- Overrides:
iteratorin classBaseModificationDAG- Returns:
- see above
- See Also:
DAG.iterator(java.util.Collection)
-
iterator
@NotNull public DAGIterator<Long> iterator(@NotNull Long startNode)
Description copied from class:DAGGet iterator through the nodes of the graph- Overrides:
iteratorin classBaseModificationDAG- Parameters:
startNode- start node for iteration- Returns:
- see above
-
iterator
@NotNull public DAGIterator<Long> iterator(@NotNull Collection<Long> startNodes)
Description copied from class:DAGGet iterator through the nodes of the graph- Overrides:
iteratorin classBaseModificationDAG- Parameters:
startNodes- start nodes for iteration- Returns:
- see above
-
exclude
@NotNull public DAG<Long> exclude(@NotNull Collection<Long> nodesToExclude)
Description copied from class:DAGReturns DAG which doesn't contain nodes in the specified collection
-
include
@NotNull public DAG<Long> include(@NotNull Collection<Long> nodesToInclude)
Description copied from class:DAGReturns 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:DAGReturns 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:DAGReturns 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:
ensureContainsNodein classDAG<Long>
-
splitIsolatedDAGs
public List<DAG<Long>> splitIsolatedDAGs()
- Overrides:
splitIsolatedDAGsin classDAG<Long>
-
getChildren
@NotNull public List<Long> getChildren(@NotNull Long node)
Description copied from class:DAGGet children of the specified node- Overrides:
getChildrenin classDAG<Long>- Parameters:
node- node of interest- Returns:
- see above
-
getCommonAncestors
@NotNull public List<Long> getCommonAncestors(@NotNull Long... nodes)
- Overrides:
getCommonAncestorsin classDAG<Long>- See Also:
DAG.getCommonAncestors(java.util.List)
-
getNodesWithMissingParents
public Set<Long> getNodesWithMissingParents()
Description copied from class:DAGReturns nodes where some parent nodes are missing. UnlikeDAG.getNodesWithoutParents()also returns nodes where some parents are present and other parents are missing.- Overrides:
getNodesWithMissingParentsin classDAG<Long>
-
depthFirstSearch
public void depthFirstSearch(@NotNull Long start, @NotNull DFSVisitor<Long> visitor)Description copied from class:DAGRun depth-first search from the specified start node- Overrides:
depthFirstSearchin classDAG<Long>- Parameters:
start- start node for the searchvisitor- visitor
-
unwrap
@NotNull public BaseModificationDAG unwrap()
-
-