Skip to content

tgn.cpp: Documentation

tgn.cpp is a library for large-scale Temporal Graph Learning, built around two components:


1. Temporal Graph Unified Format (TGUF)

A binary, flatbuffer-style on-disc format for graph streams, supporting:

  • Dynamic node and edge events, static node features, pre-computed negatives (for link prediction)
  • Zero-copy tensor reads via memory mapping for out-of-core training and inference
  • Optimized sequential access patterns common in CTDG style methods

Includes a storage engine API for reading TGUF files.

Note: We expose Python bindings for TGUF ingestion so that you can easily convert your own datasets into the binary file format. See the Python API for more details.

See: tguf-spec for more details.

2. High-Performance TGN Implementation

A C++20 Port of TGN over pure LibTorch:

  • Built on the TGUF storage engine
  • Minimal abstractions, with efficient sampling kernels and data loading

Out-of-the box examples

tgn.cpp includes a ready-to-run examples for link prediction and node prediction.

These examples automatically:

  • download and convert TGB datasets into TGUF format
  • run the TGN model end-to-end