Min-tree PD#

Min-tree diversity measure implementation.

class phypanda.measure.min_tree.MinTreeDiversity#

Bases: object

Minimum displayed-tree diversity measure.

Examples

>>> import phypanda as pp
>>> # pp.min_tree.compute_diversity(network, {"a"})
compute_diversity(network: DirectedPhyNetwork, taxa: Set[str], tree_extension: TreeExtension | None = None, **kwargs: Any) float#

Compute minimum displayed-tree diversity for a fixed taxon set.

Parameters:
  • network (DirectedPhyNetwork) – Input phylogenetic network.

  • taxa (Set[str]) – Selected taxa.

  • tree_extension (TreeExtension | None, optional) – Optional tree extension for the full network. If the working network is network itself (no pruning), it is used as-is; otherwise it is adapted with adapt_tree_extension_for_pruned_network().

  • **kwargs (Any) – Keyword arguments forwarded to scanwidth.node_scanwidth when a tree extension is computed.

Returns:

Minimum all-paths diversity value across displayed trees.

Return type:

float

Examples

>>> import phypanda as pp
>>> # pp.min_tree.compute_diversity(network, {"a", "b"})
solve_maximization(network: DirectedPhyNetwork, budget: int, costs: Mapping[str, int] | None = None, **kwargs: Any) tuple[float, Set[str]]#

Solve budgeted MinTreePD maximization.

Notes

This exact optimizer is not implemented yet.

Examples

>>> import phypanda as pp
>>> # pp.min_tree.solve_maximization(network, budget=5)
phypanda.measure.min_tree.adapt_tree_extension_for_pruned_network(working_network: DirectedPhyNetwork, tree_extension: TreeExtension) TreeExtension#

Derive a tree extension for working_network from one on a supergraph.

For each Γ-vertex absent from working_network, connect its Γ-parent to each Γ-child and remove that vertex. The result is a valid tree extension for the pruned DAG; node scanwidth is at most that of tree_extension.

If working_network already uses the full vertex set of tree_extension.tree, the shortcut loop does nothing and the returned object wraps a copy of Γ with the working DAG.

phypanda.measure.min_tree.prune_to_taxa(network: DirectedPhyNetwork, taxa: Set[str]) DirectedPhyNetwork#

Return the PhyloZoo subnetwork induced by taxa.

If taxa is exactly the leaf set of network, returns network unchanged (same object).