Random Graph Generation in Context-Free Graph Languages
Federico Vastarini, Detlef Plump
TL;DR
The paper addresses uniform random sampling of hypergraphs from context-free hypergraph languages specified by hyperedge replacement grammars (HRGs). It extends Mairson's CFG sampling approach to HRGs in CNF, introducing a preprocessing phase that builds counting matrices and a generation phase that, under non-ambiguity, yields uniformly distributed samples in $O(n^2)$ time. Key contributions include a CNF transformation framework for HRGs, a practical two-phase sampling algorithm, and a formal uniformity proof for $n$-unambiguous grammars, with implications for graph-based testing and domains like term graphs and molecule representations. This method enables controlled, uniform generation of structured graph inputs, supporting robust testing and cryptographic explorations in graph-structured domains.
Abstract
We present a method for generating random hypergraphs in context-free hypergraph languages. It is obtained by adapting Mairson's generation algorithm for context-free string grammars to the setting of hyperedge replacement grammars. Our main results are that for non-ambiguous hyperedge replacement grammars, the method generates hypergraphs uniformly at random and in quadratic time. We illustrate our approach by a running example of a hyperedge replacement grammar generating term graphs.
