TraversalTree
symbolica.community.hepkit Class
TraversalTree()A native DFS or BFS result retaining the immutable physics diagram.
Examples
from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
diagram = model.process(["phi", "phi"], ["phi", "phi"]).generate_diagrams(loops=1, progress=None).diagrams[0]tree = diagram.depth_first_traverse(0)
discovery_order = [vertex.id for vertex in tree.nodes]Member details
subgraph
Property · read-only#subgraph: SubgraphTraversal edges as a reusable physics region, retaining isolated roots.
Examples
edges = diagram.depth_first_traverse(0).subgraph.edgesnodes
Property · read-only#nodes: list[DiagramVertex] Physics vertices in traversal discovery order.
Examples
order = [vertex.id for vertex in diagram.depth_first_traverse(0).nodes]covers
Method#parent
Method#parent(node: int) -> 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
| Name | Type | Default | Description |
|---|---|---|---|
node | int | — | Diagram vertex ID in this traversal. |
children
Method#children(node: int) -> list[DiagramVertex] Immediate children in discovery order.
Examples
children = diagram.depth_first_traverse(0).children(0)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
node | int | — | Diagram vertex ID in this traversal. |
ancestors
Method#ancestors(node: int) -> 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
| Name | Type | Default | Description |
|---|---|---|---|
node | int | — | Diagram vertex ID in this traversal. |
fundamental_cycle
Method#fundamental_cycle(half_edge: int) -> 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
| Name | Type | Default | Description |
|---|---|---|---|
half_edge | int | — | Native diagram half-edge ID whose endpoints are in this traversal. |
View generated signature source: docs/api/python/feynkit-community.pyi:11695