Class GraphTraversal


  • public final class GraphTraversal
    extends Object
    • Method Detail

      • breadthFirst

        public static <N,​E,​D> void breadthFirst​(IndefiniteGraph<N,​E> graph,
                                                            N initialNode,
                                                            GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a breadth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        initialNode - the node from which the traversal should start
        visitor - the visitor
      • breadthFirst

        public static <N,​E,​D> void breadthFirst​(IndefiniteGraph<N,​E> graph,
                                                            Collection<? extends N> initialNodes,
                                                            GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a breadth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
      • breadthFirst

        public static <N,​E,​D> boolean breadthFirst​(IndefiniteGraph<N,​E> graph,
                                                               int limit,
                                                               N initialNode,
                                                               GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a breadth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNode - the node from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise
      • breadthFirst

        public static <N,​E,​D> boolean breadthFirst​(IndefiniteGraph<N,​E> graph,
                                                               int limit,
                                                               Collection<? extends N> initialNodes,
                                                               GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a breadth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise
      • breadthFirstOrder

        public static <N,​E> Iterable<N> breadthFirstOrder​(IndefiniteGraph<N,​E> graph,
                                                                Collection<? extends N> start)
        Returns an Iterable for the (reachable) nodes of the given graph in breadth-first order.
        Type Parameters:
        N - node type
        E - edge type
        Parameters:
        graph - the graph
        start - the nodes from which the traversal should start
        Returns:
        an Iterable for the (reachable) nodes of the given graph in breadth-first order
      • breadthFirstIterator

        public static <N,​E> Iterator<N> breadthFirstIterator​(IndefiniteGraph<N,​E> graph,
                                                                   Collection<? extends N> start)
        Returns an Iterator for the (reachable) nodes of the given graph in breadth-first order.
        Type Parameters:
        N - node type
        E - edge type
        Parameters:
        graph - the graph
        start - the nodes from which the traversal should start
        Returns:
        an Iterator for the (reachable) nodes of the given graph in breadth-first order
      • depthFirst

        public static <N,​E,​D> void depthFirst​(IndefiniteGraph<N,​E> graph,
                                                          N initialNode,
                                                          GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a depth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        initialNode - the node from which the traversal should start
        visitor - the visitor
      • depthFirst

        public static <N,​E,​D> void depthFirst​(IndefiniteGraph<N,​E> graph,
                                                          Collection<? extends N> initialNodes,
                                                          GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a depth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
      • depthFirst

        public static <N,​E,​D> boolean depthFirst​(IndefiniteGraph<N,​E> graph,
                                                             int limit,
                                                             N initialNode,
                                                             GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a depth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNode - the node from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise
      • depthFirst

        public static <N,​E,​D> boolean depthFirst​(IndefiniteGraph<N,​E> graph,
                                                             int limit,
                                                             Collection<? extends N> initialNodes,
                                                             GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a breadth-first fashion. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise
      • depthFirstOrder

        public static <N,​E> Iterable<N> depthFirstOrder​(IndefiniteGraph<N,​E> graph,
                                                              Collection<? extends N> start)
        Returns an Iterable for the (reachable) nodes of the given graph in depth-first order.
        Type Parameters:
        N - node type
        E - edge type
        Parameters:
        graph - the graph
        start - the nodes from which the traversal should start
        Returns:
        an Iterable for the (reachable) nodes of the given graph in depth-first order
      • depthFirstIterator

        public static <N,​E> Iterator<N> depthFirstIterator​(IndefiniteGraph<N,​E> graph,
                                                                 Collection<? extends N> start)
        Returns an Iterator for the (reachable) nodes of the given graph in depth-first order.
        Type Parameters:
        N - node type
        E - edge type
        Parameters:
        graph - the graph
        start - the nodes from which the traversal should start
        Returns:
        an Iterator for the (reachable) nodes of the given graph in depth-first order
      • traverse

        public static <N,​E,​D> void traverse​(TraversalOrder order,
                                                        IndefiniteGraph<N,​E> graph,
                                                        N initialNode,
                                                        GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a given order. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        order - the order in which the states should be traversed
        graph - the graph
        initialNode - the node from which the traversal should start
        visitor - the visitor
      • traverse

        public static <N,​E,​D> void traverse​(TraversalOrder order,
                                                        IndefiniteGraph<N,​E> graph,
                                                        Collection<? extends N> initialNodes,
                                                        GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a given order. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        order - the order in which the states should be traversed
        graph - the graph
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
      • traverse

        public static <N,​E,​D> boolean traverse​(TraversalOrder order,
                                                           IndefiniteGraph<N,​E> graph,
                                                           int limit,
                                                           N initialNode,
                                                           GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a given order. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        order - the order in which the states should be traversed
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNode - the node from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise
      • traverse

        public static <N,​E,​D> boolean traverse​(TraversalOrder order,
                                                           IndefiniteGraph<N,​E> graph,
                                                           int limit,
                                                           Collection<? extends N> initialNodes,
                                                           GraphTraversalVisitor<N,​E,​D> visitor)
        Traverses the given graph in a given order. The traversal is steered by the specified visitor.
        Type Parameters:
        N - node type
        E - edge type
        D - (user) data type
        Parameters:
        order - the order in which the states should be traversed
        graph - the graph
        limit - the upper bound on the number of nodes to be visited
        initialNodes - the nodes from which the traversal should start
        visitor - the visitor
        Returns:
        false if the number of explored nodes reached limit, true otherwise