mapping a hierarchy to a tree

This is a discussion on mapping a hierarchy to a tree within the Object forums in Theory and Concepts category; hi there, i want to map a hierarchy in a tree , i have level of each node, and the parent id. any ideas?...

Go Back   Application Development Forum > Theory and Concepts > Object

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-02-2008, 05:50 AM
s.doroodian@gmail.com
Guest
 
Default 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?
Reply With Quote
  #2  
Old 08-02-2008, 09:24 AM
Phlip
Guest
 
Default 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?
Reply With Quote
  #3  
Old 08-03-2008, 03:16 PM
H. S. Lahman
Guest
 
Default 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
Reply With Quote
  #4  
Old 08-04-2008, 02:25 PM
Tegiri Nenashi
Guest
 
Default 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.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:58 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.