Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Tree with repeated labels

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113243] Re: Tree with repeated labels
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Wed, 20 Oct 2010 04:08:20 -0400 (EDT)

tree[1, nBranches_: 3] :== tree[1, nBranches] ==
   Thread[0 -> Range[nBranches]];

tree[n_Integer?Positive, nBranches_: 3] :==
 tree[n, nBranches] ==
  Flatten[{tree[n - 1, nBranches],
    Thread[# -> (10 # + Range[nBranches])] & /@
    
     Last /@ Take[tree[n - 1, nBranches],
       -nBranches^(n - 1)]}]

nLevels == 3;

TreePlot[tree[nLevels], Left,
 VertexRenderingFunction ->
  ({White, EdgeForm[Black], Disk[#, 0.1],
     Black,
     Text[Last[IntegerDigits[#2]], #1]} &),
 ImageSize -> 85*nLevels]


Bob Hanlon

---- "Francisco Javier Garc=C3=ADa Capit=C3=A1n" <garciacapitan at gmail.com> wrote:

==========================
I would like (using TreePlot or another way) to display a tree with say
three levels  such that the root is the symbol 0 and each node having three
daughters labelled 1, 2 and 3

TreePlot[{0->1, 0->2,0->3}]

does the first level, but I don't know how  to continue.



--
---
Francisco Javier Garc==EDa Capit==E1n
http://garciacapitan.auna.com


  • Prev by Date: Why so slow and not getting faster
  • Next by Date: Re: ListAnimate
  • Previous by thread: Tree with repeated labels
  • Next by thread: Re: Tree with repeated labels