PhyNetPy Documentation

Library for the Development and Use of Phylogenetic Network Methods

Visitor Module v0.3.0

Visitor pattern interface for ModelNode traversals with typed dispatch.

Author:
Mark Kessler
Last Edit:
5/12/26
Source:
Visitor.py

Contents

Visitor

class Visitor(ABC)

Abstract base for model-node visitors. Subclasses implement one ``visit_*`` method per node kind. :meth:`visit` provides automatic dispatch by calling :pymeth:`ModelNode.get_node_type`.

Methods

visit_leaf(n: ModelNode) -> None abstract

Side-effect callback fired when the traversal lands on a leaf.

Parameter Type Description
n ModelNode The leaf node being visited.
visit_internal(n: ModelNode) -> None abstract

Side-effect callback fired when the traversal lands on an internal node.

Parameter Type Description
n ModelNode The internal node being visited.
visit_reticulation(n: ModelNode) -> None abstract

Side-effect callback fired when the traversal lands on a reticulation node.

Parameter Type Description
n ModelNode The reticulation (hybrid) node being visited.
visit_root(n: ModelNode) -> None abstract

Side-effect callback fired when the traversal lands on the root.

Parameter Type Description
n ModelNode The root node being visited.
visit(n: ModelNode) -> None

Dispatch to the correct ``visit_*`` method based on node type.

Navigation

Modules

This Page