phylox.cherrypicking.tree_child_sequences.find_tree_child_sequence
- phylox.cherrypicking.tree_child_sequences.find_tree_child_sequence(network, labels=False)
Find a tree child sequence for a network. If the network is orchard but not tree-child, this function may produce a cherry-picking sequence that reduces the network to a single edge, but that is not a tree-child sequence.
- Parameters:
network (phylox.DiNetwork) – The network to find a tree child sequence for.
labels (bool) – Whether to return the tree child sequence as a list of labels instead of a list of nodes.
- Returns:
The tree child sequence.
- Return type:
list
- Example:
>>> from phylox import DiNetwork >>> N = DiNetwork( ... edges=[(-1, 0), (0, 1), (0, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 5), (4, 6)], ... labels=[(5, "A"), (6, "B")], ... ) >>> try: ... find_tree_child_sequence(N, labels=True) ... except ValueError: ... exception_raised = True >>> exception_raised True
>>> N = DiNetwork( ... edges=[(-1, 0), (0, 1), (0, 2), (1, 2), (1, 3), (2, 4), (3, 4), (3, 5), (4, 6)], ... labels=[(5, "A"), (6, "B")], ... ) >>> TC_sequence = find_tree_child_sequence(N, labels=True) >>> TC_sequence == [("B", "A"), ("B", "A"), ("B", "A")] or TC_sequence == [("A", "B"), ("B", "A"), ("B", "A")] True