mapping a hierarchy to a tree - Object
This is a discussion on mapping a hierarchy to a tree - Object ; hi there,
i want to map a hierarchy in a tree , i have level of each node, and
the parent id.
any ideas?...
-
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?
-
Re: mapping a hierarchy to a tree
s.doroodian@gmail.com wrote:
> 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?
-
Re: mapping a hierarchy to a tree
Responding to S.doroodian@gmail.com...
> 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
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@pathfindermda.com for your copy.
Pathfinder is hiring:
http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH
-
Re: mapping a hierarchy to a tree
On Aug 2, 2:50 am, s.dorood...@gmail.com wrote:
> 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.