| Crates.io | pushout |
| lib.rs | pushout |
| version | 0.1.1 |
| created_at | 2025-08-07 11:28:25.24899+00 |
| updated_at | 2025-08-07 11:28:25.24899+00 |
| description | A graph rewriting library built on petgraph. |
| homepage | https://github.com/Finradon/pushout |
| repository | https://github.com/Finradon/pushout |
| max_upload_size | |
| id | 1785150 |
| size | 52,149 |
A graph rewriting library built on petgraph, providing:
petgraph::GraphCrate: pushout ยท License: Apache-2.0
Pattern Matching (src/algorithms/vf2.rs)
match_subgraphs & has_subgraph via the VF2 algorithmGraph Rewriting (src/transformation/)
apply_once, apply_rules, apply_exhaustiveRuleBuilder for ergonomic rule constructionI/O
load_neo4j_graph(json: &str) to parse Neo4j JSON exportsexport_rule_to_cypher & save_rule_as_cypher for Cypher queriesFuture work: RDF/SPARQL support via optional graphdb feature.
Add to your Cargo.toml:
[dependencies]
pushout = "0.1.1"
petgraph = "0.8.1"
serde = { version = "1.0", features = ["derive"] }
thiserror = "2.0.12"
Then in your code:
use pushout::api::{
match_subgraphs, has_subgraph,
apply_rule, apply_rules,
RuleBuilder,
load_neo4j_graph, export_rule_to_cypher,
};
use petgraph::graph::Graph;
// 1. Load a Neo4j JSON export
let json = std::fs::read_to_string("graph.json")?;
let host: Graph<_, String> = load_neo4j_graph(&json)?;
// 2. Build a DPO rule
let rule = RuleBuilder::new()
.lhs(pattern_graph)
.interface(interface_graph)
.rhs(replacement_graph)
.l2k(l2k_morphism)
.k2r(k2r_morphism)
.build();
// 3. Apply the rule
let result = apply_rule(&host, &rule).unwrap_or(host.clone());
// 4. Export to Cypher
let cy = export_rule_to_cypher(&rule);
std::fs::write("rule.cypher", cy)?;
This project is licensed under Apache License, Version 2.0