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.1.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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: beanone_graph-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 abe3ef3e565f79056f3d9b2d3cce4ec8d81de7732545f6d7da9e22308e353b06
MD5 f5ea8562f19cef57e0356d6e3cb6313d
BLAKE2b-256 3c2200014de4a51d59c6fa5f5d1944398578af1d4549b445dc92cca43e984625

See more details on using hashes here.

Provenance

The following attestation bundles were made for beanone_graph-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: beanone_graph-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 545c1f8b0117ee0904e07496408f4c8613ae26d9701fd767de08cb86751d1bd1
MD5 c5ad12d0132c222516cfa2bf3e3dce4f
BLAKE2b-256 d8b5ff1e8cec88df1dc9d231c12810d07cfce951668bb9143c12f8886635163f

See more details on using hashes here.

Provenance

The following attestation bundles were made for beanone_graph-0.1.1-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