Newick - Maple Help

GraphTheory

 Newick
 compute Newick encoding

 Calling Sequence Newick(G, opts) Newick(s)

Parameters

 G - graph; tree or arborescence s - string opts - (optional) one or more options as specified below

Options

 • directed = truefalse
 Specifies whether the output graph should be directed or undirected when the input is a Newick string. The default is true. When the input is not a string, this option is ignored.
 • root = string, name, or integer
 Specifies a root vertex when the input is an undirected graph. The default value is the first vertex in the list returned by Vertices. When the input is not an undirected graph, this option is ignored.

Description

 • Newick(G), where G is a graph, returns a string comprising the Newick encoding of G.
 If G is undirected, it must be a tree.
 If G is directed, it must be an arborescence or anti-arborescence.
 • Newick(s), where s a string, returns a graph whose Newick encoding is s.

Examples

Generate the Newick encoding of a tree.

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

Generate the Newick encoding of an arborescence.

 > $A≔\mathrm{Graph}\left(10,\left\{\left[2,5\right],\left[3,4\right],\left[3,7\right],\left[4,1\right],\left[5,3\right],\left[5,6\right],\left[9,8\right],\left[10,2\right],\left[10,9\right]\right\}\right)$
 ${A}{≔}{\mathrm{Graph 2: a directed unweighted graph with 10 vertices and 9 arc\left(s\right)}}$ (3)
 > $\mathrm{Newick}\left(A\right)$
 ${"\left(\left(\left(\left(\left(1\right)4,7\right)3,6\right)5\right)2,\left(8\right)9\right)10;"}$ (4)

Generate the unweighted graph corresponding to a given Newick encoding.

 > $\mathrm{Newick}\left("\left(\left(\left(\left(\left(6,\left(\left(\left(9\right)16\right)4\right)15\right)8,\left(11,\left(19\right)20\right)10\right)2,\left(17\right)12,13\right)3,\left(7\right)5\right)14,18\right)1;"\right)$
 ${\mathrm{Graph 3: a directed unweighted graph with 20 vertices and 19 arc\left(s\right)}}$ (5)

Generate the weighted graph corresponding to a given Newick encoding.

 > $\mathrm{Newick}\left("\left(\left(\left(\left(\left(\left(\left(4:2.990\right)10:6.574\right)9:5.323\right)6:2.994,\left(5:1.025\right)8:6.644\right)7:2.876\right)3:8.254\right)2:6.146\right)1;"\right)$
 ${\mathrm{Graph 4: a directed weighted graph with 10 vertices and 9 arc\left(s\right)}}$ (6)

Compatibility

 • The GraphTheory[Newick] command was introduced in Maple 2021.