Skip to main content

A lightweight embedded graph compute database for large sparse graph networks.

Project description

TongGraph

TongGraph logo

TongGraph is a lightweight embedded graph compute database for Python applications that need local GraphRAG retrieval, AI memory, agent context graphs, and probabilistic graph reasoning. TongGraph is for applications that want fast local graph structure, persistence, traversal, algorithms, and inference without running a separate database service.

Feature Highlights

  • Property graph model with labels, typed edges, scalar properties, and external IDs.
  • Rust core exposed through a compact Python SDK.
  • Local SQLite persistence with reopen, indexes, snapshots, and compute segment compaction.
  • Traversal and analytics APIs for neighbors, k-hop retrieval, BFS, shortest path, connected components, PageRank, random walks, subgraphs, and batch jobs.
  • Structured path-query DSL plus a provider-neutral natural-language compiler hook.
  • Embedded Cypher compatibility subset for common local CREATE, MATCH, MERGE, and RETURN flows.
  • Probabilistic graph layer with variables, CPDs, factor tables, evidence, active-subgraph belief propagation, posteriors, and traces.
  • Reproducible Python benchmark scripts for graph algorithms and belief propagation.

Getting Started

Use the source tree during development:

git clone https://github.com/bigai-nlco/TongGraph.git
cd TongGraph
uv sync --dev
uv run python scripts/build_python_extension.py

Verify the package:

uv run python -c "from tonggraph import Graph; print(Graph().node_count())"

Create a small graph:

from tonggraph import Graph

graph = Graph()
alice = graph.add_node(
    "alice",
    labels=["Person"],
    properties={"name": "Alice", "active": True},
)
bob = graph.add_node("bob", labels=["Person"], properties={"name": "Bob"})
graph.add_edge(alice, bob, "KNOWS", properties={"weight": 0.8})

print(graph.neighbors(alice))
print(graph.k_hop(alice, 1))

Use local persistence by passing a SQLite path:

graph = Graph("memory.db")
graph.add_node("session:1", labels=["Session"])
graph.compact()

reopened = Graph("memory.db")
print(reopened.node_count())

Run the Python tests and benchmark scripts:

uv run pytest
uv run python scripts/benchmark_algorithms.py --nodes 1000 --degree 4 --repeat 2
uv run python scripts/benchmark_belief_propagation.py --nodes 1000 --degree 4 --repeat 2

Documentation

Development

uv sync --dev
uv run python scripts/build_python_extension.py
uv run pytest
uv run mkdocs build --strict

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tonggraph-0.1.0.tar.gz (304.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tonggraph-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (669.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file tonggraph-0.1.0.tar.gz.

File metadata

  • Download URL: tonggraph-0.1.0.tar.gz
  • Upload date:
  • Size: 304.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tonggraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb0862db468cfcd031b38b8b9458954938f044dcc3c668c470a88ca5e55056ed
MD5 e6d30c84d947825380ac969bd8dd35a8
BLAKE2b-256 06f699f33fb2660ecead9c9843f54ac8be8e81ced8ec6f9f9345a29cf88d5747

See more details on using hashes here.

File details

Details for the file tonggraph-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tonggraph-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 669.1 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tonggraph-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9507adec62c731d6be8dd09f03c9ede6db7782bda5c9c0660787d1443d71de3
MD5 4d52d669a3412adb5ab928511cc1f384
BLAKE2b-256 048351809262e87b9e0452d97e5f280e4f1bab695a20a81e18525b31250565f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page