TopoHG: Topology Hard Sample Generation
- TopoHG is a design pattern that concentrates on generating topologically hard instances for problems like graph algorithms and tubular segmentation.
- It employs probabilistic models and techniques such as prioritized replay and teacher-student consistency to learn a distribution of challenging samples.
- The framework adapts across domains by leveraging topology-aware perturbations to reveal structural failure modes and improve benchmarking and performance.
Searching arXiv for the cited TopoHG-related papers to ground the article in current literature. Querying arXiv for "Learning to Sample Hard Instances for Graph Algorithms" and related "Topology Hard sample Generation" works. Topology Hard Sample Generation (TopoHG) denotes a family of methods that concentrate sampling or synthesis on topologically informative or algorithmically difficult instances. In the graph-algorithm setting, the term is instantiated by HiSampler, a general, problem-agnostic framework that learns a probabilistic generator over small graphs whose mass is concentrated on instances that are maximally hard for a target algorithm (Sato et al., 2019). In later usage within tubular structure segmentation, TopoHG refers to a test-time hard-sample generation strategy that creates local pseudo-breaks in confidently predicted tubular regions and trains a model to restore continuity under teacher-student consistency supervision (Zhou et al., 1 Aug 2025). Taken together, the literature suggests that TopoHG is best understood not as a single architecture, but as a recurring design pattern in which topology-aware perturbation, sampling, or guidance is used to expose failure modes and improve analysis, benchmarking, or adaptation.
1. Origins in hard-instance generation for graph algorithms
The earliest formulation in the present corpus is HiSampler, introduced for graph problems in "Learning to Sample Hard Instances for Graph Algorithms" (Sato et al., 2019). Its stated objective is to obtain a probabilistic generator of hard instances rather than only a finite set of instances. The motivation is twofold: hard instances help analyze an algorithm for accelerating it, and they help build a good benchmark for evaluating performance. The paper further argues that evolutionary algorithms can generate only a finite number of hard instances, making it difficult to extract meaningful patterns from a small number of instances.
In this formulation, TopoHG is explicitly described as a general, problem-agnostic framework for learning a probabilistic generator over small graphs that concentrates mass on instances that are maximally hard for a given graph algorithm (Sato et al., 2019). The framework is notable for avoiding hand-engineered features and for modeling the distribution of hard instances without parameters or rules supplied by domain experts. The paper states, "To the best of our knowledge, this is the first method to learn the distribution of hard instances using machine learning" (Sato et al., 2019).
A central conceptual point is that the target object is a distribution rather than a single adversarial example. This changes the role of hard-sample generation: instead of searching for isolated worst cases, the method seeks a learned source of varied hard instances from which one can both sample benchmarks and infer recurring structural motifs.
2. Probabilistic model, objective, and optimization
For a fixed number of vertices , a simple undirected graph is represented by the upper-triangular part of its adjacency matrix, with
HiSampler defines a parameterized distribution in two stages. First, it samples latent noise
with latent dimension . Second, an -layer MLP maps 0 to edge probabilities
1
after which the graph is sampled coordinate-wise as independent Bernoullis conditioned on 2 (Sato et al., 2019). The conditional distribution is
3
and the marginal graph distribution is
4
Hardness is measured by a scalar 5, obtained by actually running the target algorithm 6 on 7. Depending on the experiment, this is either a discrete count such as the number of recursive calls or branching decisions, or wall-clock time in microseconds or milliseconds (Sato et al., 2019). The learning objective is
8
equivalently 9.
Because 0 is a non-differentiable black-box quantity, the optimization uses the score-function estimator REINFORCE. A single Monte Carlo estimator is written as
1
In practice, each iteration samples 2, computes 3, samples 4, evaluates 5, and applies
6
The variant HiSampler-PER augments vanilla REINFORCE with an experience pool containing the top-7 hardest graphs seen so far, and replays a uniformly chosen element from that pool at each iteration (Sato et al., 2019). Because truly hard graphs occupy a tiny corner of the graph space, this prioritized replay mechanism is presented as a way to accelerate convergence toward high-hardness regions.
3. Architecture, protocol, and empirical behavior
The generator is a fully connected feedforward network of depth 8, with a representative configuration
9
ReLU hidden activations, and a final sigmoid output layer (Sato et al., 2019). Although the decoder factorizes edges conditionally as independent Bernoullis, the paper emphasizes that shared parameters 0 and nonlinear activations induce rich nonlinear dependencies among edges.
The reported evaluation covers seven algorithms spanning four graph problems: DSATUR and a MiniSat reduction for 3-coloring; a branch-and-bound algorithm 1 for minimum vertex cover; BK, MCS, and FMC for maximum clique; and Nauty for graph isomorphism (Sato et al., 2019). The key hyperparameters are fixed across problems: hidden dimensions 2, Adam with learning rate 3, latent dimension 4, PER pool size 5, and total evaluation budget 6 graphs. Initialization uses a final-layer bias
7
so that 8 starts near a "hard" edge density 9 found by a small sweep.
The baselines are random sampling from Erdős-Rényi 0, a generic evolutionary algorithm with population size 1, uniform crossover, and adaptive mutation, and rule-based constructions from the literature such as phase-transition heuristics and gadget graphs (Sato et al., 2019). Across all seven targets, HiSampler-PER is reported to find instances whose hardness 2 is several to many orders of magnitude larger than random or rule-based sampling, while also consistently outperforming the generic evolutionary search.
A representative example is DSATUR with 3. The hardest random 4 sample yields about 5 recursive calls, whereas HiSampler-PER produces graphs requiring approximately 6 calls, described as a factor of about 7 harder (Sato et al., 2019). For MiniSat-based 3-coloring at 8, the hardest random sample requires about 9 solver decisions and HiSampler-PER reaches about 0. The paper states that prioritized replay consistently outperforms vanilla REINFORCE.
The qualitative analysis is equally important. Inspection of the hardest DSATUR instances reveals a tight 4-clique attached to the rest of the graph only via a long path of low-degree vertices (Sato et al., 2019). The interpretation given is that DSATUR colors the bulk of the graph first and fails only later on the clique, which forces combinatorial backtracking. Frequent-subgraph mining with gSpan on 1 samples from the learned 2 identifies 4-cliques with support approximately 3, as well as longer chains with degree-2 connectors leading into small unsatisfiable cores. The paper further reports that these motifs suggest a preprocessing rule deleting degree-4 vertices, described as provably equivalent and sufficient to eliminate the bottleneck that the learned generator exposed.
4. TopoHG in test-time adaptation for tubular structure segmentation
A distinct later use of the term appears in "TopoTTA: Topology-Enhanced Test-Time Adaptation for Tubular Structure Segmentation," where TopoHG denotes the second-stage hard-sample generation strategy inside a two-stage test-time adaptation pipeline (Zhou et al., 1 Aug 2025). Here the objective is not graph-instance generation but topological continuity refinement under domain shift.
The motivation is stated in explicitly topological terms. Tubular structure segmentation is described as especially sensitive to domain shifts because changes in topological structures can compromise segmentation integrity, while local variations in texture and contrast can disrupt topological continuity (Zhou et al., 1 Aug 2025). Stage 1, based on TopoMDCs, addresses large-scale structural discrepancies such as thickness, curvature, and branching. Stage 2, TopoHG, addresses fine-grained continuity failures by generating hard test-time samples through local perturbation of high-confidence tubular regions.
The procedure has three steps. First, key-point selection uses the teacher pseudo-label 5 to identify highly confident pixels,
6
and samples
7
distinct key points with a small coefficient 8, for example 9 (Zhou et al., 1 Aug 2025). Second, for each key point, the method extracts an 0 foreground patch with 1 and searches its non-overlapping 8-neighborhood for a background patch minimizing aggregate foreground confidence. If the selected background patch exceeds the threshold 2, that key point is discarded. Third, the foreground and background patches are transformed by FFT, and only the low-frequency region selected by a binary mask 3 is swapped: 4 The resulting patch is then blended with the pseudo-label,
5
and pasted back into the image to create the hard sample 6 (Zhou et al., 1 Aug 2025).
Learning proceeds in a teacher-student framework. The teacher predicts 7 on the original image, the student predicts 8 on the hard sample, and a weighted symmetric cross-entropy is minimized: 9 with 0 inside pseudo-break patches that belong to foreground in 1, and 2 otherwise (Zhou et al., 1 Aug 2025). The teacher is refreshed by exponential moving average,
3
The ablation results specifically attributed to Stage 2 report that adding TopoHG to a teacher-student baseline changes Dice from 4 to 5, clDice from 6 to 7, and 8 from 9 to 0, corresponding to a 1 percentage-point gain in clDice and a 2 change in Betti error (Zhou et al., 1 Aug 2025). In comparisons against naïve augmentations, the full two-stage TopoTTA with TopoHG attains Dice 3, clDice 4, and 5; Gaussian blur gives clDice 6, Gaussian noise 7, and spatial image swap 8 with a smaller Betti error but substantially lower Dice 9 (Zhou et al., 1 Aug 2025). The paper interprets pure spatial swap as over-connecting background, whereas TopoHG preserves high Dice while strengthening continuity.
5. Relation to topology-controlled and topology-guided generative methods
TopoHG sits in a broader landscape of topology-aware sampling and generation. One antecedent is "Efficient Topology-Controlled Sampling of Implicit Shapes," which develops a topology-controlled MCMC sampler, TC-GIMH-SS, for implicit level-set segmentations and shows how to impose hard topology constraints such as topology-preserving, genus-preserving, component-preserving, or unconstrained sampling (Chang et al., 2012). The method chooses proposals so that the Metropolis-Hastings acceptance ratio is identically 0, and the summary further describes a recipe for generating "hard" or adversarial shapes by modifying the target density with an auxiliary difficulty function 1. This is not called TopoHG in the paper title, but it provides a direct precedent for combining topology control with hardness-biased sampling.
Another related line is "Topology Guidance: Controlling the Outputs of Generative Models via Vector Field Topology," which studies controllable generation of 2D vector fields using a diffusion model in latent space coupled with a coordinate-based neural network (Wang et al., 11 May 2025). There the user specifies a topological descriptor 2 consisting of critical-point locations, types, and stability labels. Guidance is imposed during reverse diffusion by modifying the predicted noise with the gradient of a topology energy,
3
The energy combines critical-point existence, type, and stability terms derived from the decoded field and the Jacobian eigenvalues at prescribed points. The reported evaluation includes alignment and Fréchet Distance metrics, with single-critical-point experiments showing alignment 4 for sink and source, 5 for saddle, and 6 compared with baseline 7 (Wang et al., 11 May 2025). This suggests a neighboring interpretation of topology-aware hard generation: instead of maximizing algorithmic hardness or inducing pseudo-breaks, the generator is guided toward specified topological events while remaining within the learned data distribution.
A plausible implication is that TopoHG, topology-controlled sampling, and topology guidance all share the same methodological skeleton: a base generative or sampling process is perturbed by a topology-sensitive signal, and the perturbation is evaluated not only by realism or likelihood but also by the induced structural configuration.
6. Extensions to topologically labeled synthetic data and conceptual scope
A further extension appears in a related specification built on "Generating Topologically and Geometrically Diverse Manifold Data in Dimensions Four and Below" (Hannouch et al., 2024). In that specification, a "Topology Hard Sample Generation" pipeline produces binary 2D, 3D, or 4D images with Betti-number labels known by construction. The pipeline begins with a filled 8-cube, carves out manifold-with-boundary connected sums with sampled parameters 9, optionally applies hypervolume-preserving pixel-moving deformations and topology-preserving morphological deformations, computes exact cubical homology, and stores the sample together with 00 (Hannouch et al., 2024).
The stated hardness metrics are explicitly topological: topological complexity
01
persistence-entropy vectors 02, and minimum nonzero persistence in persistence diagrams (Hannouch et al., 2024). The same specification provides examples such as a 2D genus-03 curve with 04, a 3D two-torus example with 05, and a 4D 06 tube with 07.
This broader usage sharpens an important conceptual distinction. In the graph setting, "topology" refers primarily to graph topology and algorithmic worst cases; in tubular segmentation, it refers to continuity and breakage of curvilinear structures; in topology-guided field generation, it refers to critical-point configurations; and in manifold-data generation, it refers to homology and Betti-number control. The literature therefore uses the label TopoHG heterogeneously. A common misconception would be to treat it as a single standardized model family. The evidence instead supports a narrower claim: TopoHG is a reusable methodological motif for generating structurally difficult or structurally specified samples, with the operative notion of topology determined by domain-specific invariants and failure modes.