Metadata-Version: 2.4
Name: nx-ladybug
Version: 0.1.0
Summary: LadybugDB storage provider for nx-arrow columnar graphs
License-Expression: BSD-3-Clause OR MIT
Project-URL: Homepage, https://github.com/Ladybug-Memory/nx-ladybug
Project-URL: Source Code, https://github.com/Ladybug-Memory/nx-ladybug
Keywords: networks,graph theory,apache arrow,networkx,columnar,ladybugdb
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: nx-arrow>=0.1.0
Requires-Dist: ladybug>=0.20
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# nx-ladybug

LadybugDB storage provider for
[nx-arrow](https://github.com/Ladybug-Memory/nx-arrow) columnar graphs.
`nx-arrow` owns the Arrow-backed graph and the `arrow` NetworkX backend;
this package only adds persistence into
[LadybugDB](https://ladybugdb.com/). Build and analyze graphs with
`nx-arrow` everywhere — the only `nxladybug` import is the persist step.

## Install

```bash
pip install nx-arrow nx-ladybug
```

For development:

```bash
pip install -e ".[test]"
```

## Use

```python
import networkx as nx
from nxladybug import LadybugStorageProvider, persist

g = nx.DiGraph([(0, 1), (1, 2)], backend="arrow")

nx.out_degree_centrality(g, backend="arrow")
list(nx.topological_sort(g, backend="arrow"))
```

## Persist

`persist()` bulk-loads per-type frames through a storage provider — pick
LadybugDB or Parquet:

```python
from nxarrow.parquet import ParquetStorageProvider
from nxladybug import LadybugStorageProvider, persist

# LadybugDB: one unified node table (NxNode) + one relationship table
# (NxEdge) + a meta table (NxMeta). Each frame is registered as an Arrow
# staging table and bulk-copied natively — COPY <table> FROM (MATCH ...) —
# so endpoints resolve through the node primary key inside the copy.
provider = LadybugStorageProvider("graph.lbdb")  # or ":memory:"
persist(g, provider, graph_attrs=g.graph)
restored = provider.load_graph()  # full round-trip

# ... or Parquet: one file per type plus a manifest.json
parquet = ParquetStorageProvider("graph_store")
persist(g, parquet, graph_attrs=g.graph)
restored = parquet.load_graph()
```

The Ladybug provider drops and recreates its tables on every persist, so
re-persisting a smaller graph leaves no stale rows. `:memory:` databases
live as long as the provider; file paths reopen with
`LadybugStorageProvider.load(path)`.

Custom stores implement `store_nodes(frames)` / `store_edges(frames)` and
register with `nxarrow.register_storage_provider`.

## Develop

```bash
pytest
```
