hyp

hyp.core.Binary_Type: TypeAlias = hyp.core.Product | hyp.core.Coproduct | hyp.core.FunnyTensor | hyp.core.StrongTensor | hyp.core.StraightTensor | hyp.core.FiniteProduct | hyp.core.FiniteCoproduct | hyp.core.FiniteFunnyTensor | hyp.core.FiniteStrongTensor

This section defines some specific hypergraphs that are useful for testing and examples and generating finite hypergraphs.

class hyp.core.CartesianHomSet(H0: Representable, H1: Representable)[source]

Bases: Construct

Represent the homset in Hyp For H0,H1, return Hyp[H0,H1], the set of morphisms of hypergraphs from H0 to H1 Object calculation is defered to the method generate, which calculates the homset as a subset of the cartesian product of the homsets of the underlying sets.

display()[source]
generate()[source]

Calculate the homset using the Rust index decoder.

generate_fast()[source]

Calculate the homset using the Rust implementation.

generate_formel()[source]

Calculate the homset as a subset of the cartesian product of the homsets of the underlying sets.

property name: str

Return the name of the homset.

property obj: NamedSet

Realizes Hom[H0,H1] as a Homset.

class hyp.core.Coequalizer(f0: HypergraphMorphism, f1: HypergraphMorphism)[source]

Bases: Construct

proj() → HypergraphEpimorphism[source]

Return the projection π : H1 → H1 /~_f0,f1 H0

test_coequalize(g: HypergraphMorphism) → bool[source]

Test if a morphism g : H1 → C coequalizes f0 and f1, i.e. if g ∘ f0 = g ∘ f1.

universal_solution(g: HypergraphMorphism) → HypergraphMorphism[source]

For a map g : H1 → C such that g ∘ f0 = g ∘ f1, return the unique morphism

⟨g⟩ : Coeq(f0,f1) → C

such that

⟨g⟩ ∘ π = g.

class hyp.core.Construct[source]

Bases: Representable

Construct represent the result of a universal construction It is a representable, hence has a name .obj returns an underlying object which is always a Hypergraph. It is eligible as a domain or codomain of functions, and can be used in further constructions, without losing the structure supported by the underlying hypergraph.

Invoque the links of the underlying hypergraph.

property Nodes

Invoque the nodes of the underlying hypergraph.

property Ties

Invoque the ties of the underlying hypergraph.

Invoque the link_map of the underlying hypergraph.

property name: str

Invoque the name of the underlying hypergraph.

property node_map

Invoque the node_map of the underlying hypergraph.

property obj: Hypergraph

Invoque the underlying hypergraph.

class hyp.core.Coproduct(H0: Representable, H1: Representable)[source]

Bases: Construct

Return the coproduct of two hypergraphs H0 and H1:

  • S_{H0 + H1} = S_{H0} + S_{H1}

  • T_{H0 + H1} = T_{H0} + T_{H1}

  • L_{H0 + H1} = L_{H0} + L_{H1}

  • σ_{H0 + H1} = σ_{H0} + σ_{H1}

  • λ_{H0 + H1} = λ_{H0} + λ_{H1}

braiding() → HypergraphIsomorphism[source]

Return the braiding isomorphism

β : H0 + H1 ≃ H1 + H0

inj_0() → HypergraphMonomorphism[source]

Return the injection

in0 : H0 ↣ H0 + H1

inj_1() → HypergraphMonomorphism[source]

Return the injection

in1 : H1 ↣ H0 + H1

universal_solution(f1: HypergraphMorphism, f2: HypergraphMorphism) → HypergraphMorphism[source]

For a cocone f1 : H0 → C, f2 : H1 → C, return the unique morphism

⟨f1,f2⟩ : H0 + H1 → C

such that

  • ⟨f1,f2⟩ ∘ inj_0 = f1

  • ⟨f1,f2⟩ ∘ inj_1 = f2.

class hyp.core.Equalizer(f0: HypergraphMorphism, f1: HypergraphMorphism)[source]

Bases: Construct

Return the equalizer of two morphisms f0 : H0 → H1 and f1 : H0 → H1

inclusion() → HypergraphMonomorphism[source]

Return the inclusion morphism

i : Eq(f0,f1) ↣ H0

test_equalize(g: HypergraphMorphism) → bool[source]

Test if a morphism g : C → H0 equalizes f0 and f1, i.e. if f0 ∘ g = f1 ∘ g.

universal_solution(g: HypergraphMorphism) → HypergraphMorphism[source]

For a map g : C → H0 such that f0 ∘ g = f1 ∘ g, return the unique morphism

⟨g⟩ : C → Eq(f0,f1)

such that

i ∘ ⟨g⟩ = g

class hyp.core.FiniteCoproduct(hypergraph_list: list[Representable])[source]

Bases: Construct

Return the finite coproduct H0 + H1 + … + Hn of a list of hypergraphs

  • S_{H0 + H1 + … + Hn} = S_{H0} + S_{H1} + … + S_{Hn}

  • T_{H0 + H1 + … + Hn} = T_{H0} + T_{H1} + … + T_{Hn}

  • L_{H0 + H1 + … + Hn} = L_{H0} + L_{H1} + … + L_{Hn}

  • σ_{H0 + H1 + … + Hn} = σ_{H0} + σ_{H1} + … + σ_{Hn}

  • λ_{H0 + H1 + … + Hn} = λ_{H0} + λ_{H1} + … + λ_{Hn}

