MATLAB Answers

making combinations from each leaf to parent node in Matlab

7 views (last 30 days)
Sohaib  Bin Altaf
Sohaib Bin Altaf on 19 Jun 2018
Commented: Sohaib Bin Altaf on 22 Jun 2018
Hello, I have to make all combinations from a tree, starting from parent node and ends at the last leaf nodes. The depth of all leaf nodes is same. I don't understand how can i get such a combination... starting from parent node ending to the leaf node.
Can anyone help please.
  5 Comments
Sohaib  Bin Altaf
Sohaib Bin Altaf on 21 Jun 2018
I followed this article, i was able to construct my required tree but unable to extract the branches which i need,

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 21 Jun 2018
Consider building your tree as a graph. You could create the adjacency matrix or the edge lists as shown on that page or you could start with an empty graph and use addedge to add edges (either one at a time, or from a parent to each of its children, or in some other grouping.)
As you add edges, you can plot the resulting graph to see how it is growing. The rmedge function may help if you accidentally add the wrong edge.
  1 Comment
Sohaib  Bin Altaf
Sohaib Bin Altaf on 22 Jun 2018
thanks a lot for your suggestion, i will try graphs this time. I hope it solves my problem.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!