Class VcsDAGs


  • public class VcsDAGs
    extends Object
    Author:
    dmitry.neverov
    • Constructor Detail

      • VcsDAGs

        public VcsDAGs()
    • Method Detail

      • emptyDAG

        @NotNull
        public static DAG<Long> emptyDAG()
      • createLinearDag

        public static LinearDag createLinearDag​(@NotNull
                                                List<Long> nodes)
        Returns linear DAG created from given nodes
        Parameters:
        nodes - nodes for dag, children nodes should come first
        Returns:
        see above
      • addEdges

        @NotNull
        public static BaseModificationDAG addEdges​(@NotNull
                                                   DAG<Long> dag,
                                                   @NotNull
                                                   Collection<? extends Pair<Long,​Long>> edges,
                                                   @Nullable
                                                   AdditionalNodesSupplier nodesSupplier)
        Returns DAG that contains edges from given DAG and specified additional edges. Method assumes (but doesn't check) that new edges do not add parents to nodes in given dag, they should add only children.
        Parameters:
        dag - initial DAG
        edges - additional edges
        Returns:
        see above
      • addNodes

        public static LinearDag addNodes​(@NotNull
                                         DAG<Long> dag,
                                         @NotNull
                                         List<Long> nodes)
        Adds nodes to the given linear dag. Dag must implement LinearDag interface. Nodes must be sorted in descending order (caller must ensure a correct order). Returns a dag with added nodes.
        Parameters:
        dag - dag where nodes should be added
        nodes - nodes to add
        Returns:
        see above
      • childrenFirstSearch

        public static void childrenFirstSearch​(@NotNull
                                               DAG<Long> dag,
                                               @NotNull
                                               BFSVisitor<Long> visitor,
                                               @NotNull
                                               Set<Long> starts)
        Runs children-first search on the given dag with specified visitor and start nodes. Children-first search is similar to BFS, but guarantees no parent is visited before its children.
        Parameters:
        dag - dag to travers
        visitor - visitor to use
        starts - node where traversal should begin
      • createReachabilityPredicate

        @NotNull
        public static ReachabilityPredicate createReachabilityPredicate​(@NotNull
                                                                        DAG<Long> dag)
        Returns a reachability predicate for the given VCS dag (dag where children have higher ids than parents)
        Parameters:
        dag - VCS dag of interest
        Returns:
        see above