-# Hooke is free software: you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
-# Hooke is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
-# You should have received a copy of the GNU Lesser General Public
-# License along with Hooke. If not, see
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke. If not, see <http://www.gnu.org/licenses/>.
"""Define :class:`Graph`, a directed, acyclic graph structure.
:class:`Graph`\s are composed of :class:`Node`\s, also defined by this
"""Define :class:`Graph`, a directed, acyclic graph structure.
:class:`Graph`\s are composed of :class:`Node`\s, also defined by this
>>> g = Graph([a, b, c, d])
>>> g.set_children()
>>> g = Graph([a, b, c, d])
>>> g.set_children()
For the split/join branch columns, "born" and "dead" are defined
from the point of view of `GraphRow`. For root-to-tip ordering
For the split/join branch columns, "born" and "dead" are defined
from the point of view of `GraphRow`. For root-to-tip ordering
>>> n.i.extend([n.f, n.g, n.h])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
>>> g.topological_sort(tip_to_root=True)
>>> n.i.extend([n.f, n.g, n.h])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
>>> g.topological_sort(tip_to_root=True)
[i, h, g, f, e, d, c, b, a]
[i, h, g, f, e, d, c, b, a]
>>> n.g.extend([n.e, n.f])
>>> n.h.extend([n.c, n.g])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h])
>>> n.g.extend([n.e, n.f])
>>> n.h.extend([n.c, n.g])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h])
... nx = getattr(n, char)
... n.i.append(nx)
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
... nx = getattr(n, char)
... n.i.append(nx)
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
... nx = getattr(n, char)
... nx.append(n.a)
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
... nx = getattr(n, char)
... nx.append(n.a)
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
>>> n.h.extend([n.a, n.c, n.d, n.g])
>>> n.i.extend([n.a, n.b, n.c, n.g])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])
>>> n.h.extend([n.a, n.c, n.d, n.g])
>>> n.i.extend([n.a, n.b, n.c, n.g])
>>> g = Graph([n.a,n.b,n.c,n.d,n.e,n.f,n.g,n.h,n.i])