inj(index: int) → HypergraphMorphism[source]

Return the injection

in_i : Hi ↣ H0 + H1 + … + Hn

universal_solution(morphism_list: list[HypergraphMorphism]) → HypergraphMorphism[source]

For a cocone f_i : Hi → C, return the unique morphism

⟨f_i⟩ : H0 + H1 + … + Hn → C

such that for all i

⟨f_i⟩ ∘ inj_i = f_i

class hyp.core.FiniteFunnyTensor(hypergraph_list: list[Representable])[source]

Bases: Construct

class hyp.core.FiniteProduct(hypergraph_list: list[Hypergraph])[source]

Bases: Construct

proj(index: int) → HypergraphMorphism[source]

Return the projection morphism

π_i : H0 × H1 × … × Hn → Hi

universal_solution(morphism_list: list[HypergraphMorphism]) → HypergraphMorphism[source]

For a cone f_i : C → Hi, return the unique morphism

(f_i) : C → H0 × H1 × … × Hn

such that for all i

π_i ∘ (f_i) = f_i

It is computed from the universal solutions at the underlying sets of nodes, links and ties.

class hyp.core.FiniteStrongTensor(hypergraph_list: list[Representable])[source]

Bases: Construct

Return the finite strong tensor product H0 ⊠ H1 ⊠ … ⊠ Hn of a list of hypergraphs H0 ⊠ H1 ⊠ … ⊠ Hn:

  • S_(⊠_i H_i) = Π_i S_H_i

  • T_(⊠_i H_i) = ∑_(J⊆I, J≠∅) (Π_{j∈J } T_{H_j} × Π_{j ∉ J} × S_{H_i})

  • L_(⊠_i H_i) = ∑_(J⊆I, J≠∅) (Π_{j∈J } L_{H_j} × Π_{j ∉ J} × S_{H_i})

class hyp.core.FunnyHomgraph(H0: Representable, H1: Representable)[source]

Bases: Construct

Return the funny hom-graph Hom[H0, H1]_□, where H0 and H1 are representable hypergraphs.

Nodes = Hom(H0, H1) Links = Prenatural transformations H0 -> H1 Ties = Natural ties between morphisms and prenatural transformations, i.e.

t : f -> alpha if for each node s in H0, the link alpha(s) in H1 has for source the image of s by the node map of H1, i.e. alpha(s) : H1.node_map(t(s)) ∈ alpha(s) in H1.

class hyp.core.FunnyTensor(H0: Representable, H1: Representable)[source]

Bases: Construct

Return the funny tensor product of two hypergraphs H0 and H1

  • S_{H0 □ H1} = S_{H0} × S_{H1}

  • T_{H0 □ H1} = (S_{H0} × T_{H1}) + (T_{H0} × S_{H1})

  • L_{H0 □ H1} = (S_{H0} × L_{H1}) + (L_{H0} × S_{H1})

braiding() → HypergraphIsomorphism[source]

Return the braiding isomorphism β : H0 □ H1 → H1 □ H0

canonical_elements_naming() → Hypergraph[source]

Rename the links and ties of H0 □ H1 with their canonical form, i.e.

  • x ⊗ r : (x,y) ∈ x ⊗ k if x ∈ S_H0 and r : y ∈ k in H1

  • t ⊗ y : (x,y) ∈ t ⊗ k if t : x ∈ k in H0 and y ∈ S_H1

canonical_elements_naming_isomorphism() → HypergraphIsomorphism[source]

Rename the links and ties of H0 □ H1 with their canonical form

class hyp.core.Hypergraph(Nodes: Representable, Ties: Representable, Links: Representable, node_map: NamedFunction, link_map: NamedFunction, name: str)[source]

Bases: Representable

A (finite) hypergraph represented as a span of Named Sets and NamedFunctions, with a name and a custom display method.

A hypergraph consists of:

  • a set of nodes S;

  • a set of links L;

  • a set of ties T;

  • a node map σ : T → S;

  • a link map λ : T → L.

Parameters:
  • nodes – The named set of nodes.

  • links – The named set of links.

  • ties – The named set of incidence witnesses.

  • node_map – The function sending each tie to its node.

  • link_map – The function sending each tie to its link.

Notes

A node may occur several times in the same link, because incidences are represented by explicit ties.

Invoque the links of the hypergraph.

property Nodes

Invoque the nodes of the hypergraph.

property Ties

Invoque the ties of the hypergraph.

bipartite() → ndarray[source]

Return the bipartite adjacency matrix of the hypergraph, with rows indexed by nodes and columns indexed by links, and entries given by the valence of the node in the link.

For two nodes s1 and s2, return the set

Occ_L(s1) ∩ Occ_L(s2) = {l in L | s1 is in the support of l and s2 is in the support of l}

dictionnaire() → dict[source]

Return a dictionary coding the relation T subs S x L, of the form {t : (s, l)}.

display() → str[source]

Return a string representation of the hypergraph.

Example of display:
Hypergraph HX
Nodes (2):

x0 x1

Links (1):

lx

Ties (2):

t0 : x0 ∈ lx t1 : x1 ∈ lx

Return the set of empty links, that is, the set of links l such that |l| = ∅.

hypergraph_to_mutable() → MutableHypergraph[source]

