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


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

TreePlot Edges Orientation

From Šerých Jakub <Serych@panska.cz>
Newsgroups comp.soft-sys.math.mathematica
Subject TreePlot Edges Orientation
Date 2011-05-10 00:20 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iqa0cq$d98$1@smc.vnet.net> (permalink)

Show all headers | View raw


Dear MathGroup,

I'm trying to construct binary tree for the Huffman coding table using the TreePlot (the example is for the sentence "She shall sell sea shells by the sea shelfs."). All is working properly, but the TreePlot organizes the edges his way. Normaly it is common to put logical zeros (blue lines) to the left side and logical ones (red lines) to the right side of the forks.
Is there any possibility to tell to the TreePlot, how to organize edges?

Thanks for help in advance

Jakub

Code:

grafik = {{Subscript[2, 1] -> 
\!\(\*SubscriptBox[\(1\), \("\<.\>"\)]\), 0}, {Subscript[2, 1] -> 
\!\(\*SubscriptBox[\(1\), \("\<f\>"\)]\), 1}, {Subscript[2, 2] -> 
\!\(\*SubscriptBox[\(1\), \("\<S\>"\)]\), 0}, {Subscript[2, 2] -> 
\!\(\*SubscriptBox[\(1\), \("\<b\>"\)]\), 1}, {Subscript[2, 3] -> 
\!\(\*SubscriptBox[\(1\), \("\<t\>"\)]\), 0}, {Subscript[2, 3] -> 
\!\(\*SubscriptBox[\(1\), \("\<y\>"\)]\), 
    1}, {Subscript[4, 4] -> Subscript[2, 2], 
    0}, {Subscript[4, 4] -> Subscript[2, 1], 
    1}, {Subscript[5, 5] -> Subscript[2, 3], 0}, {Subscript[5, 5] -> 
\!\(\*SubscriptBox[\(3\), \("\<a\>"\)]\), 
    1}, {Subscript[9, 6] -> Subscript[4, 4], 0}, {Subscript[9, 6] -> 
\!\(\*SubscriptBox[\(5\), \("\<h\>"\)]\), 
    1}, {Subscript[12, 7] -> Subscript[5, 5], 0}, {Subscript[12, 7] -> 
\!\(\*SubscriptBox[\(7\), \("\<l\>"\)]\), 1}, {Subscript[15, 8] -> 
\!\(\*SubscriptBox[\(7\), \("\<e\>"\)]\), 0}, {Subscript[15, 8] -> 
\!\(\*SubscriptBox[\(8\), \("\< \>"\)]\), 1}, {Subscript[17, 9] -> 
\!\(\*SubscriptBox[\(8\), \("\<s\>"\)]\), 
    0}, {Subscript[17, 9] -> Subscript[9, 6], 
    1}, {Subscript[27, 10] -> Subscript[12, 7], 
    0}, {Subscript[27, 10] -> Subscript[15, 8], 
    1}, {Subscript[44, 11] -> Subscript[17, 9], 
    0}, {Subscript[44, 11] -> Subscript[27, 10], 1}};

TreePlot[grafik, Automatic, Subscript[44, 11] , 
 VertexLabeling -> True, 
 VertexRenderingFunction -> (If[
     NumericQ[#2[[2]]], {LightBlue, EdgeForm[Black], Disk[#, .30], 
      Black, Text[#2, #1]}, {LightRed, EdgeForm[Black], 
      Rectangle[# - .20, # + .20], Black, Text[#2, #1]}] &),
 EdgeRenderingFunction -> (If [#3 == 1, {Red, Thick, Line[#1]}, {Blue,
       Thick, Line[#1]}] &)
 , AspectRatio -> Automatic, ImageSize -> Automatic] 

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


Thread

TreePlot Edges Orientation Šerých Jakub <Serych@panska.cz> - 2011-05-10 00:20 +0000

csiph-web