Skip to main content

Graph generation and storage library with update tracking

Project description

Graph Context Banner

This library enables fast graph traversal and lookup from file-based storage with sharded and indexed structure. Now includes community exploration.

Python Versions License: MIT Tests Coverage Code Quality PyPI version

Features

  • Efficient reading of graph data from JSONL files
  • Support for multiple indexing strategies (SQLite and Memory)
  • Entity caching for improved performance
  • Adjacency list-based neighbor lookup
  • Property-based entity search
  • Community lookup
  • Configurable cache size

Architecture

The library is organized into the following components:

Core Components

  • GraphReader: Main class for reading and querying graph data
  • GraphReaderConfig: Configuration class for customizing reader behavior

Indexers

The library supports multiple indexing strategies through a plugin architecture:

  • BaseIndexer: Abstract base class for indexers
  • SQLiteIndexer: SQLite-based indexing for persistent storage
  • MemoryIndexer: In-memory indexing for faster access

Data Structure

The library expects data to be organized in the following directory structure:

base_dir/
├── entities/
│   └── shard_*.jsonl
├── relations/
│   └── shard_*.jsonl
└── adjacency/
    └── adjacency.jsonl

Architecture Diagram

graph TD
    GR[GraphReader]
    GC[GraphReaderConfig]
    BI[BaseIndexer]
    SI[SQLiteIndexer]
    MI[MemoryIndexer]
    EF[Entity Files]
    RF[Relation Files]
    AF[Adjacency File]
    DB[(SQLite DB)]

    GR --> GC
    GR --> BI
    SI --> BI
    MI --> BI
    GR --> EF
    GR --> RF
    GR --> AF
    SI --> DB

    style GR fill:#e6f3ff,stroke:#000000,stroke-width:2px,color:#000000
    style GC fill:#e6f3ff,stroke:#000000,stroke-width:2px,color:#000000
    style BI fill:#fff2e6,stroke:#000000,stroke-width:2px,color:#000000
    style SI fill:#fff2e6,stroke:#000000,stroke-width:2px,color:#000000
    style MI fill:#fff2e6,stroke:#000000,stroke-width:2px,color:#000000
    style EF fill:#f0fff0,stroke:#000000,stroke-width:2px,color:#000000
    style RF fill:#f0fff0,stroke:#000000,stroke-width:2px,color:#000000
    style AF fill:#f0fff0,stroke:#000000,stroke-width:2px,color:#000000
    style DB fill:#f0fff0,stroke:#000000,stroke-width:2px,color:#000000

Installation

pip install beanone-graph

Usage

from graph_reader import GraphReader, GraphReaderConfig

config = GraphReaderConfig(base_dir="graph_output")
reader = GraphReader(config)

# Get an entity
entity = reader.get_entity(1)
print("Entity:", entity)

# Get neighbors
neighbors = reader.get_neighbors(1)
print("Neighbors:", neighbors)

# Search
matches = reader.search_by_property("name", "Alice")
print("Matches:", matches)

# Get entity's community
community = reader.get_entity_community(1)
print("Community:", community)

# Get members of a community
members = reader.get_community_members("team_alpha")
print("Members:", members)

Configuration

The GraphReaderConfig class supports the following parameters:

  • base_dir: Base directory containing the graph data
  • indexer_type: Type of indexer to use ("sqlite" or "memory")
  • cache_size: Maximum number of entities to cache in memory

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

beanone_graph-0.1.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

beanone_graph-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file beanone_graph-0.1.2.tar.gz.

File metadata

  • Download URL: beanone_graph-0.1.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for beanone_graph-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e9720542645b76af78225f8fe81ceedbd508cb1ce77d14d845b8fbbbf54547fb
MD5 c55ea159cda136fdb4d699d1f3316764
BLAKE2b-256 9b17650dcf43235987bf8de064e355aa5789db33da7a138ffe6a7a9dce1d7776

See more details on using hashes here.

Provenance

The following attestation bundles were made for beanone_graph-0.1.2.tar.gz:

Publisher: publish.yml on beanone/graph_reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file beanone_graph-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: beanone_graph-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for beanone_graph-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16ff2ac3d6fb37c33c54d92661f715ca475d7404cbff0423f793961b8128ef99
MD5 612beacbe9e6e5ba8041889614c529c1
BLAKE2b-256 92118b316fabdd6a26441d87a68b97a7778ff1edcd3adb8d44f327408defa46d

See more details on using hashes here.

Provenance

The following attestation bundles were made for beanone_graph-0.1.2-py3-none-any.whl:

Publisher: publish.yml on beanone/graph_reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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