Return a MutableHypergraph with the same underlying sets and maps, but with mutable sets.

incidences() → Pullback[source]

Return the pullback of the node_map and the link_map, which is the set of pairs (t0, t1) such that node_map(t0) = node_map(t1). This set can be seen as the set of incidences between ties

intersection_nodes(l1, l2) → NamedSet[source]

For two links l1 and l2, return the set

||l1|| ∩ ||l2|| = {s in S | s is in the support of l1 and s is in the support of l2}

intersections() → Pullback[source]

Return the pullback of the node_map and the link_map, which is the set of pairs (t0, t1) such that lambda(t0) = lambda(t1). This set can be seen as the set of intersections between ties

Invoque the link_map of the hypergraph.

nakednodes() → set[source]

Return the set of naked nodes, that is, the set of nodes s such that Occ(s) = ∅.

property name: str

Invoque the name of the hypergraph.

property node_map

Invoque the node_map of the hypergraph.

nodes_support: dict
property obj: Hypergraph

Invoque the underlying hypergraph, which is itself.

For a node s, return the set

Occ_L(s) = {l in L | s is in the support of l}

occurrences_ties(s) → NamedSet[source]

For a node s, return the set

Occ(s) = {t in T | node_map(t) = s}

rename(new_name: str) → Hypergraph[source]

Return a new hypergraph with the same underlying sets and maps, but a new name.

This overrides Representable.rename to avoid the recursion self.obj.rename(...) because, for a Hypergraph, self.obj is self.

rename_global(new_name: str) → Hypergraph[source]

Return a new hypergraph with the same underlying sets and maps, but a new name.

sizes() → tuple[int, int, int][source]

Return the sizes of the sets of nodes, links and ties as a tuple.

support_nodes(l) → NamedSet[source]

For a link l, return the support

||l|| = {s in S | s_map(t) = s for some t in |l|}

support_ties(l) → NamedSet[source]

For a link l, return the support

|l| = {t in T | link_map(t) = l}

test_simplicité() → bool[source]

Return True if the hypergraph is simple, that is, if for every node s and every link l, there is at most one tie t such that node_map(t) = s and link_map(t) = l.

valence_len(s, l) → int[source]

For a node s and a link l, return the valence of s in l, that is the number of ties t such that node_map(t) = s and link_map(t) = l

valence_set(s, l) → NamedSet[source]

For a node s and a link l, return the set

Val(s, l) = {t in T | node_map(t) = s and link_map(t) = l}

valences: dict
class hyp.core.HypergraphEpimorphism(dom: Representable, cod: Representable, map: tuple, name=None)[source]

Bases: HypergraphMorphism

An epimorphism in the category of hypergraphs is a morphism of hypergraphs whose component functions are surjective.

classmethod from_morphism(f: HypergraphMorphism) → HypergraphEpimorphism[source]
sections() → NamedSet[source]

For an epimorphism f : G ↠ H, Return the set Γ(f) of sections of the , that is the set of morphisms

g : H → G

such that

f ∘ g = id_H

symbolic_repr() → str[source]

Return a symbolic representation of the function, e.g.,

f : X ↠ Y

class hyp.core.HypergraphIsomorphism(dom: Representable, cod: Representable, map: tuple, name=None)[source]

Bases: HypergraphMorphism

Un isomorphisme d’hypergraphes est un morphisme d’hypergraphes dont les fonctions composantes sont bijectives.

classmethod from_morphism(f: HypergraphMorphism) → HypergraphIsomorphism[source]
symbolic_repr() → str[source]

Return a symbolic representation of the function, e.g.,

f : X ≃ Y

class hyp.core.HypergraphMonomorphism(dom: Representable, cod: Representable, map: tuple, name=None)[source]

Bases: HypergraphMorphism

A monomorphism in the category of hypergraphs is a morphism of hypergraphs whose component functions are injective.

classmethod from_morphism(f: HypergraphMorphism) → HypergraphMonomorphism[source]
symbolic_repr() → str[source]

Return a symbolic representation of the function, e.g.,

f : X ↣ Y

class hyp.core.HypergraphMorphism(dom: Representable, cod: Representable, map: tuple[NamedFunction, NamedFunction, NamedFunction], name=None)[source]

Bases: object

Class representing morphisms of hypergraphs as triples of functions with a name and a custom display method.

Parameters:
  • dom – the domain hypergraph

  • cod – the codomain hypergraph

  • node_map – a named function mapping nodes of the domain to nodes of the codomain

  • tie_map – a named function mapping ties of the domain to ties of the codomain

  • link_map – a named function mapping links of the domain to links of the codomain

  • name – the name of the morphism

Enter the triple of functions as a tuple (node_map, tie_map, link_map) in the parameter ‘map’ of the constructor.

display() → str[source]
eval_occurences(s) → NamedFunction[source]

For a node s in dom, return the occurrences map of s, that is the function from the occurrences of s in dom to the occurrences of node_map(s) in cod, given by the restriction of tie_map to the occurrences of s.

eval_support(l) → NamedFunction[source]

For a link l in dom, return the support map of l, that is the function from the support of l in dom to the support of link_map(l) in cod, given by the restriction of node_map to the support of l.

classmethod from_rustic(dom: Hypergraph, cod: Hypergraph, morphism_rustic: MorphismPy, name=None) → HypergraphMorphism[source]

