Skip to main content

Reinforcement Learning for Graph Theory (RLGT)

PyPI Code style: black Imports: isort Check formatting Run tests

Reinforcement Learning for Graph Theory (RLGT) is a modular reinforcement learning (RL) framework designed to support research in extremal graph theory. RLGT aims to systematize and extend previous RL-based approaches for constructing extremal graphs and counterexamples to graph-theoretic conjectures. The framework provides a clean, modular and extensible codebase suitable for future research.

Motivation

Reinforcement learning provides a natural formalism for combinatorial optimization. In this approach, an agent interacts with an environment by iteratively modifying a configuration and receives rewards based on a target objective function. In the context of extremal graph theory, RLGT enables researchers to:

  • construct graphs that maximize or minimize a given invariant;
  • search for counterexamples to conjectured inequalities; and
  • discover structural patterns that suggest new theoretical insights.

RLGT bridges computational efficiency, through vectorized graph operations, with flexibility, by offering multiple environments and RL methods, providing a unified and extensible research tool.

Design Principles

RLGT is implemented in Python and follows a layered, object-oriented design. The framework is organized into three packages:

1. graphs

The graphs package provides a core graph abstraction supporting eight different graph formats. All required conversions between these formats are automatically performed. This package supports:

  • undirected and directed graphs;
  • graphs with or without loops;
  • arbitrarily many edge colors; and
  • batches of graphs for efficient vectorized operations using NumPy.

The graphs package has no internal dependencies and serves as the foundational layer of the framework.

2. environments

The environments package implements RL environments specialized for graph-theoretic problems. It contains nine environments implemented as seven classes and includes auxiliary utilities for deterministic and nondeterministic graph generation. This package depends only on graphs and builds reinforcement learning environments on top of the graph abstractions.

3. agents

The agents package implements RL algorithms using PyTorch. The available methods include:

  • Deep Cross-Entropy;
  • REINFORCE; and
  • Proximal Policy Optimization (PPO).

This package depends on graphs and environments, and requires PyTorch to be installed. However, using this package is optional; users may choose to work only with the graphs and environments packages and provide their own RL methods if desired. The package provides fully encapsulated agent implementations that are decoupled from the environment logic.

Layered Architecture

  • graphs This package has no internal dependencies and serves as the foundational layer of the framework.

  • environments
    This package depends only on graphs and builds reinforcement learning environments on top of the graph abstractions.

  • agents
    This package depends on graphs and environments, and requires PyTorch. Using this package is optional, and it provides fully encapsulated implementations of reinforcement learning algorithms using PyTorch.

Repository Structure

.
├── src/rlgt/
├── tests/
├── docs/
├── examples/
└── applications/
  • src/rlgt contains the full modular implementation of the framework.
  • tests contains the unit tests that enhance the code stability.
  • docs contains the documentation that provides detailed explanations and usage guidelines.
  • examples contains several examples that demonstrate how to define graphs and environments, and train agents.
  • applications contains the applications of this framework to concrete graph theory problems.

Tooling and Code Quality

RLGT emphasizes reproducibility, stability and clean code. The framework uses:

  • Poetry — for dependency management and packaging;
  • Black — for automatic code formatting;
  • isort — for consistent import sorting; and
  • pytest — for unit testing of framework features.

Poetry manages both required and optional dependencies, ensuring a clean and reproducible setup. Black and isort enforce a consistent code style, and pytest guarantees reliability through automated testing.

Installation

The framework can be installed via pip as follows:

pip install rlgt

If you also want to use the agents package, then the additional dependencies need to be installed with:

pip install rlgt[agents]

Documentation

Detailed documentation is available at https://ivan-damnjanovic.github.io/rlgt/.

Citation

If you use RLGT in academic work, please cite the associated paper:

  • I. Damnjanović, U. Milivojević, I. Đorđević and D. Stevanović, RLGT: A reinforcement learning framework for extremal graph theory, 2026, arXiv:2602.17276.

Metadata

Release files for RLGT 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RLGT 1.0.1
File Size Uploaded
rlgt-1.0.1.tar.gz 50.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for RLGT 1.0.1
File Interpreter ABI Platform
rlgt-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 116.5 kB

Release files / rlgt-1.0.1.tar.gz

Download URL rlgt-1.0.1.tar.gz
Size 50.4 kB
Tags Source
SHA-256 checksum
How to use checksums
705d3c6b76055d4f3c89d389cdb397e5ab5c65fab01413ef440d91ea52eaf8ef
BLAKE2b-256 checksum
How to use checksums
dcec87febad243e96ce39826638077bedbe08fbcf8d318ccf0fa4ddc2ff95423
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.3 Windows/10

Release files / rlgt-1.0.1-py3-none-any.whl

Download URL rlgt-1.0.1-py3-none-any.whl
Size 66.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8e868a3c19cdbc84564508be047fc429289d1ff5c7995b51d765792e837f093
BLAKE2b-256 checksum
How to use checksums
4bc28ac4ec043efa1654ea4652965effd4d5f56879367895fd4bfd5c5fc5fa51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.3 Windows/10

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page