graph — Phase adjacency graph#
Phase adjacency graph for extended Kahler cone construction.
The CYGraph stores CalabiYauLite phases as nodes and
ExtremalContraction objects as edges, backed by a networkx.MultiGraph.
Topology (which phases a contraction connects, and with what curve orientation) is owned by the graph, not by the contraction object. A MultiGraph is used because a pair of phases (or a single phase via self-loops) can have multiple contractions (e.g. multiple terminal walls of different types).
- class CYGraph#
Bases:
objectAdjacency graph with CalabiYauLite phases as nodes and ExtremalContraction objects as edges.
Uses an undirected
networkx.MultiGraphinternally so that parallel edges (multiple contractions between the same pair of phases, or multiple self-loop terminal walls) are preserved. Contractions connect two phases symmetrically (you can flop in either direction). Each edge stores which phase wasphase_aandphase_b, along with signed curve orientations.Examples
>>> g = CYGraph() >>> g.add_phase(phase_a) >>> g.add_phase(phase_b) >>> g.add_contraction(contraction_ab, "A", "B") >>> g.neighbors("A") [CalabiYauLite(label='B')]
- add_contraction(contraction, phase_a_label, phase_b_label, curve_sign_a=1, curve_sign_b=-1)#
Add a contraction edge between two phases.
The graph owns the topology: which two phases a contraction connects, and the signed curve orientation in each phase.
- Parameters:
contraction (ExtremalContraction) – The contraction object (no phase references needed).
phase_a_label (str) – Label of the first phase.
phase_b_label (str) – Label of the second phase.
curve_sign_a (int, optional) – Curve sign in phase_a (default +1).
curve_sign_b (int, optional) – Curve sign in phase_b (default -1).
- add_phase(phase)#
Add a phase node.
- Parameters:
phase (CalabiYauLite) – Phase with a label set.
- property contractions#
All contraction objects.
- Returns:
list of ExtremalContraction
- contractions_from(label)#
Contractions incident to a phase, with curve orientation signs.
For each edge incident to label, returns the contraction and the signed curve orientation appropriate for that phase.
- Parameters:
label (str) – Phase label.
- Returns:
list of (ExtremalContraction, int) – Pairs of (contraction, sign) where sign is
curve_sign_aif label wasphase_awhen the edge was added, orcurve_sign_botherwise.
- edges(data=True)#
All edges as (u, v, data) triples.
- Parameters:
data (bool, optional) – Include edge data dicts (default True).
- Returns:
list of tuple
- get_phase(label)#
Get a phase by label.
- Parameters:
label (str) – Phase label.
- Returns:
CalabiYauLite
- neighbors(label)#
Phases adjacent to the given phase.
- Parameters:
label (str) – Phase label.
- Returns:
list of CalabiYauLite – Adjacent phase objects.
- property num_contractions#
Number of contractions in the graph.
- property num_phases#
Number of phases in the graph.
- property phases#
All phase objects.
- Returns:
list of CalabiYauLite
- phases_adjacent_to(contraction)#
Find the two phases connected by a contraction.
- Parameters:
contraction (ExtremalContraction) – The contraction to look up (identity comparison).
- Returns:
tuple of (CalabiYauLite, CalabiYauLite) or None – The two phase objects, or None if the contraction is not in the graph.