GetNodeRelationship – Check if two nodes are relatives

GetNodeRelationship – Check if two nodes are relatives

' 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 Node, _    ByVal Node2 As Node) As Integer        If Node1 Is Node2 Then        ' this is the simplest case        Exit Function    ElseIf Len(Node1.FullPath) > Len(Node2.FullPath) Then        ' if the two nodes belong to the same subtree, then        ' Node1 is a (grand)child of Node2        If InStr(Node1.FullPath, Node2.FullPath) = 1 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)                Set 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 InStr(Node2.FullPath, Node1.FullPath) = 1 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)                Set Node2 = Node2.Parent                GetNodeRelationship = GetNodeRelationship - 1                If Node1 Is Node2 Then Exit Function            Loop        End If    End If        ' Nodes belong to different subtrees    GetNodeRelationship = 0    End Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

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