Hypergraphs Generators API
Hypergraph Generators
- graphcalc.hypergraphs.generators.uniform.affine_plane(q: int, **hg_kwargs) Hypergraph[source]
Construct the affine plane
AG(2, q)for primeq.Vertices are points of
F_q^2and edges are affine lines.- Parameters:
q (int) – Prime order of the field.
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Affine plane hypergraph with
q^2vertices,q^2 + qlines, and line sizeq.- Return type:
- Raises:
ValueError – If
qis not prime.
- graphcalc.hypergraphs.generators.uniform.arithmetic_progressions(n: int, k: int, cyclic: bool = True, include_reverse: bool = False, **hg_kwargs) Hypergraph[source]
Construct the
k-term arithmetic progression hypergraph onZ_n.The vertices are
0, 1, ..., n - 1and hyperedges arek-term arithmetic progressions.- Parameters:
n (int) – Number of vertices.
k (int) – Progression length and edge size.
cyclic (bool, default=True) – If True, progressions are taken modulo
n. If False, only non-wrapping progressions inside[0, n-1]are included.include_reverse (bool, default=False) – In the cyclic model, whether to include both steps
dand-d. When False, attempts to avoid double counting reverse progressions.**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Arithmetic progression hypergraph.
- Return type:
- Raises:
ValueError – If
k < 2ork > n.
- graphcalc.hypergraphs.generators.uniform.complete_k_uniform(n: int, k: int, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct the complete
k-uniform hypergraph onnvertices.The hyperedges are all
k-subsets of the vertex set.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Complete
k-uniform hypergraph.- Return type:
- Raises:
ValueError – If
k < 2ork > n.
- graphcalc.hypergraphs.generators.uniform.erdos_ko_rado_star(n: int, k: int, t: int = 1, core: Iterable[Hashable] | None = None, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct an Erdős-Ko-Rado
t-star.This is the family of all
k-sets containing a fixedt-set called the core.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
t (int, default=1) – Size of the fixed core.
core (iterable, optional) – Chosen core. If omitted, the first
tvertices are used.labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
The EKR
t-star.- Return type:
- Raises:
ValueError – If the parameters are inconsistent or if
coreis not a validt-subset of the vertex set.
- graphcalc.hypergraphs.generators.uniform.fano_plane(**hg_kwargs) Hypergraph[source]
Construct the Fano plane.
This is the projective plane
PG(2, 2), a 3-uniform hypergraph on 7 vertices with 7 edges.- Parameters:
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.- Returns:
Fano plane.
- Return type:
- graphcalc.hypergraphs.generators.uniform.hilton_milner(n: int, k: int, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct the Hilton-Milner intersecting family.
Standard construction assumes
n > 2k >= 4. On the vertex setV = [v_0, ..., v_{n-1}], letS = {v_0, ..., v_{k-1}}andx = v_k. The family is{S} ∪ {A : |A| = k, x in A, A ∩ S != empty}.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Hilton-Milner family.
- Return type:
- Raises:
ValueError – If
k < 2orn <= 2k.
- graphcalc.hypergraphs.generators.uniform.k_uniform_matching(n: int, k: int, m: int, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct a matching of
mdisjointk-edges.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
m (int) – Number of disjoint edges.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Hypergraph consisting of
mpairwise disjoint edges.- Return type:
- Raises:
ValueError – If
m < 0orn < m * k.
- graphcalc.hypergraphs.generators.uniform.k_uniform_star(n: int, k: int, center: Hashable | None = None, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct the
k-uniform star centered at one vertex.The hyperedges are all
k-sets containing the chosen center.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
center (hashable, optional) – Distinguished center vertex. If omitted, the first vertex is used.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
k-uniform star.- Return type:
- Raises:
ValueError – If
n < korcenteris not in the vertex set.
- graphcalc.hypergraphs.generators.uniform.loose_cycle(r: int, k: int, start_label: int = 0, **hg_kwargs) Hypergraph[source]
Construct a
k-uniform loose cycle withredges.Consecutive edges intersect in exactly one vertex, and nonconsecutive edges are disjoint. The vertex count is
r * (k - 1).- Parameters:
r (int) – Number of edges.
k (int) – Uniform edge size.
start_label (int, default=0) – Starting integer used for vertex labels.
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Loose cycle. If
r == 0, returns the empty hypergraph.- Return type:
- Raises:
ValueError – If
k < 2orr < 0.
- graphcalc.hypergraphs.generators.uniform.loose_path(r: int, k: int, start_label: int = 0, **hg_kwargs) Hypergraph[source]
Construct a
k-uniform loose path withredges.Consecutive edges intersect in exactly one vertex, and nonconsecutive edges are disjoint. The vertex count is
r * (k - 1) + 1.- Parameters:
r (int) – Number of edges.
k (int) – Uniform edge size.
start_label (int, default=0) – Starting integer used for vertex labels.
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Loose path. If
r == 0, returns the empty hypergraph.- Return type:
- Raises:
ValueError – If
k < 2orr < 0.
- graphcalc.hypergraphs.generators.uniform.projective_plane(q: int, **hg_kwargs) Hypergraph[source]
Construct the projective plane
PG(2, q)for primeq.Vertices are projective points and hyperedges are projective lines.
- Parameters:
q (int) – Prime order of the field.
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Projective plane hypergraph with
q^2 + q + 1vertices,q^2 + q + 1lines, and line sizeq + 1.- Return type:
- Raises:
ValueError – If
qis not prime.
- graphcalc.hypergraphs.generators.uniform.random_k_regular_configuration(n: int, k: int, d: int, seed: object | None = None, max_tries: int = 2000, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct a random simple
d-regulark-uniform hypergraph using a configuration-style model.This attempts to partition vertex stubs into
k-blocks. Candidate blocks containing repeated vertices are rejected. Duplicate edges are deduplicated, so exact regularity may fail if too many rejections occur. The best attempt found withinmax_triesis returned.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
d (int) – Target vertex degree.
seed (object, optional) – Seed passed to
random.Random.max_tries (int, default=2000) – Maximum number of configuration attempts.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
A simple
k-uniform hypergraph, often but not always exactlyd-regular.- Return type:
- Raises:
ValueError – If
n * dis not divisible byk.
- graphcalc.hypergraphs.generators.uniform.random_k_uniform(n: int, k: int, p: float | None = None, m: int | None = None, seed: object | None = None, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct a random
k-uniform hypergraph onnvertices.Exactly one of
pormmust be supplied.If
pis provided, eachk-subset is included independently with probabilityp.If
mis provided, exactlymdistinct edges are chosen uniformly without replacement.
- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
p (float, optional) – Inclusion probability for the binomial model.
m (int, optional) – Number of edges for the fixed-size model.
seed (object, optional) – Seed passed to
random.Random.labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Random
k-uniform hypergraph.- Return type:
- Raises:
ValueError – If
k > n, if both or neither ofpandmare supplied, ifpis outside[0, 1], or ifmis out of range.
- graphcalc.hypergraphs.generators.uniform.sunflower(k: int, petals: int, core_size: int = 1, start_label: int = 0, **hg_kwargs) Hypergraph[source]
Construct a
k-uniform sunflower (delta-system).All edges share the same core of size
core_sizeand are otherwise pairwise disjoint.- Parameters:
k (int) – Uniform edge size.
petals (int) – Number of petals (edges).
core_size (int, default=1) – Size of the common core.
start_label (int, default=0) – Starting integer used for vertex labels.
**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Sunflower hypergraph.
- Return type:
- Raises:
ValueError – If
k < 2,petals < 0, orcore_sizeis not in[0, k].
- graphcalc.hypergraphs.generators.uniform.tight_cycle(n: int, k: int, labels: Sequence[Vertex] | None = None, **hg_kwargs) Hypergraph[source]
Construct the
k-uniform tight cycle onnvertices.The edges are the cyclic consecutive
k-windows modulon. There are exactlynedges.- Parameters:
n (int) – Number of vertices.
k (int) – Uniform edge size.
labels (sequence, optional) – Vertex labels. If omitted, uses
range(n).**hg_kwargs – Additional keyword arguments passed to
Hypergraph.from_edges.
- Returns:
Tight cycle.
- Return type:
- Raises:
ValueError – If
n < k.