For demo, exploration and teaching purposes, I would like to be able (and asking you for help) to generate these special instances of trees:
For given:
- N - number of nodes in the tree
- D - depth of the tree (largest distance root-leaf)
I need to generate a random tree with all nodes labeled so that:
- Root is labeled "Lorem"
- First or other prominent child of the root is labeled "ipsum".
- All other children are labeled randomly from words from following paragraph: "dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Example from related question: (but this solution doesn't care about depth limitations)
vtx[] := Table[i <-> RandomInteger[{0, i - 1}], {i, 1, 50}];
Graph@vtx[]
Tree should look like this: (just imagine words instead of numbers)
1 -> "Lorem"
,2 -> "Ipsum"
and then thread the remaining integers with aRandomSample
of the remaining words? $\endgroup$DepthFirstScan
. You can try to code this in Mathematica. $\endgroup$