 Newick - Maple Help

Newick (.newick) Format

Newick file format Description

 • Newick is a simple text-based format for describing a tree with edge lengths using parentheses and commas.
 • The GraphTheory[Newick] can convert a Graph representing a tree to its Newick encoding as a string, and vice versa.
 • The GraphTheory[ImportGraph] and GraphTheory[ExportGraph] commands can read from and write to this format.
 • The general-purpose commands Import and Export also support this format. Examples

Return the Newick encoding of a tree.

 > $T≔\mathrm{GraphTheory}:-\mathrm{Graph}\left(\left\{\left\{1,11\right\},\left\{1,12\right\},\left\{2,10\right\},\left\{2,12\right\},\left\{3,10\right\},\left\{4,5\right\},\left\{4,9\right\},\left\{4,11\right\},\left\{5,7\right\},\left\{6,12\right\},\left\{8,11\right\}\right\}\right)$
 ${T}{≔}{\mathrm{Graph 1: an undirected graph with 12 vertices and 11 edge\left(s\right)}}$ (1)
 > $\mathrm{GraphTheory}:-\mathrm{Newick}\left(T\right)$
 ${"\left(\left(\left(\left(7\right)5,9\right)4,8\right)11,\left(\left(\left(3\right)10\right)2,6\right)12\right)1;"}$ (2)

Export this to a file in the home directory of the current user.

 > $\mathrm{Export}\left("mytree.newick",\mathrm{DG},\mathrm{base}=\mathrm{homedir}\right)$
 ${35}$ (3) References

 "Newick file format", Wikipedia, https://en.wikipedia.org/wiki/Newick_format.