Re: TreePlots and GraphPlots
- To: mathgroup at smc.vnet.net
- Subject: [mg88609] Re: TreePlots and GraphPlots
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 9 May 2008 07:17:30 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fvudp8$eck$1@smc.vnet.net>
Namrata Khemka wrote: > I have a question regarding TreePlot and GraphPlots. I have the following > list : > myList1 = {{1.9124437047927545`, 2.140934695277407`, > 2.4290608973234304`}, {3.1220434925197633`}, {3.193277882536842`, > 3.321086033303083`, 3.3624160109272454`}, {3.8240882444935016`, > 4.778362811870326`}} > > One of the elements in this list is set as the root node for a tree - based > structure. For instance : > treeRoot = myList1[[2]] > > Based on the list above : I would like the root node will have 3 children > The first child has 3 leaf nodes > {1.9124437047927545`, 2.140934695277407`, 2.4290608973234304`}, the second > child has three leaf nodes > {3.193277882536842`, 3.321086033303083`, 3.3624160109272454`} and finally > the third child has 2 leaf nodes : > {3.8240882444935016`, 4.778362811870326`}. > > In other words, I am trying to represent myList1 in a tree structure. I am > not able to create a list of rules for the tree. Any suggestions/ > ideas would be great. The following may suit your needs. myList1 = {{1.9124437047927545`, 2.140934695277407`, 2.4290608973234304`}, {3.1220434925197633`}, {3.193277882536842`, 3.321086033303083`, 3.3624160109272454`}, {3.8240882444935016`, 4.778362811870326`}}; myList2 = Thread[Table[myList1[[2]], {Length[myList1] - 1}] -> Delete[myList1, 2]] TreePlot[myList2, VertexLabeling -> True] {{3.12204} -> {1.91244, 2.14093, 2.42906}, {3.12204} -> {3.19328, 3.32109, 3.36242}, {3.12204} -> {3.82409, 4.77836}} [... Tree plot deleted ...] Regards, -- Jean-Marc
- Follow-Ups:
- Re: Re: TreePlots and GraphPlots
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: TreePlots and GraphPlots