Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Combinatorics
Light Logo Dark Logo
Version 10.7 Reference Manual
  • Home - Combinatorics
  • Comprehensive module list
    • A bijectionist’s toolkit
    • Abstract recursive trees
    • Affine permutations
    • Algebraic combinatorics
    • Alternating sign matrices
    • Backtracking
    • Baxter permutations
    • Bell and Uppuluri-Carpenter numbers
    • Binary recurrence sequences
    • Binary trees
    • Blob algebras
    • Boundedness of \(k\)-Regular Sequences
    • Brent Yorgey’s fast algorithm for integer vector (multiset) partitions
    • Cartesian products
    • Cluster complex (or generalized dual associahedron)
    • Colored permutations
    • Combinations
    • Combinatorial diagrams
    • Combinatorial functions
    • Combinatorial maps
    • Combinatorial triangles for posets and fans
    • Combinatorics
    • Introduction to combinatorics in Sage
    • Combinatorics quickref
    • Common automata and transducers (finite state machines generators)
    • Composition tableaux
    • Constellations
    • Cores
    • Counting
    • Counting, generating, and manipulating nonnegative integer matrices
    • Cyclic sieving phenomenon
    • De Bruijn sequences
    • Decorated permutations
    • Degree sequences
    • Derangements
    • Descent algebras
    • Diagram and partition algebras
    • Dyck words
    • Enumerated sets
    • Exact cover problem via dancing links
    • Families
    • Fast computation of combinatorial functions (Cython + mpz)
    • Fast set partition iterators
    • Finite state machines, automata, transducers
    • Free dendriform algebras
    • Free modules
    • Free pre-Lie algebras
    • Free quasi-symmetric functions
    • Fully commutative elements of Coxeter groups
    • Fully packed loops
    • Functions that compute some of the sequences in Sloane’s tables
    • Gelfand-Tsetlin patterns
    • Generalized Tamari lattices
    • Gray codes
    • Grossman-Larson Hopf algebras
    • Growth diagrams and dual graded graphs
    • Hall polynomials
    • Integer compositions
    • Integer partitions
    • Integer vectors modulo the action of a permutation group
    • Iterators over the partitions of an integer
    • Kazhdan-Lusztig polynomials
    • Key polynomials
    • Kleshchev partitions
    • Knutson-Tao puzzles
    • Littlewood-Richardson tableaux
    • Miscellaneous
    • Necklaces
    • Non-decreasing parking functions
    • Nonnegative integer vectors
    • Ordered multiset partitions into sets and the minimaj crystal
    • Ordered rooted trees
    • Ordered set partitions
    • Output functions
    • Parallelogram polyominoes
    • Parking functions
    • Partition shifting algebras
    • Partition tuples
    • Partition/diagram algebras
    • Partitions, tableaux, and others
    • Paths in directed acyclic graphs
    • Perfect matchings
    • Permutations
    • Permutations (Cython file)
    • Plane partitions
    • Rankers
    • Recognizable series
    • Representations of the symmetric group
    • Residue sequences of tableaux
    • Restricted growth arrays
    • Ribbon shaped tableaux
    • Ribbon tableaux
    • Ribbons
    • Robinson-Schensted-Knuth correspondence
    • Rooted (unordered) trees
    • Schubert polynomials
    • Set partitions
    • Shard intersection order
    • Shifted primed tableaux
    • Shuffle product of iterables
    • Sidon sets and their generalizations, Sidon \(g\)-sets
    • Signed compositions
    • Similarity class types of matrices with entries in a finite field
    • Six vertex model
    • Skew partitions
    • Skew tableaux
    • Specht modules
    • Steinhaus-Johnson-Trotter algorithm
    • Strong and weak tableaux
    • Subsets
    • Subsets satisfying a hereditary property
    • Subsets whose elements satisfy a predicate pairwise
    • Substitutions over unit cube faces (Rauzy fractals)
    • Subword complex
    • Subword complex: auxiliary Cython functions
    • Subwords
    • Super partitions
    • Super tableaux
    • Symmetric group algebra
    • T-sequences
    • TableauTuples
    • Tableaux
    • Tamari Interval-posets
    • The Hillman-Grassl correspondence
    • Tiling solver
    • Tools for enumeration modulo the action of a permutation group
    • Transitive ideal closure tool
    • Tuples
    • Vector partitions
    • Weighted integer vectors
    • Yang-Baxter Graphs
    • \(\nu\)-Dyck words
    • \(\nu\)-Tamari lattice
    • \(k\)-regular sequences
    • \(q\)-Bernoulli numbers and polynomials
    • \(q\)-analogues
    • sine-Gordon Y-system plotter
    • Combinatorial Hopf algebras
    • Poirier-Reutenauer Hopf algebra of standard tableaux
    • Word quasi-symmetric functions
    • Cluster algebras and quivers
    • Cluster seeds
    • Helper functions for mutation types of quivers
    • Interactive display of quivers
    • Quiver
    • Quiver mutation types
    • mutation_class
    • Affine crystals
    • Affine factorization crystal of type \(A\)
    • Affinization crystals
    • Alcove paths
    • An introduction to crystals
    • Benkart-Kang-Kashiwara crystals for the general-linear Lie superalgebra
    • Catalog of crystal models For \(B(\infty)\)
    • Catalog of crystal models for Kirillov-Reshetikhin crystals
    • Catalog of crystals
    • Catalog of elementary crystals
    • Crystal of Bernstein-Zelevinsky multisegments
    • Crystal of Mirković-Vilonen polytopes
    • Crystals
    • Crystals of Kac modules of the general-linear Lie superalgebra
    • Crystals of generalized Young walls
    • Crystals of letters
    • Crystals of modified Nakajima monomials
    • Direct sum of crystals
    • Elementary crystals
    • Fast rank two crystals
    • Fully commutative stable Grothendieck crystal
    • Highest weight crystals
    • Induced crystals
    • Kirillov-Reshetikhin crystals
    • Kyoto path model for affine highest weight crystals
    • Littelmann paths
    • PBW data
    • Polyhedral realization of \(B(\infty)\)
    • Spin crystals
    • Star-crystal structure on \(B(\infty)\)
    • Subcrystals
    • Tensor products of crystal elements
    • Tensor products of crystals
    • Virtual crystals
    • \(\mathcal{B}(\infty)\) crystal of PBW monomials
    • \(\mathcal{B}(\infty)\) crystals of tableaux in nonexceptional types and \(G_2\)
    • Balanced incomplete block designs (BIBD)
    • Block designs
    • Bounds on the number of mutually orthogonal Latin squares
    • Catalog of designs
    • Combinatorial designs and incidence structures
    • Covering arrays
    • Covering designs: coverings of \(t\)-element subsets of a \(v\)-set by \(k\)-sets
    • Cython functions for combinatorial designs
    • Database of generalised quadrangles with spread
    • Database of small combinatorial designs
    • Difference families
    • Difference matrices
    • Evenly distributed sets in finite fields
    • External representations of block designs
    • Group-divisible designs (GDD)
    • Hypergraph isomorphic copy search
    • Incidence structures (i.e. hypergraphs, i.e. set systems)
    • Mutually orthogonal Latin squares (MOLS)
    • Orthogonal arrays (OA)
    • Orthogonal arrays (build recursive constructions)
    • Orthogonal arrays (find recursive constructions)
    • Resolvable balanced incomplete block design (RBIBD)
    • Steiner quadruple systems
    • Two-graphs
    • Enumerated set of lists of integers with constraints, in inverse lexicographic order
    • Enumerated set of lists of integers with constraints: base classes
    • Enumerated set of lists of integers with constraints: front-end
    • Lists of nonnegative integers with constraints.
    • Combinatorics on matrices
    • Dancing Links internal pyx code
    • Dancing links C++ wrapper
    • Hadamard matrices
    • Latin squares
    • Common combinatorial tools
    • Generic code for bases
    • Introduction to quasisymmetric functions
    • Noncommutative symmetric functions
    • Noncommutative symmetric functions and quasi-symmetric functions
    • Quasisymmetric functions
    • Bases for NCSym
    • Dual symmetric functions in non-commuting variables
    • Symmetric functions in non-commuting variables
    • Symmetric functions in non-commuting variables
    • Catalog of path tableaux
    • Dyck paths
    • Frieze patterns
    • Path tableaux
    • Path tableaux
    • Semistandard tableaux
    • Bubble and Shuffle lattices
    • Cartesian products of posets
    • Catalog of posets and lattices
    • D-complete posets
    • Elements of posets, lattices, semilattices, etc.
    • Fast linear extension iterator
    • Finite lattices and semilattices
    • Finite posets
    • Forest posets
    • Hasse diagrams of posets
    • Hochschild lattices
    • Incidence algebras
    • Linear extensions of posets
    • Mobile posets
    • Möbius algebras
    • Posets
    • Some fast computations for finite posets
    • Some fast computations for finite posets using FLINT matrices
    • Abstract classes for the rigged configuration bijections
    • Bijection between rigged configurations and KR tableaux
    • Bijection between rigged configurations for \(B(\infty)\) and marginally large tableaux
    • Bijection classes for type \(A_n^{(1)}\)
    • Bijection classes for type \(A_{2n-1}^{(2)}\)
    • Bijection classes for type \(A_{2n}^{(2)\dagger}\)
    • Bijection classes for type \(A_{2n}^{(2)}\)
    • Bijection classes for type \(B_n^{(1)}\)
    • Bijection classes for type \(C_n^{(1)}\)
    • Bijection classes for type \(D_4^{(3)}\)
    • Bijection classes for type \(D_n^{(1)}\)
    • Bijection classes for type \(D_{n+1}^{(2)}\)
    • Bijection classes for type \(E_{6,7}^{(1)}\)
    • Crystal of rigged configurations
    • Kirillov-Reshetikhin tableaux
    • Kleber trees
    • Rigged configuration elements
    • Rigged configurations
    • Rigged configurations
    • Rigged configurations of \(\mathcal{B}(\infty)\)
    • Rigged partitions
    • Tensor product of Kirillov-Reshetikhin tableaux
    • Tensor product of Kirillov-Reshetikhin tableaux elements
    • Ambient lattices and ambient spaces
    • Associahedron
    • Braid move calculator
    • Braid orbit
    • Branching rules
    • Cartan matrices
    • Cartan types
    • Coxeter groups
    • Coxeter matrices
    • Coxeter types
    • Dynkin diagrams
    • Extended affine Weyl groups
    • Finite complex reflection groups
    • Finite real reflection groups
    • Fundamental group of an extended affine Weyl group
    • Group algebras of root lattice realizations
    • Hecke algebra representations
    • Integrable representations of affine Lie algebras
    • Nonsymmetric Macdonald polynomials
    • Pieri factors
    • Reflection group elements
    • Reflection groups: auxiliary Cython functions
    • Root lattice realizations
    • Root lattices and root spaces
    • Root system data for (untwisted) type A affine
    • Root system data for (untwisted) type B affine
    • Root system data for (untwisted) type C affine
    • Root system data for (untwisted) type D affine
    • Root system data for (untwisted) type E affine
    • Root system data for (untwisted) type F affine
    • Root system data for (untwisted) type G affine
    • Root system data for Cartan types with marked nodes
    • Root system data for affine Cartan types
    • Root system data for dual Cartan types
    • Root system data for folded Cartan types
    • Root system data for reducible Cartan types
    • Root system data for relabelled Cartan types
    • Root system data for super type A
    • Root system data for type A
    • Root system data for type A infinity
    • Root system data for type B
    • Root system data for type BC affine
    • Root system data for type C
    • Root system data for type D
    • Root system data for type E
    • Root system data for type F
    • Root system data for type G
    • Root system data for type H
    • Root system data for type I
    • Root system data for type Q
    • Root systems
    • Root systems
    • Tutorial: visualizing root systems
    • Weight lattice realizations
    • Weight lattices and weight spaces
    • Weyl character rings
    • Weyl groups
    • Abreu-Nigro symmetric functions
    • Characters of the symmetric group as bases of the symmetric functions
    • Classical symmetric functions
    • Elementary symmetric functions
    • Generic dual bases symmetric functions
    • Hall-Littlewood polynomials
    • Hecke character basis
    • Homogeneous symmetric functions
    • Jack symmetric functions
    • Kostka-Foulkes polynomials
    • LLT symmetric functions
    • Macdonald polynomials
    • Monomial symmetric functions
    • Multiplicative symmetric functions
    • Non-symmetric Macdonald polynomials
    • Orthogonal symmetric functions
    • Power sum symmetric functions
    • Quotient of symmetric function space by ideal generated by Hall-Littlewood symmetric functions
    • Schur symmetric functions
    • Symmetric functions
    • Symmetric functions
    • Symmetric functions defined by orthogonality and triangularity
    • Symmetric functions, with their multiple realizations
    • Symplectic symmetric functions
    • Witt symmetric functions
    • \(k\)-Schur functions
    • Characteristic species
    • Combinatorial species
    • Combinatorial species
    • Composition species
    • Cycle species
    • Empty species
    • Examples of combinatorial species
    • Functorial composition species
    • Generating series
    • Linear-order species
    • Miscellaneous functions
    • Partition species
    • Permutation species
    • Product species
    • Recursive species
    • Set species
    • Species structures
    • Subset species
    • Sum species
    • Abstract word (finite or infinite)
    • Alphabet
    • Combinatorics on words
    • Common words
    • Datatypes for finite words
    • Datatypes for words defined by iterators and callables
    • Fast word datatype using an array of unsigned char
    • Finite word
    • Infinite word
    • Lyndon words
    • Morphic words
    • Set of words
    • Shuffle product of words
    • Suffix tries and suffix trees
    • User-customizable options for words
    • Word classes
    • Word morphisms/substitutions
    • Word paths
    • C-finite sequences
    • Lazy Combinatorial Species
