Using the functions layersF
and edgesF
from this answer:
ClearAll[layersF, edgesF];
layersF = Module[{k = 1}, Table[k++, {i, #}, {j, i}]] &;
edgesF = Flatten[Thread /@ Thread[# -> Partition[#2, 2, 1]] & @@@
Partition[layersF[#], 2, 1], 2]&;
m = {{5}, {4, 6}, {3, 5, 7}, {2, 4, 6, 8}};
el = edgesF @ Length[m];
vlabels = Thread[Flatten[layersF@Length[m]] -> (Placed[#, Center] & /@ Flatten[m])];
options = {VertexShapeFunction -> "Square", VertexSize -> {0.1, 0.1},
ImagePadding -> 20, VertexStyle -> Hue[0.125`, 0.7`, 0.9`],
ImageSize -> 400, BaseStyle -> Arrowheads[Large]};
g = Graph[el, options, VertexLabels -> vlabels,
GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> (Length /@ m)}]
Show[g, Frame -> True,
GridLines -> (gl = DeleteDuplicates /@ Transpose@GraphEmbedding[g]),
FrameTicks -> {{None, None}, {Transpose[{gl[[1]], Range[0, 3]}], None}}]
TreeForm[m]
? $\endgroup$TreeForm[m]
, but it places all values at the final nodes. I need the progressing as I on the picture I posted. Just a regular tree plot. It's probably possible withTreeForm[m]
, but I'd need to transform my inputm
somehow. @march: thanks. posted a sample plot. $\endgroup$