Skip to main content

larzgraph

Graphs and the everyday algorithms. Pure Python, zero dependencies.

The useful 90% of a graph library, tiny: build a directed or undirected weighted graph and run traversal, shortest paths, connectivity, ordering, and cycle detection — no networkx, no numpy, nothing to install.

from larzgraph import Graph, DiGraph

g = Graph()
g.add_edge("a", "b"); g.add_edge("b", "c", weight=2)
g.shortest_path("a", "c")          # (['a', 'b', 'c'], 3)
g.connected_components()

dag = DiGraph()
dag.add_edges([("build", "test"), ("test", "deploy")])
dag.topological_sort()             # ['build', 'test', 'deploy']
dag.has_cycle()                    # False

Why

  • The algorithms you actually use — BFS, DFS, Dijkstra shortest paths, connected components, topological sort, cycle detection, and strongly-connected components (Tarjan) — without importing a scientific stack.
  • Directed and undirected, weighted, with a clean small API.
  • Deterministic — traversal and topological order break ties in sorted order, so results are reproducible and testable.
  • Zero dependencies. Great for build-order resolution, dependency graphs, routing, task scheduling, and teaching — anywhere networkx is overkill.

Install

pip install larzgraph

Usage

from larzgraph import Graph, DiGraph

g = Graph()                              # undirected
g.add_edges([("a", "b"), ("b", "c", 4)]) # weight optional (default 1)
g.neighbors("b"); g.degree("b"); g.weight("b", "c")

g.bfs("a"); g.dfs("a")                   # traversal order
g.has_path("a", "c")
g.shortest_path("a", "c")                # (path, distance) via Dijkstra
g.connected_components(); g.is_connected()
g.has_cycle()

d = DiGraph()                            # directed
d.add_edges([("a", "b"), ("b", "c"), ("c", "a")])
d.topological_sort()                     # raises CycleError here
d.has_cycle(); d.is_dag()
d.strongly_connected_components()        # [['a', 'b', 'c']]
d.weakly_connected_components()

Tests

python -m unittest discover -s tests -v   # 24 tests, zero deps

The Larz stack

Pure-Python, zero-dependency building blocks: larz · larzchain · larzmoney · larzcrypt · larzdb · larzagent · larzchart · larzmark · larztask · larzvault · larzvm · larzcache · larzvalidate · larzid · larzrpc · larzstate · larzhttp · larzconf · larzcron · larzlimit · larzlog · larzcli · larzretry · larztime · larzpdf · larzpack · larztemplate · larzcolor · larztable · larzjson · larzbus · larzmigrate · larzgraph

License

MIT © larz-scripter

Metadata

Release files for larzgraph 0.1.0

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

Source distribution (sdist)

Source distribution for larzgraph 0.1.0
File Size Uploaded Provenance
larzgraph-0.1.0.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.2 kB

Release files / larzgraph-0.1.0.tar.gz

Download URL larzgraph-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2d9c655188e3236b2ef341aac2427999987eb5db841d581b09aec37ce6667c27
BLAKE2b-256 checksum
How to use checksums
28c09d4f54dc894e65ee4352c1276fa268c7d6b55165bcd54eaaed70775c93dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzgraph-0.1.0-py3-none-any.whl

Download URL larzgraph-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2bcd58978bb8a582bc0c46a922f45756ad8ae9aa5b5d617e40bf7674f4de320
BLAKE2b-256 checksum
How to use checksums
e64384cefad7d892c5415db0065660f408cd1a15fa15430c06bfd3399b523488
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzgraph 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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