Subgraph
symbolica.community.hepkit Class
Subgraph()A physics region retaining its immutable original Feynman diagram.
Construct with diagram.subgraph(...) or diagram.filter(...). Inherited physics operations use this selection, with original edge IDs and momentum coordinates. Display keeps the full original graph as muted context. excise() creates independent topology and routing when those are needed.
Examples
from symbolica import S, E
from symbolica.community import hepkit as hep
model = hep.Model.phi4()
process = model.process(["phi", "phi"], ["phi", "phi"])
result = process.generate_diagrams(loops=1)
diagram = result.diagrams[0]
region = diagram.filter(edge=lambda edge: not edge.is_external)
left = diagram.subgraph(nodes=[0])
right = diagram.subgraph(nodes=[1])
common = left & right
independent = region.excise()
independent.validate()Member details
original
Property · read-only#original: FeynmanDiagramReturn a full view of the immutable original diagram, sharing the same underlying diagram.
Examples
Using the setup in the Subgraph class example:
assert region.original.id == diagram.idn_half_edges
Property · read-only#n_half_edges: intReturn the number of selected half-edges, excluding isolated vertices.
Examples
Using the setup in the Subgraph class example:
assert region.n_half_edges == len(region.half_edge_indices())excise
Method#excise() -> FeynmanDiagramMaterialize an independent diagram with dangling legs at the region boundary.
Complete interaction crowns are retained. Only selected internal pairs stay paired; remaining incident halves become boundary legs. Proper regions get independent momentum coordinates and unit global weights and projector. Excising the complete original preserves its factors, cuts and routing.
Examples
Using the setup in the Subgraph class example:
region = diagram.subgraph(nodes=[0])
independent = region.excise()
independent.validate()half_edge_indices
Method#half_edge_indices() -> list[int] Return native diagram half-edge IDs of this region.
Examples
Using the setup in the Subgraph class example:
selected_half_edges = region.half_edge_indices()
selected = region.original.subgraph(half_edges=selected_half_edges)isolated_node_indices
Method#isolated_node_indices() -> list[int] Return explicitly selected vertices with no incident half-edges.
Examples
Using the setup in the Subgraph class example:
isolated_vertices = region.isolated_node_indices()__len__
Method#__len__() -> intCount selected half-edges and explicitly selected isolated vertices.
Examples
Using the setup in the Subgraph class example:
size = len(region)__bool__
Method#__bool__() -> boolTest whether any half-edge or isolated vertex is selected.
Examples
Using the setup in the Subgraph class example:
nonempty = bool(region)__and__
Method#__and__(other: FeynmanDiagram) -> SubgraphIntersect two regions belonging to the same original diagram.
Examples
Using the setup in the Subgraph class example:
common = left & rightParameters
| Name | Type | Default | Description |
|---|---|---|---|
other | FeynmanDiagram | — | Region or full diagram sharing this region's immutable original. |
__or__
Method#__or__(other: FeynmanDiagram) -> SubgraphUnite two regions belonging to the same original diagram.
Examples
Using the setup in the Subgraph class example:
combined = left | rightParameters
| Name | Type | Default | Description |
|---|---|---|---|
other | FeynmanDiagram | — | Region or full diagram sharing this region's immutable original. |
__xor__
Method#__xor__(other: FeynmanDiagram) -> SubgraphSelect elements present in exactly one of two regions.
Examples
Using the setup in the Subgraph class example:
exclusive = left ^ rightParameters
| Name | Type | Default | Description |
|---|---|---|---|
other | FeynmanDiagram | — | Region or full diagram sharing this region's immutable original. |
__sub__
Method#__sub__(other: FeynmanDiagram) -> SubgraphRemove the other region's elements from this selection.
Examples
Using the setup in the Subgraph class example:
remaining = left - rightParameters
| Name | Type | Default | Description |
|---|---|---|---|
other | FeynmanDiagram | — | Region or full diagram sharing this region's immutable original. |
__invert__
Method#__invert__() -> SubgraphComplement the region relative to its immutable original diagram.
Examples
Using the setup in the Subgraph class example:
outside = ~regionView generated signature source: docs/api/python/feynkit-community.pyi:10619