Create a HypergraphMorphism from a rustic.MorphismPy object.

image() → Hypergraph[source]

Pointwise calculation of the image of the morphism, that is the hypergraph whose sets of nodes, links and ties are the images of the corresponding functions,

symbolic_repr() → str[source]

Return a symbolic representation of the function, e.g.,

f : X → Y

test_epi() → bool[source]

An epimorphisme in the category of hypergraphs is a morphism of hypergraphs whose component functions are surjective.

test_iso() → bool[source]

An isomorphisme in the category of hypergraphs is a morphism of hypergraphs whose component functions are bijective.

test_mono() → bool[source]

A monomorphisme in the category of hypergraphs is a morphism of hypergraphs whose component functions are injective.

test_morphisme_concret() → bool[source]

Test whether the triple of functions (node_map, tie_map, link_map) satisfies the morphism condition, that is, whether for every tie t in dom.Ties

  • node_map(dom.node_map(t)) = cod.node_map(tie_map(t))

  • link_map(dom.link_map(t)) = cod.link_map(tie_map(t))

test_morphisme_formel() → bool[source]

Test whether the data of the morphism satisfies the morphism condition, that is, as a formal commutativity condition on the functions

test_rustic() → bool[source]

Test whether the morphism is a hypergraph morphism using the rustic implementation.

class hyp.core.Initial[source]

Bases: Construct

Initial object in the category of hypergraphs, which is the hypergraph with no nodes, no links and no ties.

S0 = T0 = L0 = ∅

classmethod test_initial(H) → bool[source]

Test whether H is initial, that is, whether it has no nodes, no links and no ties.

unique_map(H: Representable) → HypergraphMorphism[source]

Return the unique morphism from the initial object to H

!_H : ∅ -> H

hyp.core.Iso(H_0: Representable, H_1: Representable) → NamedSet[source]

Return the set of isomorphisms of hypergraphs from H_0 to H_1, as a subset of the homset Hom[H_0,H_1].

class hyp.core.MutableHypergraph(Nodes: set, Links: set, Data: dict, name=None)[source]

Bases: object

Class of mutable hypergraphs, whose objects of Nodes and Links are mutable native sets and ties are coded by a dictionary of the form {t : (s, l)}.

Elements can be added or removed from the sets of nodes and links, and from the dictionary of ties.

Parameters:
  • Nodes – A set of nodes.

  • Links – A set of links.

  • Data – A dictionary coding the span T ↣ S x L, of the form {t : (s, l)}.

  • name – An optional name for the hypergraph.

add(S: set = None, L: set = None, T: dict = None) → MutableHypergraph[source]

Add nodes, links and ties to the hypergraph, where S is a set of nodes, L is a set of links and T is a dictionary coding the ties to add.

copy() → MutableHypergraph[source]

Return a copy of the hypergraph, with the same underlying sets and maps,

Add a new link to the hypergraph, with a new name based on the current number of links.

increment_node() → MutableHypergraph[source]

Add a new node to the hypergraph, with a new name based on the current number of nodes.

mutable_to_hypergraph() → Hypergraph[source]

Return a Hypergraph with the same underlying sets and maps, but with named sets and named functions.

Add n new ties between a node s and a link l, with new names based on the current number of ties.

remove(S: set = None, L: set = None, T: dict = None) → MutableHypergraph[source]

Remove nodes, links and ties from the hypergraph, where S is a set of nodes, L is a set of links and T is a dictionary coding the ties to remove.

rename_elements(S_map: dict = None, L_map: dict = None, T_map: dict = None) → MutableHypergraph[source]

Rename nodes, links and ties of the hypergraph, with dictionaries for renaming separately node, links and ties.

rename_sorted() → MutableHypergraph[source]

Rename nodes, links and ties of the hypergraph with sorted names.

repr_sorted() → MutableHypergraph[source]
sizes() → tuple[int, int, int][source]
hyp.core.Omega_hyp() → Hypergraph[source]

Return the subobject classifier Omega in the category of hypergraphs.

  • S_Ω = {True,False} (the subobject classifier of Set)

  • L_Ω = {True,False} (the subobject classifier of Set)

  • T_Ω = {t_∅, t_sigma, t_lambda, t_sigma_lambda, t_top}

the 5 possible configurations for a tie t : x ∈ l :

  • t_∅ : neither t, x nor l are in the subobject

  • t_sigma : only x is in the subobject

  • t_lambda : only l is in the subobject

  • t_sigma_lambda : both x and l are in the subobject, but not t

  • t_top : t, x and l are all in the subobject

class hyp.core.PrenaturalTransformation(H0: Representable, H1: Representable, mapping: NamedFunction, name=None)[source]

Bases: object

Return a prenatural transformation alpha : H0 -> H1, where H0 and H1 are representable hypergraphs, and mapping is a function mapping : H0.Nodes -> H1.Links, such that for each node s in H0, the link alpha(s) in H1 has for source the image of s by the node map of H1, i.e. alpha(s) : H1.node_map(mapping(s)) ∈ alpha(s) in H1.

class hyp.core.Product(H0: Representable, H1: Representable)[source]

Bases: Construct

Return H0 × H1, the product of H0 and H1 in the category of hypergraphs,

