MCPcopy Index your code
hub / github.com/SuperKevinZhou/hpdg

github.com/SuperKevinZhou/hpdg @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
431 symbols 881 edges 21 files 274 documented · 64% updated 3mo agov0.1.0 · 2026-03-30★ 3491 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

hpdg

hpdg (High-Performance Data Generator) is a Rust-first data generator for competitive programming and OI workflows.

The project is inspired by Luogu's CYaRon, but it leans into Rust's strengths instead of cloning the Python API one-to-one: strong typing, trait-based extension points, feature flags, reproducible RNG streams, and better composition for larger generators.

Status

hpdg is under active development, but it is no longer just a skeleton:

  • The crate is now published on crates.io as hpdg.
  • The crate compiles across library, examples, benches, and tests.
  • Core generator modules are implemented and usable today.
  • The public API is still evolving, so breaking changes are possible before 1.0.
  • Python/C binding scaffolding exists, but the Rust crate is the primary supported surface right now.

What Works Today

Area Current support
IO / testcase helpers In-memory buffers, configurable file naming, separators/formatters, flush to disk, output generation via external programs, timeout helpers, parallel generation, streaming writers, batch builders
Graph Edge, SwitchGraph, editable Graph, graph formatting, label/edge shuffling, chain/flower/tree/binary tree generators, simple graph/multigraph/connected graph/forest/DAG helpers, degree-sequence constructors, adjacency-list and matrix export, GraphMatrix, Merger, hack-SPFA generator
Math Permutation/palindrome helpers, divisor and digit utilities, Fibonacci, primality + Miller-Rabin, factorization, permutation/binomial/Catalan helpers, sieve, exgcd, modular inverse, phi, miu, base conversion, number-to-words
Sequence Formula-driven Sequence, initial-value bootstrapping, range/slice helpers, arithmetic and geometric helpers
Vector Random integer vectors, unique/repeatable modes, random float vectors, matrix helpers, formatting helpers
String Random strings/words/sentences/paragraphs, simplified regex-based generation, dictionary-based generation, ASCII/Unicode modes
Polygon Random points, simple polygons, convex hulls, perimeter/area helpers
Query Random range queries, mixed update/query streams, per-dimension constraints, weighted query generation
Compare File/string/program comparison, custom graders, whitespace-insensitive grader, parallel compare helpers
Rust-specific extras NodeId/EdgeId newtypes, Weight trait, seeded RNG streams, Generator / GraphGenerator traits, shared error types

What Is Still Rough

These parts exist, but they are still early and should be treated as unstable:

  • Crate-level documentation and docs.rs polish are still in progress.
  • Some modules have broad functionality but still need API cleanup and more examples.
  • Python bindings and the C ABI are scaffolding-level rather than polished releases.
  • Full CYaRon parity is not the goal; some APIs will stay intentionally more Rust-idiomatic.

Quick Example

use hpdg::graph::Graph;
use hpdg::io::IO;
use hpdg::string::{SentenceConfig, StringGen};
use hpdg::vector::{IntRange, Vector};

fn main() {
    let mut io = IO::new("example".to_string());

    let mut g = Graph::new(5, false);
    g.add_edge(1, 2, None);
    g.add_edge(2, 3, None);

    let vecs = Vector::random_int(3, &[IntRange::Max(10), IntRange::MinMax(5, 8)]);

    let mut cfg = SentenceConfig::default();
    cfg.sentence_terminators = ".".to_string();
    let sentence = StringGen::random_sentence(6, Some(&cfg));

    io.input_writeln("5 2");
    io.input_writeln(format!("{}", g));
    io.input_writeln(vecs.len());
    for v in vecs {
        io.input_writeln(v.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(" "));
    }
    io.input_writeln(sentence);

    let _ = io.flush_to_disk();
}

See also:

  • examples/full_generation.rs
  • docs/rust-quickstart.md
  • docs/cyaron-api.md

Installation

Install from crates.io:

[dependencies]
hpdg = "0.1.0"

You can also browse the published package and API docs here:

If you need unreleased changes, you can still depend on the Git repository directly:

[dependencies]
hpdg = { git = "https://github.com/SuperKevinZhou/hpdg" }

Feature Flags

Most generator modules are enabled by default.

Optional integration flags currently include:

  • python-bindings
  • c-bindings

The remaining feature flags mostly mirror internal module boundaries such as io, graph, math, sequence, vector, string, polygon, query, compare, utils, core, rng, traits, and error.

Project Direction

The long-term goal is to make hpdg a practical Rust alternative to CYaRon for serious OI data generation:

  • Keep common workflows concise.
  • Prefer deterministic, reproducible generation.
  • Provide stronger invariants through types and traits.
  • Add Rust-specific building blocks instead of only mirroring Python behavior.

Issues and PRs are welcome.

License

MIT

Extension points exported contracts — how you extend this code

IntLike (Interface)
Marker trait implemented for integer primitives. [10 implementers]
src/utils.rs
Grader (Interface)
Custom output grader interface. [2 implementers]
src/compare.rs
GraphGenerator (Interface)
A specialized trait for graph generators. Closures returning [`crate::graph::Graph`] automatically implement this trait [1 …
src/traits.rs
Formatter (Interface)
Testcase I/O buffers, file naming, process execution, and streaming output. This module is the glue layer for many `hpd [1 …
src/io.rs
Weight (Interface)
Marker trait for values that can act as edge weights. This is primarily useful when building generic generator layers o [1 …
src/core.rs
ListLike (Interface)
Marker trait implemented for slice-like collection types. [3 implementers]
src/utils.rs
Generator (Interface)
Traits for building reusable generators on top of `hpdg`. The traits in this module are intentionally lightweight: they
src/traits.rs
StreamingWriter (Interface)
Streaming writer interface for incremental output. [1 implementers]
src/io.rs

Core symbols most depended-on inside this repo

len
called by 89
src/query.rs
to_string
called by 66
src/graph.rs
iter
called by 45
src/graph.rs
add_edge
called by 40
src/graph.rs
insert
called by 21
src/graph.rs
is_empty
called by 21
src/query.rs
join
called by 20
src/io.rs
rebuild_filenames
called by 13
src/io.rs

Shape

Method 235
Function 145
Class 30
Enum 13
Interface 8

Languages

Rust100%

Modules by API surface

src/graph.rs105 symbols
src/io.rs92 symbols
src/math.rs71 symbols
src/string.rs25 symbols
src/query.rs25 symbols
src/vector.rs23 symbols
src/compare.rs19 symbols
src/sequence.rs17 symbols
src/utils.rs16 symbols
src/polygon.rs15 symbols
src/rng.rs9 symbols
src/traits.rs4 symbols

For agents

$ claude mcp add hpdg \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page