Metadata-Version: 2.4
Name: familyrelations
Version: 0.1.0
Summary: A small networkx-backed library for modelling and querying family trees.
Project-URL: Homepage, https://github.com/Anirudh-097/familyrelations
Project-URL: Issues, https://github.com/Anirudh-097/familyrelations/issues
Author-email: Anirudh S <anirudh2suresh@gmail.com>
License: MIT
License-File: LICENSE
Keywords: family relations,genealogy,graph,networkx
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: networkx>=3.0
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Description-Content-Type: text/markdown

# familyrelations

A small [networkx](https://networkx.org/)-backed Python library for building,
querying, and printing family trees.

## Install

```bash
pip install familyrelations
```

## Quick start

```python
from familyrelations import Human, Network

tree = Network("Stark")

ned = Human("Ned", 45, isFemale=False)
cat = Human("Catelyn", 43, isFemale=True)
robb = Human("Robb", 18, isFemale=False)
sansa = Human("Sansa", 16, isFemale=True)

tree.addSpouse(ned, cat)
tree.addChild(ned, robb)
tree.addChild(ned, sansa)
tree.addChild(cat, robb)
tree.addChild(cat, sansa)
tree.addSibling(robb, sansa)

tree.displayChildren(ned)          # -> Robb, Sansa
tree.displayRelation(robb, ned)    # -> Ned is Robb's father.
print(tree.totalGenerations())     # -> 2
tree.display()                     # ASCII generation printout
```

## Data model

Every relationship is stored as a directed edge on an internal
`networkx.DiGraph`: an edge `(u, v, relation=R)` means "`v` is `u`'s `R`".
Parent/child edges are inverses of each other and are always added as a
pair; spouse and sibling edges are symmetric and also added as a pair. This
lets most query methods simply walk `out_edges` of a single node and read
the `relation` label.

## Development

```bash
uv venv
uv pip install -e ".[dev]"
pytest
```

## License

MIT
