Newick Format

Author

Eric W. Weisstein
August 13, 2026

This notebook downloaded from https://mathworld.wolfram.com/notebooks/GraphTheory/NewickFormat.nb.

For more information, see Eric's MathWorld entry https://mathworld.wolfram.com/NewickFormat.html.

©2026 Wolfram Research, Inc. except for portions noted otherwise

Illustration

The rooted tree represented by the Newick string ((A,B),(C,D)); is shown below.

Module[{coordinates,edges,neutral},coordinates=Association["root"->{0,2},"left"->{-1,1},"right"->{1,1},"A"->{-(3/2),0},"B"->{-(1/2),0},"C"->{(1/2),0},"D"->{(3/2),0}];edges={{"root","left"},{"root","right"},{"left","A"},{"left","B"},{"right","C"},{"right","D"}};neutral=LightDarkSwitched[Black,White];Graphics[{Directive[neutral,AbsoluteThickness[2]],(Line[Lookup[coordinates,#1]]&)/@edges,PointSize[0.018],Point[Values[coordinates]],(Text[Style[#1,18,neutral,FontFamily->"Times"],coordinates[#1]+{0,-(1/4)}]&)/@{"A","B","C","D"},Text[Style["((A,B),(C,D));",17,neutral,FontFamily->"Times"],{0,(47/20)}]}]]