Back to top
View this page
Edit this page

Hypergraph isomorphic copy search¶

This module implements a code for the following problem:

INPUT: two hypergraphs \(H_1, H_2\)

OUTPUT: a copy of \(H_2\) in \(H_1\)

It is also possible to enumerate all such copies, and to require that such copies be induced copies. More formally:

A copy of \(H_2\) in \(H_1\) is an injection \(f:V(H_2)\mapsto V(H_1)\) such that for any set \(S_2\in E(H_2)\) we have \(f(S_2)\in E(H_1)\).

It is an induced copy if no other set of \(E(H_1)\) is contained in \(f(V(H_2))\), i.e. \(|E(H_2)|=\{S:S\in E(H_1)\text{ and }S\subseteq f(V(H_2))\}\).

The functions implemented here lists all such injections. In particular, the number of copies of \(H\) in itself is equal to \(|Aut(H)|\).

The feature is available through IncidenceStructure.isomorphic_substructures_iterator().

Implementation¶

A hypergraph is stored as a list of edges, each of which is a “dense” bitset over \(|V(H_1)|\) points. In particular, two sets of distinct cardinalities require the same memory space. A hypergraph is a C struct with the following fields:

  • n, m – (int) number of points and edges

  • limbs – (int) number of 64-bits blocks per set

  • set_space – (uint64_t *) address of the memory used to store the sets

  • sets – (uint64_t **) sets[i] points toward the limbs blocks encoding set \(i\). Note also that sets[i][limbs] is equal to the cardinality of set[i], so that sets has length m*(limbs+1)*sizeof(uint64_t).

  • names – (int *) associates an integer ‘name’ to each of the n points

