phylox.rearrangement.heuristics.utils

Functions

AllBelow(network, node)

Finds all nodes below a given node in a network.

HighestNodesBelow(network, excludedSet[, ...])

Finds a list of highest tree nodes and a list of highest reticulation nodes below a given set of nodes.

LowestReticAndTreeNodeAbove(network, excludedSet)

Finds a list of lowest tree nodes and a list of lowest reticulation nodes above a given set of nodes.

phylox.rearrangement.heuristics.utils.AllBelow(network, node)

Finds all nodes below a given node in a network.

Parameters:
  • network – a phylogenetic network.

  • node – a node in the network.

Returns:

all nodes in the network that are below the chosen node, including this node.

phylox.rearrangement.heuristics.utils.LowestReticAndTreeNodeAbove(network, excludedSet, allnodes=False)

Finds a list of lowest tree nodes and a list of lowest reticulation nodes above a given set of nodes.

Parameters:
  • network – a phylogenetic network.

  • excludedSet – a set of nodes of the network, must include all leaves.

  • allnodes – a boolean value that determines whether we try to find all lowest nodes (True) or only one lowest node of each type (False, Default). In the latter case, we return not two lists, but two nodes.

Returns:

A list of tree nodes and a list of reticulation nodes, so that each element of these lists has all their children in the excludedSet. If not allNodes, then these lists have length at most 1.

phylox.rearrangement.heuristics.utils.HighestNodesBelow(network, excludedSet, allnodes=False)

Finds a list of highest tree nodes and a list of highest reticulation nodes below a given set of nodes.

Parameters:
  • network – a phylogenetic network.

  • excludedSet – a set of nodes of the network, must include the root.

  • allnodes – a boolean value that determines whether we try to find all highest nodes (True) or only one highest node of each type (False, Default). In the latter case, we return not two lists, but two nodes.

Returns:

A list of tree nodes and a list of reticulation nodes, so that each element of these lists has all their parents in the excludedSet. If not allNodes, then these lists have length at most 1.

phylox.rearrangement.heuristics.utils.FindTreeNode(network, excludedSet=[], randomNodes=False, seed=None)

Finds a (random) tree node in a network.

Parameters:
  • network – a phylogenetic network.

  • excludedSet – a set of nodes of the network.

  • randomNodes – a boolean value.

  • seed – a seed for the random number generator.

Returns:

a tree node of the network not in the excludedSet, or None if no such node exists. If randomNodes, then a tree node is selected from all candidates uniformly at random.

phylox.rearrangement.heuristics.utils.FindLeaf(network, excludedSet=[], excludedParents=[], randomNodes=False, seed=None)

Finds a (random) leaf in a network.

Parameters:
  • network – a phylogenetic network.

  • excludedSet – a set of nodes of the network.

  • excludedParents – a set of nodes of the network.

  • randomNodes – a boolean value.

  • seed – a seed for the random number generator.

Returns:

a leaf of the network not in the excludedSet so that its parent is not in excludedParents, or None if no such node exists. If randomNodes, then a leaf is selected from all candidates uniformly at random.

phylox.rearrangement.heuristics.utils.FindRetic(network, excludedSet=[], randomNodes=False, seed=None)

Finds a (random) reticulation in a network.

Parameters:
  • network – a phylogenetic network.

  • excludedSet – a set of nodes of the network.

  • randomNodes – a boolean value.

  • seed – a seed for the random number generator.

Returns:

a reticulation node of the network not in the excludedSet, or None if no such node exists. If randomNodes, then a reticulation is selected from all candidates uniformly at random.