Class ReachabilityPredicate


  • public class ReachabilityPredicate
    extends Object
    Checks if the given node is reachable from nodes marked as uninteresting. Works only with VCS dags (dags where id of children nodes is greater than id of parent nodes).

    Example of usage:

       ReachabilityPredicate p = VcsDAGs.createReachabilityPredicate(dag);
       p.markUninteresting(node1); //marks node1 and all nodes reachable from it as uninteresting
       p.isInteresting(node2); //returns true if node2 is not reachable from node1
       p.markUninteresting(node2); //marks node2 and all nodes reachable from it as uninteresting
       dag.breadthFirstSearch(node3, p.createBfsVisitor(visitor)); //visitor will be called for all nodes reachable from node3 excluding nodes reachable form node1 and node2
       p.markUninteresting(node4);
       dag.depthFirstSearch(node5, p.createDfsVisitor(visitor)); //visitor will be called for nodes reachable from node5 excluding nodes reachable form node1, node2, and node4
     
    • Method Detail

      • isInteresting

        public boolean isInteresting​(Long node)
        Returns true if the given node is interesting, ie. it is not marked as uninteresting and is not reachable from uninteresting nodes
        Parameters:
        node - node of interest
        Returns:
        see above
      • markUninteresting

        public void markUninteresting​(long node)
        Marks specified node and all reachable from it as uninteresting
        Parameters:
        node - node to mark
      • createBfsVisitor

        @NotNull
        public BFSVisitor<Long> createBfsVisitor​(@NotNull
                                                 BFSVisitor<Long> delegate)
        Returns a BFS search calling the specified delegate only for interesting nodes
        Parameters:
        delegate - delegate visitor to call
        Returns:
        see above
      • createDfsVisitor

        @NotNull
        public DFSVisitor<Long> createDfsVisitor​(@NotNull
                                                 DFSVisitor<Long> delegate)
        Returns a DFS search calling the specified delegate only for interesting nodes
        Parameters:
        delegate - delegate visitor to call
        Returns:
        see above