Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16613

Re: TreePlot

Path csiph.com!usenet.pasdenom.info!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From Marco Gabiccini <m.gabiccini@ing.unipi.it>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: TreePlot
Date Sat, 8 Mar 2014 07:43:28 +0000 (UTC)
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <lfehn0$5lf$1@smc.vnet.net> (permalink)
References <20140306070605.915576A18@smc.vnet.net> <CAEtRDSe1sq=fLwbX0iiXjzE+H3tiTNCxzJ7FGvDDK+9TzkbzqA@mail.gmail.com>
Lines 118
Organization Time-Warner Telecom
NNTP-Posting-Date 08 Mar 2014 07:49:07 GMT
NNTP-Posting-Host 2b989778.news.twtelecom.net
X-Trace DXC=n:iQ?o6iQ0iiUai=K\Eb@nC_A=>8kQj6m;[h;PUXBgbdj4eD5l`OG?oEFiONJ7[GofYN\7M<;bBFh
X-Complaints-To abuse@twtelecom.net
X-Received-Bytes 4117
X-Received-Body-CRC 2139487743
Xref csiph.com comp.soft-sys.math.mathematica:16613

Show key headers only | View raw


Dear Bob,

thanks for the precious help.

Indeed an elegant and practical solution.

Best,

Marco

Il 06/03/2014 15:19, Bob Hanlon ha scritto:
>
> Add a frame to the edge labels.
>
>
> treeStructure = {{0, 1}, {1, 2}, {1, 3}, {3, 5},
>    {0, 4}, {4, 6}, {4, 7}, {4, 8}};
>
>
> jointList = Map[Last, treeStructure];
>
>
> edgeList = Thread[
>    (DirectedEdge @@@ treeStructure) ->
>     (Framed[#, FrameStyle -> White,
>         Background -> White] & /@
>       jointList)];
>
>
> g = TreeGraph[
>   DirectedEdge @@@ treeStructure,
>   VertexLabels -> Placed["Name", After],
>   GraphRoot -> 0,
>   EdgeLabels -> edgeList,
>   VertexSize -> 0.15,
>   EdgeStyle -> Thick,
>   EdgeLabelStyle -> Directive[Red, Bold, 16],
>   VertexLabelStyle -> Directive[Black, 14],
>   ImagePadding -> 20,
>   GraphHighlight -> {0},
>   GraphHighlightStyle -> "DehighlightGray"]
>
>
> To grow from the bottom, suppress the display of g (use ;) and use its 
> VertexCoordinates to draw an inverted graph.
>
>
> g2 = TreeGraph[
>   DirectedEdge @@@ treeStructure,
>   VertexLabels -> Placed["Name", After],
>   GraphRoot -> 0, EdgeLabels -> edgeList,
>   VertexSize -> 0.15, EdgeStyle -> Thick,
>   EdgeLabelStyle -> Directive[Red, Bold, 16],
>   VertexLabelStyle -> Directive[Black, 14],
>   ImagePadding -> 20,
>   GraphHighlight -> {0},
>   GraphHighlightStyle -> "DehighlightGray",
>   VertexCoordinates -> ((VertexCoordinates /.
>        AbsoluteOptions[g, VertexCoordinates]) /.
>      {x_, y_} -> {x, -y})]
>
>
>
> Bob Hanlon
>
>
>
>
> On Thu, Mar 6, 2014 at 2:06 AM, Marco Gabiccini 
> <m.gabiccini@ing.unipi.it <mailto:m.gabiccini@ing.unipi.it>> wrote:
>
>     Dear all,
>
>     I am trying to obtain a nice visualization of generic trees in
>     Mathematica for mechanism analysis.
>
>     I have been able to use something like:
>
>     treeStructure = {{0, 1}, {1, 2}, {1, 3}, {3, 5}, {0, 4}, {4, 6}, {4,
>          7}, {4, 8}};
>
>     jointList = Map[Last, treeStructure];
>
>     edgeList = MapThread[Rule,
>         {Map[DirectedEdge @@ # &, treeStructure],
>          jointList}
>         ];
>
>     g = TreeGraph[
>        Map[DirectedEdge @@ # &, treeStructure],
>        VertexLabels -> "Name",
>        GraphRoot -> 0,
>        EdgeLabels -> edgeList,
>        VertexSize -> 0.15, EdgeStyle -> Thick,
>        EdgeLabelStyle -> Directive[Red, Bold, 16],
>        VertexLabelStyle -> Directive[Black, 14]]
>
>     and all is fine. However, I was trying to exploit the apparently more
>     freedom given by the command TreePlot, e.g. to create a small white
>     frame behind the names of the edges so that the text does not collide
>     with the edge itself, have the tree grow from the bottom up, etc.,
>      but
>     I am facing the problem that it seems that TreePlot overrides the
>     names
>     given to the nodes (e.g, my root node must be zero and it is
>     automatically renamed 1) and there seems to be no smart function like
>     that is TreeGraph VertexLabels->"Name".
>
>     Any hint about how the get, at the same time, the best of both
>     commands?
>     Or, at least, have a better visualization using TreeGraph?
>
>     Thanks,
>
>     Marco
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Re: TreePlot Marco Gabiccini <m.gabiccini@ing.unipi.it> - 2014-03-08 07:43 +0000

csiph-web