Hierarchy on Graph

Certified Senior Developer

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

  Discussion posts and replies are publicly visible

Parents Reply Children