The Euler tour technique (ETT), named after Leonhard Euler, is a method in graph theory for representing trees. The tree is viewed as a directed graph that contains two directed edges for each edge in the tree. The tree can then be represented as a Eulerian circuit of the directed graph, known as the Euler tour representation (ETR) of the tree. The ETT allows for efficient, parallel computation of solutions to common problems in algorithmic graph theory. It was introduced by Tarjan and Vishkin in 1984.
Construction.
Given an undirected tree presented as a set of edges, the Euler tour representation (ETR) can be constructed in parallel as follows:
Construct an edge list (called "succ") in Euler tour order by setting pointers succ("u","v") for all edges ("u","v") in parallel according to the following rule:
 formula_1
The resulting list "succ" will be circular.
The overall construction takes work "W"("n") = O(sort("n")) (the time it takes to sort "n" items in parallel) if the tree has "n" nodes, as in trees the number of edges is one less than the number of nodes.
Roots, advance and retreat edges.
If the tree has a root, we can split the circular list "succ" at that root. In that case, we can speak of "advance" and "retreat" edges: given a pair of nodes "u","v", the first occurrence of either ("u","v") or ("v","u") in the ETR is called the "advance edge", and the second occurrence is called the "retreat edge". This appeals to the intuition that the first time such an edge is traversed the distance to the root is increased, while the second time the distance decreases.
Rerooting the tree can be done in constant time O(1) by splitting the circular list "succ" at the new root.
Applications.
All of the following problems can be solved in O(Prefix sum("n")) (the time it takes to solve the prefix sum problem in parallel for a list of "n" items):
Euler tour trees.
Henzinger and King suggest to represent a given tree by keeping its Euler tour in a balanced binary search tree, keyed by the index in the tour. So for example, the unbalanced tree in the example above, having 7 nodes, will be represented by a balanced binary tree with 14 nodes, one for each time each node appears on the tour.
We can represent a forest (an acyclic graph) using a collection of ET trees - one ET tree for one forest tree. This representation allows us to quickly answer the question "what is the root of node v?" by just moving to the first node of the ET tree (since nodes in the ET tree are keyed by their location in the Euler tour, and the root is the first and last node in the tour). When the represented forest is updated (e.g. by connecting two trees to a single tree or by splitting a tree to two trees), the corresponding Euler-tour structure can be updated in time O(log(n)).
Link/cut trees have similar performance guarantees. While LC trees are good for maintaining aggregates on paths of a tree (making it a good choice data structure in network flow algorithms), ET trees are better at keeping aggregate information on subtrees.
References.
 ;templatestyles src="Reflist/styles.css" / ;