TraversalTree
Symbolica documentation for getting started, symbolic expressions, numerical evaluation, pattern matching, and APIs in Python and Rust.
TraversalTree
class TraversalTreeA native DFS or BFS result retaining the immutable physics diagram.
Examples
Using the setup in the FeynmanDiagram class example:
tree = diagram.depth_first_traverse(0)
discovery_order = [vertex.id for vertex in tree.nodes]Attributes
| Name | Description |
|---|---|
nodes |
Physics vertices in traversal discovery order. |
subgraph |
Traversal edges as a reusable physics region, retaining isolated roots. |
nodes
TraversalTree.nodes: builtins.list[DiagramVertex]Physics vertices in traversal discovery order.
Examples
order = [vertex.id for vertex in diagram.depth_first_traverse(0).nodes]subgraph
TraversalTree.subgraph: SubgraphTraversal edges as a reusable physics region, retaining isolated roots.
Examples
edges = diagram.depth_first_traverse(0).subgraph.edgesMethods
| Name | Description |
|---|---|
ancestors |
Strict ancestors from the immediate parent to the root. |
children |
Immediate children in discovery order. |
covers |
Restrict a physics region to vertices visited by this traversal. |
fundamental_cycle |
Fundamental cycle closed by a half-edge, or None for a tree edge. |
parent |
Immediate parent vertex, or None for the traversal root. |
ancestors
TraversalTree.ancestors(node: builtins.int) -> builtins.list[DiagramVertex]Strict ancestors from the immediate parent to the root.
Examples
tree = diagram.depth_first_traverse(0)
ancestors = tree.ancestors(tree.nodes[-1].id)Parameters
node(int) Diagram vertex ID in this traversal.
children
TraversalTree.children(node: builtins.int) -> builtins.list[DiagramVertex]Immediate children in discovery order.
Examples
children = diagram.depth_first_traverse(0).children(0)Parameters
node(int) Diagram vertex ID in this traversal.
covers
TraversalTree.covers(subgraph: Subgraph) -> SubgraphRestrict a physics region to vertices visited by this traversal.
Examples
region = diagram.subgraph(edges=[0])
covered = diagram.depth_first_traverse(0).covers(region)Parameters
subgraph(Subgraph) Region from the same original diagram.
fundamental_cycle
TraversalTree.fundamental_cycle(half_edge: builtins.int) -> typing.Optional[Subgraph]Fundamental cycle closed by a half-edge, or None for a tree edge.
Examples
tree = diagram.depth_first_traverse(0)
cycles = [tree.fundamental_cycle(half.id) for half in diagram.half_edges if not half.edge.is_dangling]Parameters
half_edge(int) Native diagram half-edge ID whose endpoints are in this traversal.
parent
TraversalTree.parent(node: builtins.int) -> typing.Optional[DiagramVertex]Immediate parent vertex, or None for the traversal root.
Examples
tree = diagram.depth_first_traverse(0)
parent = tree.parent(tree.nodes[-1].id)Parameters
node(int) Diagram vertex ID in this traversal.