Skip to main content

DPO graph rewriting core for graph databases.

Project description

dpo-rewrite

Minimal DPO graph rewriting core for graph workflows and graph databases.

Scope

  • DPO rule representation (left, interface, right, optional nac)
  • JSON import and schema validation
  • Application to nx.MultiDiGraph
  • Cypher export for graph database execution

Install

Available on PyPI:

pip install dpo-rewrite

Usage

from dpo_rewrite import load_rule, to_cypher, validate

payload = {
    "left": {
        "nodes": [{"id": "a", "label": "Node", "props": {"id": "A"}}],
        "edges": [],
    },
    "interface": {
        "nodes": [{"id": "a", "label": "Node", "props": {"id": "A"}}],
        "edges": [],
    },
    "right": {
        "nodes": [
            {"id": "a", "label": "Node", "props": {"id": "A"}},
            {"id": "b", "label": "Node", "props": {"id": "B"}},
        ],
        "edges": [{"source": "a", "target": "b", "type": "LINKS_TO"}],
    },
}

validate(payload)
rule = load_rule(payload)
cypher = to_cypher(rule)
print(cypher.query)
print(cypher.params)

Sample Script

See examples/ for a minimal end-to-end examples.

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

dpo_rewrite-0.1.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

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

dpo_rewrite-0.1.3-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file dpo_rewrite-0.1.3.tar.gz.

File metadata

  • Download URL: dpo_rewrite-0.1.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dpo_rewrite-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d468ffba643eed0c214c496e3e3b3f36653189b6a3b62e18cbb7e1115d2e5b77
MD5 bd068082c291f50fe11a862c8ac8961b
BLAKE2b-256 91324fd94bdcc7ec0c3e2595ca86cf9dd92e2f110844287a57d5d95328176f08

See more details on using hashes here.

File details

Details for the file dpo_rewrite-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dpo_rewrite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dpo_rewrite-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 04a9da8f0df41d10bdbdac0a7ab0d4cfa27f75e3fd2f616440ae269a03765eb6
MD5 1cb8a149540e4e09ec4050b89a8c2a0b
BLAKE2b-256 32ebd0651dde924820f444aecf3686de877ceb4c3c42f6600d893e09eb48a822

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