phylox.isomorphism.base.is_isomorphic
- phylox.isomorphism.base.is_isomorphic(network1, network2, partial_isomorphism=None, ignore_labels=False, label_attr='label', use_mu_vector=False)
Determines whether two networks are labeled isomorphic.
- Parameters:
network1 – a phylogenetic network, i.e., a DAG with leaf labels stored as the node attribute LABEL_ATTR.
network2 – a phylogenetic network, i.e., a DAG with leaf labels stored as the node attribute LABEL_ATTR.
partial_isomorphism – a list of node pairs, one from network1 and one from network2 each. These pairs are mapped to each other.
ignore_labels – ignore node labels (attr LABEL_ATTR) when deciding isomorphism.
label_attr – the label attr for the nodes to use instead of the default node attr LABEL_ATTR.
use_mu_vector – Compute mu-vectors for all nodes and use the fact that mu-vectors are retained by an isomorphism.
- Returns:
True if the networks are labeled isomorphic, False otherwise.
- Example:
>>> from phylox import DiNetwork >>> from phylox.isomorphism.base import is_isomorphic >>> network1 = DiNetwork( ... edges=[(0,1),(1,2),(1,3),(2,3),(2,4),(3,5)], ... labels=[(4, "A"), (5, "B")], ... ) >>> network2 = DiNetwork( ... edges=[(0,1),(1,2),(1,3),(2,3),(2,5),(3,6)], ... labels=[(5, "B"), (6, "A")], ... ) >>> is_isomorphic(network1, network2, ignore_labels=True) True >>> is_isomorphic(network1, network2, ignore_labels=False) False >>> is_isomorphic(network1, network2, partial_isomorphism=[(4,6)], ignore_labels=True) False