Metadata-Version: 2.4
Name: graphette
Version: 0.1.0
Summary: Step-by-step graph algorithm visualization with NetworkX and Matplotlib
Project-URL: Homepage, https://github.com/pzarczynski/graphette
Project-URL: Documentation, https://github.com/pzarczynski/graphette#readme
Project-URL: Repository, https://github.com/pzarczynski/graphette.git
Project-URL: Issues, https://github.com/pzarczynski/graphette/issues
Author-email: Piotr Żarczyński <piotr.zarczynski.06@gmail.com>
License: MIT
License-File: LICENSE
Keywords: algorithm,graph,matplotlib,networkx,visualization
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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 :: Visualization
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: networkx>=3.0
Requires-Dist: toolz>=0.10.0
Provides-Extra: dev
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# Graph Algorithm Visualizer

Step-by-step graph algorithm visualization with NetworkX and Matplotlib.

![BFS Example](bfs.gif)

## Usage

```bash
pip install -r requirements.txt
python visualize.py  # run included BFS example
```

## Custom Algorithms

To make a custom visualization, create a generator that yields `snapshot()` at each step:

```python
from algo import snapshot, adjacency
from visualize import visualize, animate


def dfs(edges, start):
    adj = adjacency(edges)
    stack, visited, step = [start], set(), 0

    while stack:
        cur = stack.pop()
        if cur in visited: continue
        visited.add(cur)
        step += 1

        yield snapshot(step, edges=edges, event="visit",
                       state={'visited': list(visited)},
                       node_color={'orange': ('current', cur)},
                       nodes_color={'lightgreen': ('visited', visited)})

        stack.extend(n for n in adj[cur] if n not in visited)


states = dfs(edges, 'A')
visualize(states)  # interactive (← → to navigate)
animate(states, 'out.gif')  # supports all matplotlib.animation formats
```

### Snapshot Parameters

| Parameter | Description |
|-----------|-------------|
| `step`, `event` | Step number and label |
| `nodes`, `edges` | Current state of the graph |
| `state` | Algorithm state dict to display |
| `node_color` | `{color: (label, node)}` |
| `nodes_color` | `{color: (label, node_set)}` |
| `edges_color` | `{color: (label, edge_set)}` |

## Requirements

`matplotlib`, `networkx`, `toolz`
