Visualizing the number of trees for n labeled vertices (for n = 3, 4, 5, ...)
Visualizing the number of trees for n labeled vertices (for n = 3, 4, 5, ...)
Code
Code
In[]:=
(*Graphhelperfunction.*)fun[code_]:=Module[{v=Range[Length[code]+2],cd=code,e={},c},While[Length[v]≠2,c=Sort[Complement[v,cd]];AppendTo[e,{cd[[1]],c[[1]]}];v=DeleteCases[v,c[[1]]];cd=Drop[cd,1];];Graph[UndirectedEdge@@@AppendTo[e,v],VertexSize0.3,VertexLabelsTable[iPlaced[Style[i,White,Bold],{1/2,1/2}],{i,v[[-1]]}],VertexStyleTable[iColorData["Rainbow"][i/v[[-1]]],{i,v[[-1]]}]]](*Visualizealltreesatonce.*)disp[n_]:=Grid[Partition[Column[{#,fun[#]}]&/@Tuples[Range[n],n-2],n],FrameAll](*Visualizeaparamaterizedtreeforsomen>2.*)man[u_]:=Manipulate[fun[{##}[[All,1]]],##,ControlTypeSetterBar,SaveDefinitionsTrue]&@@Table[{Symbol["x"<>ToString[i]],Range[u]},{i,u-2}](*Source:https://mathematica.stackexchange.com/questions/212054/visualizing-cayleys-formula-in-mathematica/212191#212191*)
Visualizing all 4-trees at once.
Visualizing all 4-trees at once.
In[]:=
disp[4]
Out[]=
|
|
|
| ||||||||
|
|
|
| ||||||||
|
|
|
| ||||||||
|
|
|
|
Visualizing all 10-trees by parameter.
Visualizing all 10-trees by parameter.
In[]:=
man[10]
Out[]=
The number of n-trees for n > 2
The number of n-trees for n > 2
In[]:=
ListLinePlot[Table[{n,n^(n-2)},{n,3,6,1}],MeshFull,PlotLabel(n^(n-2))]
Out[]=
Visualizing n-trees for custom n > 2
Visualizing n-trees for custom n > 2
In[]:=
d=Manipulate[disp[n],{n,3,5,1},SaveDefinitionsTrue];CloudDeploy[d,Permissions"Public"]
Out[]=
In[]:=
m=Manipulate[man[n],{n,5,10,1},SaveDefinitionsTrue];CloudDeploy[m,Permissions"Public"]
Out[]=