The operations used on this data structure are:

  • void permute(hypergraph * h, int n1, int n2) – exchanges points \(n1\) and \(n2\) in the data structure. Note that their names are also exchanged so that we still know which is which.

  • int induced_hypergraph(hypergraph * h1, int n, hypergraph * tmp1) – stores in tmp1 the hypergraph induced by the first \(n\) points, i.e. all sets \(S\) such that \(S\subseteq \{0,...,n-1\}\). The function returns the number of such sets.

  • void trace_hypergraph64(hypergraph * h, int n, hypergraph * tmp) – stores in tmp1 the trace of \(h\) on the first \(n\) points, i.e. all sets of the form \(S\cap \{0, \ldots, n-1\}\).

Algorithm¶

We try all possible assignments of a representant \(r_i\in H_1\) for every \(i\in H_2\). When we have picked a representant for the first \(n<\) points \(\{0, \ldots, n-1\}\subsetneq V(H_2)\), we check that:

  • The hypergraph induced by the (ordered) list \(0, \ldots, n-1\) in \(H_2\) is equal to the one induced by \(r_0, \ldots, r_{n-1}\) in \(H_1\).

  • If \(S\subseteq \{0,...,n-1\}\) is contained in \(c\) sets of size \(k\) in \(H_2\), then \(\{r_i:i\in S\}\) is contained in \(\geq c\) sets of size \(k\) in \(H_1\). This is done by comparing the trace of the hypergraphs while remembering the original size of each set.

