Skip to main content

Crate graphqlite

Crate graphqlite 

Source
Expand description

GraphQLite - SQLite extension for graph queries using Cypher

This crate provides Rust bindings for GraphQLite, allowing you to use Cypher graph queries in SQLite databases.

§High-Level Graph API

The Graph struct provides an ergonomic interface for common graph operations:

use graphqlite::Graph;

let g = Graph::open(":memory:")?;

// Add nodes
g.upsert_node("alice", [("name", "Alice"), ("age", "30")], "Person")?;
g.upsert_node("bob", [("name", "Bob"), ("age", "25")], "Person")?;

// Add edge
g.upsert_edge("alice", "bob", [("since", "2020")], "KNOWS")?;

// Query
println!("{:?}", g.stats()?);
println!("{:?}", g.get_neighbors("alice")?);

// Graph algorithms
let ranks = g.pagerank(0.85, 20)?;
let communities = g.community_detection(10)?;

§Low-Level Cypher API

The Connection struct provides direct Cypher query access:

use graphqlite::Connection;

let conn = Connection::open(":memory:")?;

// Create nodes
conn.cypher("CREATE (n:Person {name: 'Alice', age: 30})")?;

// Query the graph
let results = conn.cypher("MATCH (n:Person) RETURN n.name, n.age")?;
for row in &results {
    println!("{}: {}", row.get::<String>("n.name")?, row.get::<i64>("n.age")?);
}

Structs§

AStarResult
A* shortest path result.
ApspResult
All pairs shortest path result for a single pair.
BetweennessCentralityResult
Betweenness centrality result for a single node.
BulkInsertResult
Result of a bulk insert operation.
CacheStatus
Cache operation status returned by load/unload/reload operations.
ClosenessCentralityResult
Closeness centrality result for a single node.
CommunityResult
Community detection result for a single node.
ComponentResult
Connected component result for a single node.
Connection
A GraphQLite database connection.
CypherQuery
A builder for constructing and executing parameterized Cypher queries.
CypherResult
Result of a Cypher query, containing zero or more rows.
DegreeCentralityResult
Degree centrality result for a single node.
EigenvectorCentralityResult
Eigenvector centrality result for a single node.
Graph
High-level graph operations.
GraphManager
Manager for multiple graph databases in a directory.
GraphStats
Graph statistics containing node and edge counts.
KnnResult
K-nearest neighbor result.
NodeSimilarityResult
Node similarity result using Jaccard coefficient.
PageRankResult
PageRank result for a single node.
Row
A single row from a Cypher query result.
ShortestPathResult
Shortest path result from Dijkstra’s algorithm.
TraversalResult
Traversal result for BFS/DFS.
TriangleCountResult
Triangle count result for a single node.

Enums§

Error
Error type for GraphQLite operations.
Value
A dynamically-typed value returned from a Cypher query.

Statics§

CYPHER_RESERVED
Cypher reserved keywords that can’t be used as relationship types.

Functions§

escape_string
Escape a string for use in Cypher queries.
format_value
Format a value for inclusion in a Cypher query.
graph
Create a new Graph instance (convenience function).
graphs
Create a new GraphManager instance (convenience function).
sanitize_rel_type
Sanitize a relationship type for use in Cypher.

Type Aliases§

Result
Result type for GraphQLite operations.