phylox.networkproperties.murepresentation.add_mu_vectors_as_attribute

phylox.networkproperties.murepresentation.add_mu_vectors_as_attribute(network)

The mu-vectors are added as a tuple(str, int, …, int) with the label of the node as first entry, and then the mu-vector consisting of num_path values. For each labeled node, the num_paths value belonging to their label is set to one. Then, starting with the leaves and going up, the number of paths to each labeled node is calculated for all of the nodes, by adding the mu-vector of its children to that of itself.

The mu-vector entries are ordered by label.

The resulting vectors are stored in the node attr MUVECTOR_ATTR and the network is modified in place.

Parameters:

network – a DiNetwork

Example:

>>> from phylox import DiNetwork
>>> from phylox.networkproperties.murepresentation import add_mu_vectors_as_attribute
>>> network = DiNetwork.from_newick("((A,B),C);")
>>> add_mu_vectors_as_attribute(network)
>>> network.nodes[network.labels["A"][0]].get(MUVECTOR_ATTR)
('A', 1, 0, 0)
>>> network.nodes[network.labels["B"][0]].get(MUVECTOR_ATTR)
('B', 0, 1, 0)
>>> network.nodes[network.labels["C"][0]].get(MUVECTOR_ATTR)
('C', 0, 0, 1)