Skip to main content

A small networkx-backed library for modelling and querying family trees.

Project description

familyrelations

A small networkx-backed Python library for building, querying, and printing family trees.

Install

pip install familyrelations

Quick start

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

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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

familyrelations-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

familyrelations-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file familyrelations-0.1.0.tar.gz.

File metadata

  • Download URL: familyrelations-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for familyrelations-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c6af286692235721149574e8220e3b699aa96391c30fd4bcbda6d1fa257d01f
MD5 764a447ae36fa4ae305c60b33fe48126
BLAKE2b-256 a72b11c494c82b48aaafd0e29d3225dbdfb93e6f9dc099c852e7f0eb86cca390

See more details on using hashes here.

File details

Details for the file familyrelations-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: familyrelations-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for familyrelations-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9a0908024a6b2f1eee98f4108c660aa02389272fc86f1f448ed22ac85180be6
MD5 c493389929a5459c178b1c6c14b23cf4
BLAKE2b-256 bc8c48855179c0e5632cdd9999da573cae3328584a01ee02a1c438178a86d1c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page