GetNodeRelationship – Evaluates the relationship between two treeview’s nodes

GetNodeRelationship – Evaluates the relationship between two treeview’s nodes

' Returns a value >0 if node1 is a parent (or grandparent) of node2' Returns a value <0 if node1 is a child (or grandchild) of node2' in both cases the number reflects the number of levels between the two nodes' Returns 0 if the two Nodes are the same or if they belong to different ' subtreesFunction GetNodeRelationship(ByVal node1 As TreeNode, ByVal node2 As TreeNode) _    As Integer    If node1 Is node2 Then        ' this is the simplest case        Return 0    ElseIf node1.FullPath.Length > node2.FullPath.Length Then        ' if the two nodes belong to the same subtree,        '  then node1 is a (grand)child of node2        If node1.FullPath.IndexOf(node2.FullPath) = 0 Then            ' do the loop only if the two nodes appear to belong to the same            ' subtree check that the relationship really exists            Do Until (node1.Parent Is Nothing)                node1 = node1.Parent                GetNodeRelationship = GetNodeRelationship - 1                If node1 Is node2 Then Exit Function            Loop        End If    Else        ' if the two nodes belong to the same subtree,        '  then node1 is a (grand)parent of node2        If node2.FullPath.IndexOf(node1.FullPath) = 0 Then            ' do the loop only if the two nodes appear to belong to the same            ' subtree check that the relationship really exists            Do Until (node2.Parent Is Nothing)                node2 = node2.Parent                GetNodeRelationship = GetNodeRelationship + 1                If node1 Is node2 Then Exit Function            Loop        End If    End If    ' Nodes belong to different subtrees    Return 0End Function

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as