Skip to main content
April 16, 2025
Question

Hierarchy on Graph

  • April 16, 2025
  • 3 replies
  • 0 views

We have a structure in db

with an id, INFO, fatherID, level

I have to given an ID, have to reconstruct all the Hierarchical Structure under the Given ID

The Structure is a Three

                                                                                          /------------ID1------------\

                                 ID2[fatherID:ID1]                                                                               ID3[fatherID:ID1]

ID4[fatherID:ID2] -/                               \- ID5[fatherID:ID2]               ID6[fatherID:ID3]-/                                    \-ID7[fatherID:ID3]

Given an ID i have to reconstruct all the hierarchy under the given id,

For Example given ID1 that is the root, i have to list ID1, ID2, ID3, ID4, ID5, ID6

Another Example is, given ID3 i have to list ID3, ID6, ID7

I'm trying to do it with a reduce() with recursion, but without success

3 replies

stefanhelzle0001
April 16, 2025

Reduce() does no recursion.

I wrote a blog post on how to do this: appian.rocks/.../

April 16, 2025

Hi stefan you are even precious i user your post to resolve a hyerarchical path problem. With same structure starting from a bottone leaf level i finded the path from leaf to roof... but this time the approch have to be Top Down and not bottom up. Do you think that the article can be even useful

stefanhelzle0001
April 17, 2025

Yes I do.