Skip to main content

A lightweight, type-safe library for building, managing, and visualizing dependency graphs.

Project description

graphable

CI License: MIT

graphable is a lightweight, type-safe Python library for building, managing, and visualizing dependency graphs. It provides a simple API for defining nodes and their relationships, performing topological sorts, and exporting graphs to various formats like Mermaid and ASCII text trees.

Features

  • Type-Safe: Built with modern Python generics and type hints.
  • Topological Sorting: Easily get nodes in dependency order.
  • Filtering & Tagging: Create subgraphs based on custom predicates or tags.
  • Visualizations:
    • Mermaid: Generate flowchart definitions or export directly to SVG.
    • Text Tree: Generate beautiful ASCII tree representations.
  • Modern Tooling: Managed with uv and just.

Installation

uv add graphable
# or
pip install graphable

Quick Start

from graphable.graph import Graph
from graphable.graphable import Graphable
from graphable.views.texttree import create_topology_tree_txt

# 1. Define your nodes
a = Graphable("Database")
b = Graphable("API Service")
c = Graphable("Web Frontend")

# 2. Build the graph
g = Graph()
g.add_edge(a, b)  # API Service depends on Database
g.add_edge(b, c)  # Web Frontend depends on API Service

# 3. Get topological order
for node in g.topological_order():
    print(node.reference)
# Output: Database, API Service, Web Frontend

# 4. Visualize as a text tree
print(create_topology_tree_txt(g))
# Output:
# Web Frontend
# └─ API Service
#    └─ Database

Visualizing with Mermaid

from graphable.views.mermaid import create_topology_mermaid_mmd

mmd = create_topology_mermaid_mmd(g)
print(mmd)
# Output:
# flowchart TD
# Database --> API Service
# API Service --> Web Frontend

Documentation

Full documentation is available in the docs/ directory. You can build it locally:

just docs-view

Development

This project uses uv for dependency management and just as a command runner.

just install    # Install dependencies
just check      # Run linting, type checking, and tests
just coverage   # Run tests with coverage report

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

graphable-0.2.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

graphable-0.2.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file graphable-0.2.1.tar.gz.

File metadata

  • Download URL: graphable-0.2.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphable-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f759ae030389bed1093af449629441c8bf5d6a12d99478031f82eb6c3c26d7f4
MD5 4fb9885d66154a8eb0c830e6b8d7ae8d
BLAKE2b-256 b2c6dc0eb7429594d9d2dfd520815ed2404d75a78ef82cb31ffab9f35689f74a

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphable-0.2.1.tar.gz:

Publisher: publish.yml on TheTrueSCU/graphable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphable-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: graphable-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphable-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c07a2c8df28aa2f9f179487e8c55eddb8c82e2335f47ef82a8033b78ce2eef1d
MD5 8353769584857a70b83a93681e45ea73
BLAKE2b-256 6bdfb9f86beabdbbe937900b85620c73060594ff24ae860e2e902c0606725d39

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphable-0.2.1-py3-none-any.whl:

Publisher: publish.yml on TheTrueSCU/graphable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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