It is defined as:

  • S_{H0 × H1} = S_{H0} × S_{H1}

  • T_{H0 × H1} = T_{H0} × T_{H1}

  • L_{H0 × H1} = L_{H0} × L_{H1}

  • σ_{H0 × H1} = σ_{H0} × σ_{H1}

  • λ_{H0 × H1} = λ_{H0} × λ_{H1}

braiding() → HypergraphIsomorphism[source]

Return the braiding isomorphism

β : H0 × H1 ≃ H1 × H0

proj_0() → HypergraphMorphism[source]

Return the projection

π0 : H0 × H1 ↠ H0

proj_1() → HypergraphMorphism[source]

Return the projection

π1 : H0 × H1 ↠ H1

universal_solution(f1: HypergraphMorphism, f2: HypergraphMorphism) → HypergraphMorphism[source]

For a cone f1 : C → H0, f2 : C → H1, return the unique morphism

(f1,f2) : C → H0 × H1

such that

  • π_0 ∘ (f1,f2) = f1

  • π_1 ∘ (f1,f2) = f2

It is computed from the universal solutions for the underlying sets of nodes, links and ties.

class hyp.core.Pullback(f0: HypergraphMorphism, f1: HypergraphMorphism)[source]

Bases: Construct

Return the pullback of two morphisms f0 : H0 → H2 and f1 : H1 → H2 H0 ×_{H2} H1, which is computed pointwise as

  • S_{H0 ×_{H2} H1} = S_{H0} ×_{S_{H2}} S_{H1}

  • T_{H0 ×_{H2} H1} = T_{H0} ×_{T_{H2}} T_{H1}

  • L_{H0 ×_{H2} H1} = L_{H0} ×_{L_{H2}} L_{H1}

proj_0() → HypergraphMorphism[source]

Return the projection

π0 : H0 ×_{H2} H1 → H0

proj_1() → HypergraphMorphism[source]

Return the projection

π1 : H0 ×_{H2} H1 → H1

universal_solution(g0: HypergraphMorphism, g1: HypergraphMorphism) → HypergraphMorphism[source]

For a cone g0 : C → H0, g1 : C → H1, return the unique morphism

⟨g0,g1⟩ : C → H0 ×_{H2} H1

such that

  • π0 ∘ ⟨g0,g1⟩ = g0

  • π1 ∘ ⟨g0,g1⟩ = g1

class hyp.core.Pushout(f0: HypergraphMorphism, f1: HypergraphMorphism)[source]

Bases: Construct

inj_0() → HypergraphMorphism[source]

Return the injection

in0 : H0 → H0 +^f0,f1_H2 H1

inj_1() → HypergraphMorphism[source]

Return the injection

in1 : H1 → H0 +^f0,f1_H2 H1

universal_solution(g0: HypergraphMorphism, g1: HypergraphMorphism) → HypergraphMorphism[source]

For a cocone g0 : H0 → C, g1 : H1 → C such that g0 ∘ f0 = g1 ∘ f1, return the unique morphism

⟨g0,g1⟩ : H0 +^f0,f1_H2 H1 → C

such that

⟨g0,g1⟩ ∘ inj_0 = g0 and ⟨g0,g1⟩ ∘ inj_1 = g1.

class hyp.core.Representable[source]

Bases: ABC

A representable is an object with an underlying hypergraph. This superclass promises:

  • that the underlying hypergraph is accessible via the obj property

  • that the representable has a name, representation based on the underlying hypergraph

Representable are immutable, hence hashable, and equality is based on the underlying hypergraph, independently of the name. It also has identity morphism and dual construction

Invoque the links of the underlying hypergraph.

property Nodes: NamedSet

Invoque the nodes of the underlying hypergraph.

property Ties: NamedSet

Invoque the ties of the underlying hypergraph.

property bidual_isomorphism: HypergraphIsomorphism

Return the isomorphism between the hypergraph and its bidual, which is the identity on the underlying sets and maps.

display() → str[source]

Display based on the underlying set.

property dual: Hypergraph

Return the dual of the hypergraph, obtained by swapping nodes and links

H* satisfies:

  • S(H*) = L(H)

  • L(H*) = S(H)

  • T(H*) = T(H)

property identity: HypergraphIsomorphism

Return the identity function on the hypergraph. This is the triple made of the identities maps on nodes, ties and links, which is a morphism of hypergraphes, and in fact an isomorphism.

Invoque the link_map of the underlying hypergraph.

property name: str

Invoque the name of the underlying hypergraph.

property node_map: NamedFunction

Invoque the node_map of the underlying hypergraph.

abstract property obj: Hypergraph

Underlying representing hypergraph.

rename(new_name: str) → Representable[source]

Rename based on the underlying set.

hyp.core.Restriction_nodes(H: Representable, X: NamedSet, f: NamedFunction) → Hypergraph[source]
class hyp.core.StraightTensor(H0: Representable, H1: Representable)[source]

Bases: Construct

class hyp.core.StrongTensor(H0: Representable, H1: Representable)[source]

Bases: Construct

Return the strong tensor product H0 ⊠ H1 of two hypergraphs H0 and H1

  • S_{H0 ⊠ H1} = S_{H0} × S_{H1}

  • T_{H0 ⊠ H1} = (S_{H0} × T_{H1}) + (T_{H0} × S_{H1}) + (T_{H0} × T_{H1})

  • L_{H0 ⊠ H1} = (S_{H0} × L_{H1}) + (L_{H0} × S_{H1}) + (L_{H0} × L_{H1})