As we very often need to build the hypergraph obtained by the trace of the first \(n\) points (for all possible \(n\)), those hypergraphs are cached. The hypergraphs induced by the same points are handled similarly.

Limitations¶

Number of points For efficiency reason the implementation assumes that \(H_2\) has \(\leq 64\) points. Making this work for larger values means that calls to qsort have to be replaced by calls to qsort_r (i.e. to sort the edges you need to know the number of limbs per edge) and that induces a big slowdown for small cases (~50% when this code was implemented). Also, 64 points for \(H_2\) is already very very big considering the problem at hand. Even \(|V(H_1)|> 64\) seems too much.

Vertex ordering The order of vertices in \(H_2\) has a huge influence on the performance of the algorithm. If no set of \(H_2\) contains more that one of the first \(k<n\) points, then almost all partial assignments of representants are possible for the first \(k\) points (though the degree of the vertices is taken into account). For this reason it is best to pick an ordering such that the first vertices are contained in as many sets as possible together. A heuristic is implemented at relabel_heuristic().

AUTHORS:

  • Nathann Cohen (November 2014, written in various airports between Nice and Chennai).

Methods¶

class sage.combinat.designs.subhypergraph_search.SubHypergraphSearch¶

Bases: object

relabel_heuristic()¶

Relabel \(H_2\) in order to make the algorithm faster.

