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.0.tar.gz (12.0 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.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: beanone_graph-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 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.0.tar.gz
Algorithm Hash digest
SHA256 11c6d9562cdc7032d1ca8162faf35472583c893804250c1cb11e9eee29f2cde3
MD5 a61d7197651f6a18a1c9af067ab9740f
BLAKE2b-256 9602956a29e5a7e6a93369579a9002c86f56c532153b996d8fb02791db68c4b8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: beanone_graph-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 923b4ef57a6fb9bd45af5c980f8182116e61f286b29c13b363f9906ffbea9cb6
MD5 bf6781a2611dbdbd3cf62485a36b3269
BLAKE2b-256 357bea87194a1781fbc34cbc1cf2198af2d23191278f15848b0641b1c6d3185b

See more details on using hashes here.

Provenance

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