FeynKit · latest
On this page

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: FeynmanDiagram

Return 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.id

n_half_edges

Property · read-only#
n_half_edges: int

Return 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() -> FeynmanDiagram

Materialize 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__() -> int

Count selected half-edges and explicitly selected isolated vertices.

Examples

Using the setup in the Subgraph class example:

size = len(region)

__bool__

Method#
__bool__() -> bool

Test 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) -> Subgraph

Intersect two regions belonging to the same original diagram.

Examples

Using the setup in the Subgraph class example:

common = left & right

Parameters

NameTypeDefaultDescription
otherFeynmanDiagram—

Region or full diagram sharing this region's immutable original.

__or__

Method#
__or__(other: FeynmanDiagram) -> Subgraph

Unite two regions belonging to the same original diagram.

Examples

Using the setup in the Subgraph class example:

combined = left | right

Parameters

NameTypeDefaultDescription
otherFeynmanDiagram—

Region or full diagram sharing this region's immutable original.

__xor__

Method#
__xor__(other: FeynmanDiagram) -> Subgraph

Select elements present in exactly one of two regions.

Examples

Using the setup in the Subgraph class example:

exclusive = left ^ right

Parameters

NameTypeDefaultDescription
otherFeynmanDiagram—

Region or full diagram sharing this region's immutable original.

__sub__

Method#
__sub__(other: FeynmanDiagram) -> Subgraph

Remove the other region's elements from this selection.

Examples

Using the setup in the Subgraph class example:

remaining = left - right

Parameters

NameTypeDefaultDescription
otherFeynmanDiagram—

Region or full diagram sharing this region's immutable original.

__invert__

Method#
__invert__() -> Subgraph

Complement the region relative to its immutable original diagram.

Examples

Using the setup in the Subgraph class example:

outside = ~region