Objective: we try to pick an ordering \(p_1,...,p_k\) of the points of \(H_2\) that maximizes the number of sets involving the first points in the ordering. One way to formalize the problems indicates that it may be NP-Hard (generalizes the max clique problem for graphs) so we do not try to solve it exactly: we just need a sufficiently good heuristic.

Assuming that the first points are \(p_1,...,p_k\), we determine \(p_{k+1}\) as the point \(x\) such that the number of sets \(S\) with \(x\in S\) and \(S\cap \{p_1,...,p_k\}\neq \emptyset\) is maximal. In case of ties, we take a point with maximum degree.

This function is called when an instance of SubHypergraphSearch is created.

EXAMPLES:

sage: d = designs.projective_plane(3)                                       # needs sage.schemes
sage: d.isomorphic_substructures_iterator(d).relabel_heuristic()            # needs sage.schemes
>>> from sage.all import *
>>> d = designs.projective_plane(Integer(3))                                       # needs sage.schemes
>>> d.isomorphic_substructures_iterator(d).relabel_heuristic()            # needs sage.schemes
Next
Incidence structures (i.e. hypergraphs, i.e. set systems)
Previous
Group-divisible designs (GDD)
Copyright © 2005--2025, The Sage Development Team
Made with Sphinx and @pradyunsg's Furo
On this page
  • Hypergraph isomorphic copy search
    • Implementation
    • Algorithm
    • Limitations
    • Methods
    • SubHypergraphSearch
      • relabel_heuristic()