remove_bivalent_vertices#
- remove_bivalent_vertices(k, match_attributes=False)#
Remove all degree-2 vertices by splicing their incident edges.
- Parameters:
k (PlanarDiagram) – Diagram to modify (in place).
match_attributes (bool) – If True, only remove a bivalent vertex when the four adjacent/incident endpoints have matching attributes in pairs (i.e., compatible to splice). If False, remove regardless of attrs.
- Returns:
The number of removed bivalent vertices.
- Return type:
int
Notes
Loops are never spliced here.
For oriented diagrams, vertices whose two outward endpoints have the same direction are skipped (incoherent pairing).