Примеры использования Depth-first на Английском языке и их переводы на Русский язык
{-}
-
Official
-
Colloquial
Keywords: graph, algorithm, depth-first search, breadth-first search.
All depth-first search trees and all Hamiltonian paths are Trémaux trees.
Let d{\displaystyle d} be the depth of the resulting depth-first search tree.
In step C, the algorithm again runs a depth-first search from each root node, to check the refcount of each zval again.
The resulting ordering can equivalently be described as the order one would get from a depth-first traversal of a quadtree.
Thus, simple depth-first or breadth-first searches do not traverse every infinite tree, and are not efficient on very large trees.
The first two stages are performed with the use of depth-first search and have the complexity[ math] O(| E|)/ math.
It is possible to find an st-numbering, and a bipolar orientation, of a given graph with designated vertices s and t,in linear time using depth-first search.
Algorithmically, these numbers may be assigned by performing a depth-first search and assigning each node's number in postorder.
Beyond these basic traversals, various more complex or hybrid schemes are possible,such as depth-limited searches like iterative deepening depth-first search.
To traverse any tree with depth-first search, perform the following operations recursively at each node: Perform pre-order operation.
Trémaux trees are named after Charles Pierre Trémaux,a 19th-century French author who used a form of depth-first search as a strategy for solving mazes.
These searches are referred to as depth-first search(DFS), as the search tree is deepened as much as possible on each child before going to the next sibling.
If it's larger than zero, it reverts the decreasing of the refcount by one with a depth-first search from that point on, and they are marked"black" again.
One can use a depth-first search starting at v{\displaystyle v} to report the labels of leaf-descendants of v{\displaystyle v} in O( k){\displaystyle{\mathcal{O}}(k)} time.
A Trémaux tree exists in every graph with countably many vertices,even when an infinite form of depth-first search would not succeed in exploring every vertex of the graph.
In finite graphs, although depth-first search itself is inherently sequential, Trémaux trees can be constructed by a randomized parallel algorithm in the complexity class RNC.
Chrobak, Naor& Novick(1989)provide an alternative linear-time algorithm based on depth-first search, as well as efficient parallel algorithms for the same problem.
In step B, the algorithm runs a depth-first search on all possible roots to decrease by one the refcounts of each zval it finds, making sure not to decrease a refcount on the same zval twice by marking them as"grey.
However, for cubic graphs and other graphs of maximum degree three, the linear arboricity is always two, anda decomposition into two linear forests can be found in linear time using an algorithm based on depth-first search.
They use nodes in a codingFP-tree to represent itemsets, and employ a depth-first search strategy to discovery frequent itemsets using"intersection" of node sets.
Depth-first search is easily implemented via a stack, including recursively(via the call stack), while breadth-first search is easily implemented via a queue, including corecursively.
It is P-complete to find the Trémaux tree that would be found by a sequential depth-first search algorithm, in which the neighbors of each vertex are searched in order by their identities.
Maon, Schieber& Vishkin(1986) provide a complicated butlocalized search procedure for determining an appropriate orientation for each ear that(unlike the approach using depth-first search) is suitable for parallel computation.
Once these numbers have been computed, Tarjan's algorithm performs a second traversal of the depth-first search tree, maintaining a number sign(v) for each vertex v and a linked list of vertices that will eventually list all vertices of the graph in the order given by an st-numbering.
Conversely, if a partition with this property exists for a strongly connected graph G, k must divide the lengths of all cycles in G. Thus, we may find the period of a strongly connected graph G by the following steps:Perform a depth-first search of G For each e in G that connects a vertex on level i of the depth-first search tree to a vertex on level j, let ke j- i- 1.
For example, given a binary tree of infinite depth, a depth-first search will go down one side(by convention the left side) of the tree, never visiting the rest, and indeed an in-order or post-order traversal will never visit any nodes, as it has not reached a leaf and in fact never will.
On the other hand, given a tree of depth 2, where the root has infinitely many children,and each of these children has two children, a depth-first search will visit all nodes, as once it exhausts the grandchildren(children of children of one node), it will move on to the next assuming it is not post-order, in which case it never reaches the root.
Every finite Trémaux tree can be generated as a depth-first search tree: If T is a Trémaux tree of a finite graph, and a depth-first search explores the children in T of each vertex prior to exploring any other vertices, it will necessarily generate T as its depth-first search tree.
A more space-efficient approach for this type of traversal can be implemented using an iterative deepening depth-first search. levelorder(root) q← empty queue q. enqueue(root) while(not q. isEmpty()) node← q. dequeue() visit(node) if(node. left≠ null) q. enqueue(node. left) if(node. right≠ null) q. enqueue(node. right) While traversal is usually done for trees with a finite number of nodes(and hence finite depth and finite branching factor) it can also be done for infinite trees.