In a tree, can a child have multiple parents?

Viewed 1797

I am developing an application that contains multiple features and each feature has multiple functions. I represented this as a tree but some functions use other functions which means a child can have more than one parent (if I am not wrong). How it is possible in a tree data structure? Can I access the child node from another parent's child node? If so how can I implement this? Can graphs help me with this issue?

2 Answers

If a node has more than two parents, your data structure is no longer a tree. E.g., to quote the wikipedia entry:

A node has at most one parent, but possibly many ancestor nodes, such as the parent's parent.

If you need a data structure where a child can have multiple parents, you should look into a (directed) graph.

a google search gives the answer that:

"Yes, you can have nodes have both “children” and “parents”. However that is no longer a tree structured graph, so you will not be able to use a TreeModel"

Original reference

Related