phylox.cherrypicking.base.reduce_pair
- phylox.cherrypicking.base.reduce_pair(network, x, y, inplace=False, nodes_by_label=False)
Reduces the reducible pair (x,y) in the network. Note: Cache of network properties is not updated.
- Parameters:
network (phylox.DiNetwork) – The network to reduce the reducible pair in.
x (str or int) – The first element of the reducible pair.
y (str or int) – The second element of the reducible pair.
inplace (bool) – If True, the network is modified in place.
nodes_by_label (bool) – If True, the nodes x and y are interpreted as labels.
- Returns:
phylox.DiNetwork – The network with the reducible pair reduced.
CHERRYTYPE – The type of the reducible pair.
- Raises:
ValueError – If x or y are not in the network.
Examples
>>> from phylox import DiNetwork >>> from phylox.cherrypicking.base import reduce_pair, CHERRYTYPE >>> network = DiNetwork( ... edges=[(-1,0), (0,1), (0,2), (1,2), (1,3), (2,4)], ... ) >>> network, cherry_type = reduce_pair(network, 4, 3) >>> cherry_type == CHERRYTYPE.RETICULATEDCHERRY True >>> set(network.edges) == {(-1, 0), (0, 3), (0, 4)} True