(Before you down mod it: nope, this is not homework)
I have a web system which has a classical parent-children menu saved in a database, with fields id as the PK, and parent_id to pointing to the owning menu. (Yes, I know this doesn't scale very well, but that's another topic).
So for these records (id-parent_id pairs):
0-7 0-4 4-9 4-14 4-16 9-6
I have this tree:
0
├ 7
└ 4
├ 9
| └ 6
├ 14
└ 16
I'm needing to hide a top node, so I have to make a list of all the childrens of that certain node, i.e. for 4, they will be (9, 6, 14, 16). Order doesn't matters.
I'm confused... does this fits into the classical tree problems? or is it a graph one?
How can I compose this structure and solve this problem using php?