|  | mapping a hierarchy to a tree |  | |
| | | Guest |  |
| Posted: Sat Aug 02, 2008 9:50 am Post subject: mapping a hierarchy to a tree |  |
hi there, i want to map a hierarchy in a tree , i have level of each node, and the parent id. any ideas? |
| |
| | | Phlip |  |
| Posted: Sat Aug 02, 2008 11:24 am Post subject: Re: mapping a hierarchy to a tree |  |
s.doroodian@gmail.com wrote:
| Quote: | i want to map a hierarchy in a tree , i have level of each node, and the parent id. any ideas?
|
A class hierarchy? or a "composite design pattern"?
Either way, they already are a tree. What problem are you trying to solve? |
| |
| | | H. S. Lahman |  |
| Posted: Sun Aug 03, 2008 5:16 pm Post subject: Re: mapping a hierarchy to a tree |  |
Responding to S.doroodian@gmail.com...
| Quote: | i want to map a hierarchy in a tree , i have level of each node, and the parent id.
|
On the unlikely chance this is not a homework problem...
[Tree] | 0..1 | root for | | R1 | | 1 0..* parent of [Node] -------------+ | 0..1 | | child of | R2 | | +----------------+
Actually, the level is redundant information. You an construct the tree by simply instantiating the R2 relationship between each Node and its parent. (The Node with no parent ID will be the root Node of the tree.)
-- There is nothing wrong with me that could not be cured by a capful of Drano.
H. S. Lahman hsl@pathfindermda.com Pathfinder Solutions LINK blog: LINK "Model-Based Translation: The Next Step in Agile Development". Email info@pathfindermda.com for your copy. Pathfinder is hiring: LINK (888)OOA-PATH |
| |
| | | Tegiri Nenashi |  |
| Posted: Mon Aug 04, 2008 6:25 pm Post subject: Re: mapping a hierarchy to a tree |  |
On Aug 2, 2:50 am, s.dorood...@gmail.com wrote:
| Quote: | hi there, i want to map a hierarchy in a tree , i have level of each node, and the parent id. any ideas?
|
I assume each node has its own id as well. Then, level is redundant, and you can restore tree structure by following id->parent_id links. This problem has nothing to do with OO. |
| |
|
|