class hyp.core.Terminal[source]

Bases: Construct

Terminal object in the category of hypergraphs, which is the hypergraph with a single node, a single link and a single tie between them.

S1 = T1 = L1 = {∗}

classmethod test_terminal(H) → bool[source]

Test whether H is terminal, that is, whether it has a single node, a single link and a single tie between them.

unique_map(H: Representable) → HypergraphMorphism[source]

Return the unique morphism from H to the terminal object

!_H : H -> 1

hyp.core.Top_hyp() → HypergraphMorphism[source]

Return the morphism ⊤ : 1 → Ω, where 1 is the terminal hypergraph and Ω is the subobject classifier.

class hyp.core.Unit_Straight[source]

Bases: Construct

Unit of the straight tensor product, which is the hypergraph with a single link and no nodes

  • S1 = ∅,

  • T1 = ∅, L1 = 1

class hyp.core.Unit_funny[source]

Bases: Construct

Unit of the funny and strong tensor products, which is the hypergraph with a single node and no links

  • S1 = 1, T1 = ∅,

  • L1 = ∅

hyp.core.associator_cartesian(H0: Representable, H1: Representable, H2: Representable) → HypergraphIsomorphism[source]

Return the associator isomorphism

α : (H0 × H1) × H2 ≃ H0 × (H1 × H2)

hyp.core.associator_coproduct(H0: Representable, H1: Representable, H2: Representable) → HypergraphIsomorphism[source]

Return the associator isomorphism

α : (H0 + H1) + H2 ≃ H0 + (H1 + H2)

hyp.core.bag_of_naked_nodes(S: NamedSet | set)[source]
hyp.core.composition(f1: HypergraphMorphism, f2: HypergraphMorphism) → HypergraphMorphism[source]

Return the composition of two morphisms of hypergraphs f1 and f2, that is the morphism of hypergraphs f2 ∘ f1 : dom(f1) → cod(f2) given by the composition of the underlying functions. Beware the order.

hyp.core.coproduct_maps(f1: HypergraphMorphism, f2: HypergraphMorphism) → HypergraphMorphism[source]

Return the coproduct morphism

f1 + f2 : H0 + H1 → G0 + G1

hyp.core.decode_hyp(S: NamedSet, L: NamedSet, T: NamedSet, index: int)[source]
hyp.core.decode_productmaps(S0, L0, S1, L_1: NamedSet)[source]
hyp.core.decomp_hyp(H: Hypergraph)[source]
hyp.core.discret(n: int) → Hypergraph[source]

Return the discrete hypergraph with n nodes and n links with each node isolated in a link.

hyp.core.enriched_homset(X: NamedSet, Y: NamedSet) → Hypergraph[source]

Return the simple enriched hom-set Hom[X, Y]_set, where X and Y are sets.

  • S_Hom[X, Y] = Hom(X, Y)

  • L_Hom[X, Y] = P(X) x P(Y))

  • and f : X -> Y is in l_(A, B) with A ⊆ X and B ⊆ Y,

if for all x in A, s(x) is in B.

hyp.core.finite_funny_maps(morphism_list: list[HypergraphMorphism]) → HypergraphMorphism[source]

Return the morphism

f0 □ f1 □ … □ fn : H0 □ H1 □ … □ Hn → G0 □ G1 □ … □ Gn

which has as components:

  • S(f0 □ f1 □ … □ fn) = S(f0) × S(f1) × … × S(fn) : S(H0) × S(H1) × … × S(Hn) → S(G0) × S(G1) × … × S(Gn)

  • T(f0 □ f1 □ … □ fn) = ∑_{i} (S(f0) × … × S(f(i-1)) × T(fi) × S(f(i+1)) × … × S(fn)) : ∑_{i} (S(H0) × … × S(H(i-1)) × T(Hi) × S(H(i+1)) × … × S(Hn)) → ∑_{i} (S(G0) × … × S(G(i-1)) × T(Gi) × S(G(i+1)) × … × S(Gn))

  • L(f0 □ f1 □ … □ fn) = ∑_{i} (S(f0) × … × S(f(i-1)) × L(fi) × S(f(i+1)) × … × S(fn)) : ∑_{i} (S(H0) × … × S(H(i-1)) × L(Hi) × S(H(i+1)) × … × S(Hn)) → ∑_{i} (S(G0) × … × S(G(i-1)) × L(Gi) × S(G(i+1)) × … × S(Gn))

hyp.core.finite_strong_maps(morphism_list: list[HypergraphMorphism]) → HypergraphMorphism[source]

For a list of morphisms f_i : H_i → G_i, return the morphism

f0 ⊠ f1 ⊠ … ⊠ fn : H0 ⊠ H1 ⊠ … ⊠ Hn → G0 ⊠ G1 ⊠ … ⊠ Gn

which has as components:

  • S_(⊠_i H_i) = Π_i S_f_i

  • T_(⊠_i H_i) = ∑_(J⊆I, J≠∅) (Π_{j∈J } T_{f_j} × Π_{j ∉ J} × S_{f_i})

  • L_(⊠_i H_i) = ∑_(J⊆I, J≠∅) (Π_{j∈J } L_{f_j} × Π_{j ∉ J} × S_{f_i})

hyp.core.free_prod(H: Representable) → FunnyTensor[source]

