Newick format

Newick format offers a way of representing binary trees in text form by using parentheses and commas. Here's an example of a straightforward rooted tree.

Example Tree 1

According to this tree, taxa $a$ and $b$ appear to be closely related, as do $c$ and $d$. More formally, $a$ and $b$ are said to be neighbors since they are adjacent to the same internal node of the tree. We label this internal node using the syntax $(a, b)$, then delete $a$ and $b$ and iterate the process. In the end, the above tree can be represented using Newick format as $((a,b),(c,d))$.

Example Tree 2

The above rooted tree, which is more complex, can be represented by the following steps:

Example Tree 3

For unrooted trees, we may arbitrarily construct a root on any one of the tree's edges. root picked arbitrarily at one of the internal edges. As a result, we will wind up with different possible Newick formats. For example, the tree above tree can be represented as $(((a,b),c),(d,e))$ or $((a,b),(c,(d,e)))$; try to find another representation of it.