I want to draw a tree plot for Euler totient function for this question like the following:
I generate the EulerPhi for first 20 numbers into a list:
list = Map[# -> EulerPhi[#] &, Range[2, 20]]
Then I plot it using this:
TreePlot[list, Bottom, 1, VertexLabeling -> True, DirectedEdges -> True ]
And the output:
But I want the layout of tree become like the above one so that numbers of form $2^n$ are centered and branches to the left or right. How can I do this?
By manually editing the graph the output looks like the following
Updated
I've managed to centralize the powers of $2$ but now the branches aren't placed well.
y = 0; coordinates =
Map[First[#] -> {0, y++} &,
Select[Prepend[list, 1 -> {0, 0}], IntegerQ[Log[2, First[#]]] &]]
{1 -> {0, 0}, 2 -> {0, 1}, 4 -> {0, 2}, 8 -> {0, 3}, 16 -> {0, 4}}
and using GraphPlot
:
GraphPlot[list, VertexLabeling -> True, DirectedEdges -> True,
VertexCoordinateRules -> coordinates]
Now, If the branches are placed upper than the root, then the result would be OK.