Compare two Paths in the linearized tree Result: -1: left is lower than right 0: left is same than right 1: left is higher than right
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_path_type), | intent(in) | :: | left |
candidate path |
||
type(tem_path_type), | intent(in) | :: | right |
candidate path |
relation between the paths
elemental function tem_PathComparison( left, right ) result(relation) ! --------------------------------------------------------------------------- !> candidate path type(tem_path_type), intent(in) :: left !> candidate path type(tem_path_type), intent(in) :: right !> relation between the paths integer :: relation ! --------------------------------------------------------------------------- integer :: maxPathLen integer(kind=long_k) :: diff ! --------------------------------------------------------------------------- ! Find the greatest common level. maxPathLen = min(left%level-1, right%level-1) ! Difference of treeIDs on that level indicates the relation of the two ! paths. diff = left%Node( left%Level - maxPathLen) & & - right%Node(right%Level - maxPathLen) ! Normalize the relation. relation = int(diff / max(1_long_k, abs(diff))) end function tem_PathComparison