Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Object

mapping a hierarchy to a tree

 
Jump to:  
 
Guest
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

depresja painting contractors Bilety lotnicze PoznaƄ regaƂy poker zasady gry