Return the free funny tensor product of a hypergraph H H □ 1, which creates a link l_x at each node x of H, and a tie t_x at each node x of H, such that t_x : x ∈ l_x.

hyp.core.funny_associator(H0: Representable, H1: Representable, H2: Representable) → HypergraphIsomorphism[source]

Return the associator isomorphism

α : (H0 □ H1) □ H2 → H0 □ (H1 □ H2)

hyp.core.funny_left_unitor(H: Representable) → HypergraphIsomorphism[source]

Return the left unitor isomorphism

λ : I □ H → H

where I is the unit object for the funny tensor product.

hyp.core.funny_product_maps(f0: HypergraphMorphism, f1: HypergraphMorphism) → HypergraphMorphism[source]

Return the morphism

f0 □ f1 : H0 □ H1 → G0 □ G1

which has as components:

  • Sf0□f1 = Sf0 × Sf1 : SH0 × SH1 → SG0 × SG1

  • Tf0□f1 = Sf0 × Tf1 + Tf0 × Sf1 : SH0 × TH1 + TH0 × SH1 → SG0 × TG1 + TG0 × SG1

  • Lf0□f1 = Sf0 × Lf1 + Lf0 × Sf1 : SH0 × LH1 + LH0 × SH1 → SG0 × LG1 + LG0 × SG1

hyp.core.funny_right_unitor(H: Representable) → HypergraphIsomorphism[source]

Return the right unitor isomorphism

ρ : H □ I → H

where I is the unit object for the funny tensor product.

hyp.core.hom_coconforme(H_0: Representable, H_1: Representable) → NamedSet[source]

Return the set of coconforme morphisms of hypergraphs from H_0 to H_1, as a subset of the homset Hom[H_0,H_1].

hyp.core.hom_conforme(H_0: Representable, H_1: Representable) → NamedSet[source]

Return the set of conforme morphisms of hypergraphs from H_0 to H_1, as a subset of the homset Hom[H_0,H_1].

hyp.core.hom_epi(H_0: Representable, H_1: Representable) → NamedSet[source]

Return the set of epimorphisms of hypergraphs from H_0 to H_1, as a subset of the homset Hom[H_0,H_1].

hyp.core.hom_mono(H_0: Representable, H_1: Representable) → NamedSet[source]

Return the set of monomorphisms of hypergraphs from H_0 to H_1, as a subset of the homset Hom[H_0,H_1].

hyp.core.homgraph_cardinality_fast(H0: Representable, H1: Representable) → int[source]

Count hypergraph morphisms using the cheapest native orientation.

hyp.core.homsetfin(n: int, m: int) → HomSet[source]

Return the hom-set Hom[[n], [m]], where [n] and [m] are walking links.

hyp.core.hyp_from_matrice(matrice: ndarray) → Hypergraph[source]

Return the hypergraph associated to a matrix of natural numbers, with n rows and m columns, where each entry (i, j) of the matrix gives the number of ties from node i to link j.

hyp.core.hyp_to_matrice(hyp: Representable, sorting_nodes: list, sorting_links: list) → ndarray[source]

For H a hypergraph, given a sorting of the nodes and links of H, return the M(H) with M(H)[i, j] = <xi, l_j> the number of ties from node x_i to link l_j in H.

hyp.core.hypergraph_from_dict(dic: dict, Nodes: Representable, Links: Representable, name=None) → Hypergraph[source]

Return a Hypergraph from a dictionary. Here the values of the dictionary are elements of the given sets of nodes and links.

Parameters:
  • dic – A dictionary coding the span T ↣ S x L, of the form {t : (s, l)}.

  • Nodes – A NamedSet (or more generally, a seth.Representable) of nodes.

  • Links – A NamedSet (or more generally, a seth.Representable) of links.

  • name – An optional name for the hypergraph.

hyp.core.hypergraph_from_dict_brut(D: dict, S0=None, L0=None, name=None) → Hypergraph[source]

Return a Hypergraph from a dictionary specifying ties in an ergonomic way. Here the specified nodes and links are native sets, do not require names. The values of the dictionary are pairs of the form (s, l) where s is a node and l is a link. The values s and l need not be already in S0 nor L0, they will be added to the support of the hypergraph.

Parameters:
  • D – A dictionary coding the span T ↣ S x L, of the form {t : (s, l)}.

  • S0 – An optional set of nodes to add to the support of the hypergraph.

  • L0 – An optional set of links to add to the support of the hypergraph.

  • name – An optional name for the hypergraph.

hyp.core.hypergraph_from_set(set_input: set | Representable, name: str) → Hypergraph[source]

Return a codiscrete Hypergraph from a set of nodes, with a single link and ties corresponding to the nodes.

hyp.core.hypset(S: NamedSet, L: NamedSet, T: NamedSet)[source]

Return the set of all hypergraphs with nodes S, links L, and ties T.

hyp.core.inclusion_hypergraph(Subgraph: Representable, H: Representable) → HypergraphMorphism[source]

Return the inclusion morphism i : Subgraph ↣ H, where Subgraph is a subobject of H. It is computed from the pullback defining Subgraph as a subobject of H.

hyp.core.kernel(f: HypergraphMorphism) → Pullback[source]
hyp.core.list_2_by_2(n: int) → Hypergraph[source]

Return the hypergraph of lists of length n, with n nodes and n-1 links [i, i+1] containing the nodes i and i+1.

