yarrow.bipartite_multigraph
A representation of the “internal wiring” of string diagrams. Bipartite multigraphs have edge labels corresponding to the “ports” of operations, and node labels either generating objects or generating operations of a signature Σ.
As with other classes, these graphs are implemented with an abstract base class
AbstractBipartiteMultigraph
,
whose concrete instantiations choose a backend.
For example, BipartiteMultigraph
are backed by numpy arrays.
- class yarrow.bipartite_multigraph.AbstractBipartiteMultigraph(wi, wo, xi, xo, wn, pi, po, xn)
The type of bipartite multigraphs, parametrised by cls._Fun, the underlying representation of finite functions
- __init__(wi, wo, xi, xo, wn, pi, po, xn)
Create a BipartiteMultigraph from its component finite functions. For more details see [WZ23], Section 3.2.
- property W
Test
- Returns:
G(W)
- property Ei
Test
- Returns:
The number of input edges in the graph
- property Eo
Returns: The number of output edges in the graph
- property X
Returns: int: Corresponds to G(X), the number of generating operations in the diagram
- classmethod empty(wn, xn)
- Parameters:
wn – Finite function typed 0 → Σ₀
xn – Finite function typed 0 → Σ₁
- Returns:
The empty bipartite multigraph with no edges and no nodes.
- Return type:
- classmethod discrete(wn: AbstractFiniteFunction, xn: AbstractFiniteFunction)
Create the discrete graph of n wires for a given monoidal signature Σ whose maps are all initial except for wn.
- Parameters:
wn – An array of wire labels as a finite function typed n → Σ₀
xn – The type of operations as an empty finite function typed 0 → Σ₁
- coproduct(g)
Compute the coproduct of bipartite multigraphs
- Parameters:
g – an arbitrary AbstractBipartiteMultigraph over the same signature
- Returns:
The coproduct
self + g
.
- coequalize_wires(q: AbstractFiniteFunction)
Apply a morphism α of bipartite multigraphs whose only non-identity component α_W = q for some coequalizer q.
- Parameters:
q – An AbstractFiniteFunction which is a coequalizer.
- Returns:
The bipartite multigraph equal to the target of α.
- Return type:
- yarrow.bipartite_multigraph.universal(q: AbstractFiniteFunction, f: AbstractFiniteFunction)
Given a coequalizer q : B → Q of morphisms a, b : A → B and some f : B → B’ such that f(a) = f(b), Compute the universal map u : Q → B’ such that q ; u = f.
- class yarrow.bipartite_multigraph.BipartiteMultigraph(wi, wo, xi, xo, wn, pi, po, xn)
AbstractBipartiteMultigraphs backed by numpy arrays