How can I retrieve the length of a path between two nodes? For instance, given an organizational hierarchy, how can I determine how far separated are a parent and an descendant organization? Consider the following scenarios:
OrgA -hasSubOrganization-> OrgB, OrgC
This is the very simplistic case where I want to get all the immediate suborganizations of an entity. Hence the path length is 1.
OrgA -> OrgB -> OrgC
or the general case
OrgA -> OrgB - - - - - - - - OrgZ
I want to recursively traverse down the graph and find each organization belonging to another organization through the hasSubOrganization
property. To get all the sub-organizations recursive I can use property paths, e.g., the +
operator:
OrgA hasSubOrganization+ ?subOrg
This will give me all the suborganizations right down to the leaf nodes. But my ultimate goal is to build the organization hierarchy, but the information about the "Number of nodes/steps/levels/hops away a suborganization is" is lost. This means that I cannot recreate the org structure for a visualization.
How can I capture the "number of nodes away" information in addition to the name of the suborganization?