hyp.core.list_hyp(n: int) → Hypergraph[source]

Return the hypergraph of lists of length n, with n nodes and n links [i] containing the j < i.

hyp.core.list_ordered(n: int) → Hypergraph[source]

Return the hypergraph of ordered lists of length n, with n nodes and n(n+1)/2 links [i, j] containing the k with i <= k <= j.

class hyp.core.natural_tie(f: HypergraphMorphism, alpha: PrenaturalTransformation, map: NamedFunction, name=None)[source]

Bases: object

Return a natural tie nw : f -> alpha, where f : H0 -> H1 is a hypergraph morphism, alpha : H0 -> H1 is a prenatural transformation, and map : H0.Nodes -> H1.Ties

hyp.core.number_hyp(size_S: int, size_L: int, size_T: int)[source]

Return the number of hypergraphs with size_S nodes, size_L links, and size_T ties.

hyp.core.obj(input) → Hypergraph[source]
hyp.core.poset_of_subobjects(H: Representable) → NamedSet[source]

Return the set of subobjects of H It is computed from the hom-set Hom(H, Ω) and the pullback defining each subobject as a subobject of H.

hyp.core.preim_partition(f: NamedFunction) → Hypergraph[source]

Return the hypergraph associated to the partition of the domain of f by the preimages of the elements of the codomain of f, i.e. S = dom(f), L = cod(f), and T = {(s, f(s)) | s in S}.

hyp.core.product_morphism(f0: HypergraphMorphism, f1: HypergraphMorphism) → HypergraphMorphism[source]

For two morphisms f0 : H0 → G0 and f1 : H1 → G1, return the product morphism

f0 × f1 : H0 × H1 → G0 × G1

hyp.core.product_morphism_list(morphism_list: list[HypergraphMorphism]) → HypergraphMorphism[source]

From a list of morphisms f0, f1, …, fn, return the product morphism

Π fi : H0 × H1 × … × Hn → G0 × G1 × … × Gn

hyp.core.reticulation(n: int, m: int) → FunnyTensor[source]

Return the funny tensor of two hypergraphs of lists of length n and m.

hyp.core.sorting_defaut(s: set) → list[source]
hyp.core.strong_product_maps(f0: HypergraphMorphism, f1: HypergraphMorphism) → HypergraphMorphism[source]

For a pair of hypergraph morphisms f0 : H0 → G0 and f1 : H1 → G1, return the morphism

f0 ⊠ f1 : H0 ⊠ H1 → G0 ⊠ G1

which has as components:

  • Sf0⊠f1 = Sf0 × Sf1 : SH0 × SH1 → SG0 × SG1

  • Tf0⊠f1 = Sf0 × Tf1 + Tf0 + Sf1 + Tf0 x Tf1 : SH0 × TH1 + TH0 + SH1 + TH0 x TH1 → SG0 × TG1 + TG0 + SG1 + TG0 x TG1

  • Lf0⊠f1 = Sf0 × Lf1 + Lf0 + Sf1 + Lf0 x Lf1 : SH0 × LH1 + LH0 + SH1 + LH0 x LH1 → SG0 × LG1 + LG0 + SG1 + LG0 x LG1

hyp.core.subobject_from_charmap(H: Representable, chi: HypergraphMorphism) → Hypergraph[source]
hyp.core.subobjet_conforme(H: Representable) → NamedSet[source]

Return the set of subobjects of H that are conformal, i.e. such that the inclusion morphism is a hypergraph monomorphism.

hyp.core.sum_fin_lien_libres(list_nat: Sequence) → FiniteCoproduct[source]

Return the coproduct of a list of walking links.

hyp.core.sum_lien_libres(n: int, m: int) → Coproduct[source]

Return the coproduct of two walking links [n] and [m].

hyp.core.test_coconforme(f: HypergraphMorphism) → bool[source]

A morphism f : H → G of hypergraphs is coconforme if for every node s in dom, the occurrences map Occ(s)_H → Occ(f(s))_G of s is surjective.

hyp.core.test_conforme(f: HypergraphMorphism) → bool[source]

A morphism f : H → G of hypergraphs is conforme if for every link l in dom, the support map |l|_H → |f(l)|_G of l is surjective.

hyp.core.test_inclusion_sub_fast(Sub1: Representable, Sub2: Representable) → int[source]
hyp.core.unitor_cartesian_left(H: Representable) → HypergraphIsomorphism[source]

Return the left unitor isomorphism

λ : 1 × H ≃ H

hyp.core.unitor_cartesian_right(H: Representable) → HypergraphIsomorphism[source]

Return the right unitor isomorphism

ρ : H × 1 ≃ H

hyp.core.unitor_coproduct_left(H: Representable) → HypergraphIsomorphism[source]

Return the left unitor isomorphism

λ : 0 + H ≃ H

hyp.core.unitor_coproduct_right(H: Representable) → HypergraphIsomorphism[source]

Return the right unitor isomorphism

ρ : H + 0 ≃ H

Return the finite hypergraph [n] with n nodes and one link

Return the funny hom-graph Hom[[n], [m]]_□, where [n] and [m] are walking links.

Return the finite funny tensor product of a list of walking links.

Return the funny tensor product of two walking links [n] and [m].

hyp.core.walking_loop(n: int) → Hypergraph[source]

Return the hypergraph with a single node a single link, and n ties from the node to the link.