# tem_path_type Derived Type

## type, public :: tem_path_type

Paths of elements from the root node to themselves going through the hierarchy of the tree. Is used to compare to elements

For all [[tem_construction_module::identify_local_element]] "local elements", their actual position in the sparse mesh has to be identified for a given \ref treelmesh_module::treelmesh_type::treeid "treeID". Due to the sparsity of the mesh, the position of a certain element in the total list of elements can not be directly deduced from its \ref treelmesh_module::treelmesh_type::treeid "treeID". As already pointed out, we can rely on binary searches in the sorted list of elements for this task, as long as a comparison between any two elements is possible. A comparison of two nodes to decide their relative position in the ordered list of elements has to take into account the hierarchy of the mesh. The comparison operator is therefore defined as follows.

• Build the path from each leaf to the root of the tree, by repeatedly computing the parents with the equation used in the [tem_ParentOf function] (@ref tem_parentatlevel), until the root with \ref treelmesh_module::treelmesh_type::treeid "treeID" \f$0\f$ is reached.
• After the path through the tree is known for both leaves, comparison can be done on the greatest common level by a simple integer subtraction of the treeIDs in the path on this level.
• The result of this subtraction indicates the relation between the two paths, if it is zero they are considered to be equal. Otherwise the sign indicates the ordering of the two compared leaves.

In a tree with leaves on different levels, this results in children to be considered to be equal to their parents.

## Components

TypeVisibilityAttributesNameInitial
integer, private :: Level

Levels counted from 1 This level is 1 higher than the actual level.

integer(kind=long_k), private :: Node(globalMaxLevels+1)

treeIDs from current leaf to root