Skip to main content

Crate petgraph_decypher

Crate petgraph_decypher 

Source
Expand description

petgraph-decypher – build petgraph graphs from OpenCypher queries.

§Overview

This crate provides three main entry points:

§Supported Cypher subset

FeatureStatus
CREATE (n:Label {k: v})-[:TYPE]->(m)✅ materialised + executed
MERGE (n:Label {k: v})-[:TYPE]->(m)✅ materialised + executed
MATCH (n)-[r]->(m) WHERE n.p = v✅ evaluated
RETURN n, n.prop AS alias / RETURN *✅ evaluated
[DETACH] DELETE n✅ executed
Multiple clauses in one query
Semicolon-separated statements

§Example

use petgraph_decypher::build_graph_from_cypher;

let graph = build_graph_from_cypher(
    r#"CREATE (a:Person {name: "Alice"})-[:KNOWS]->(b:Person {name: "Bob"})"#,
)
.unwrap();

assert_eq!(graph.node_count(), 2);
assert_eq!(graph.edge_count(), 1);

Re-exports§

pub use ast::BinaryOp;
pub use ast::CaseExpr;
pub use ast::Clause;
pub use ast::CypherQuery;
pub use ast::CypherValue;
pub use ast::Expression;
pub use ast::NodePattern;
pub use ast::PathPattern;
pub use ast::RelDirection;
pub use ast::RelPattern;
pub use ast::RelationshipLength;
pub use ast::ReturnItem;
pub use ast::SetItem;
pub use ast::SortDirection;
pub use ast::SortItem;
pub use ast::UnaryOp;
pub use ast::WhereExpr;
pub use error::CypherError;
pub use query::MatchStrategy;
pub use query::Parameters;
pub use query::PetgraphCypher;
pub use query::QueryResult;
pub use query::ResultValue;
pub use query::Row;

Modules§

ast
Abstract Syntax Tree types for OpenCypher queries.
error
Error types for petgraph-decypher.
query
Query execution engine for running Cypher queries against a petgraph.

Structs§

EdgeData
Data stored at each edge in the graph built by build_graph_from_cypher.
NodeData
Data stored at each node in the graph built by build_graph_from_cypher.

Traits§

CypherEdge
Metadata required from edge weights during Cypher planning and execution.
CypherNode
Metadata required from node weights during Cypher planning and execution.
CypherProperties
Common property access used by the query planner and executor.

Functions§

build_graph_from_cypher
Parse a Cypher query and build a petgraph Graph from its CREATE and MERGE clauses.
build_graph_from_cypher_typed
Parse a Cypher query and build a petgraph Graph from its CREATE and MERGE clauses using custom node and edge types.
parse_cypher
Parse a Cypher query string and return its HIR-backed query plan representation.