Pushout
A graph rewriting library built on petgraph, providing:
- VF2 subgraph isomorphism for pattern matching
- DPO (Double Pushout) algebraic graph rewriting with rule definitions
- Neo4j JSON import into
petgraph::Graph - Cypher export of DPO rules for Neo4j execution
Crate: pushout · License: Apache-2.0
Features
-
Pattern Matching (
src/algorithms/vf2.rs)match_subgraphs&has_subgraphvia the VF2 algorithm
-
Graph Rewriting (
src/transformation/)- Define DPO rules with LHS, Interface (K), RHS graphs
apply_once,apply_rules,apply_exhaustiveRuleBuilderfor ergonomic rule construction
-
I/O
load_neo4j_graph(json: &str)to parse Neo4j JSON exportsexport_rule_to_cypher&save_rule_as_cypherfor Cypher queries
Future work: RDF/SPARQL support via optional graphdb feature.
Getting Started
Add to your Cargo.toml:
[]
= "0.1.1"
= "0.8.1"
= { = "1.0", = ["derive"] }
= "2.0.12"
Then in your code:
use ;
use Graph;
// 1. Load a Neo4j JSON export
let json = read_to_string?;
let host: = load_neo4j_graph?;
// 2. Build a DPO rule
let rule = new
.lhs
.interface
.rhs
.l2k
.k2r
.build;
// 3. Apply the rule
let result = apply_rule.unwrap_or;
// 4. Export to Cypher
let cy = export_rule_to_cypher;
write?;
License
This project is licensed under Apache License, Version 2.0