Minimal DPO graph rewriting core for graph workflows and graph databases.
- DPO rule representation (
left,interface,right, optionalnac) - JSON import and schema validation
- Application to nx.MultiDiGraph
- Cypher export for graph database execution
Available on PyPI:
pip install dpo-rewritefrom 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)See examples/ for a minimal end-to-end examples.