Metadata-Version: 2.4
Name: larzgraph
Version: 0.1.0
Summary: Graphs and everyday algorithms (BFS/DFS, Dijkstra, components, topological sort, cycles, SCC) in pure Python. Zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzgraph
Project-URL: Repository, https://github.com/larz-scripter/larzgraph
Project-URL: Documentation, https://github.com/larz-scripter/larzgraph#readme
Project-URL: Issues, https://github.com/larz-scripter/larzgraph/issues
Keywords: graph,graphs,algorithms,dijkstra,bfs,dfs,topological-sort,shortest-path,networkx-alternative,zero-dependency,pure-python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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

```bash
pip install larzgraph
```

## Usage

```python
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

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

## The Larz stack

Pure-Python, zero-dependency building blocks: **[larz](https://github.com/larz-scripter/larz)** · **[larzchain](https://github.com/larz-scripter/larzchain)** · **[larzmoney](https://github.com/larz-scripter/larzmoney)** · **[larzcrypt](https://github.com/larz-scripter/larzcrypt)** · **[larzdb](https://github.com/larz-scripter/larzdb)** · **[larzagent](https://github.com/larz-scripter/larzagent)** · **[larzchart](https://github.com/larz-scripter/larzchart)** · **[larzmark](https://github.com/larz-scripter/larzmark)** · **[larztask](https://github.com/larz-scripter/larztask)** · **[larzvault](https://github.com/larz-scripter/larzvault)** · **[larzvm](https://github.com/larz-scripter/larzvm)** · **[larzcache](https://github.com/larz-scripter/larzcache)** · **[larzvalidate](https://github.com/larz-scripter/larzvalidate)** · **[larzid](https://github.com/larz-scripter/larzid)** · **[larzrpc](https://github.com/larz-scripter/larzrpc)** · **[larzstate](https://github.com/larz-scripter/larzstate)** · **[larzhttp](https://github.com/larz-scripter/larzhttp)** · **[larzconf](https://github.com/larz-scripter/larzconf)** · **[larzcron](https://github.com/larz-scripter/larzcron)** · **[larzlimit](https://github.com/larz-scripter/larzlimit)** · **[larzlog](https://github.com/larz-scripter/larzlog)** · **[larzcli](https://github.com/larz-scripter/larzcli)** · **[larzretry](https://github.com/larz-scripter/larzretry)** · **[larztime](https://github.com/larz-scripter/larztime)** · **[larzpdf](https://github.com/larz-scripter/larzpdf)** · **[larzpack](https://github.com/larz-scripter/larzpack)** · **[larztemplate](https://github.com/larz-scripter/larztemplate)** · **[larzcolor](https://github.com/larz-scripter/larzcolor)** · **[larztable](https://github.com/larz-scripter/larztable)** · **[larzjson](https://github.com/larz-scripter/larzjson)** · **[larzbus](https://github.com/larz-scripter/larzbus)** · **[larzmigrate](https://github.com/larz-scripter/larzmigrate)** · **larzgraph**

## License

MIT © larz-scripter
