Crates.io | graph-api-simplegraph |
lib.rs | graph-api-simplegraph |
version | |
source | src |
created_at | 2025-04-12 22:42:27.070282+00 |
updated_at | 2025-04-21 17:22:20.854515+00 |
description | A simple, efficient graph implementation for the graph-api ecosystem with support for indexing |
homepage | |
repository | https://github.com/BrynCooke/graph-api |
max_upload_size | |
id | 1631327 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
SimpleGraph
is the reference implementation for the Graph API, designed primarily to showcase and test the full
capabilities of the API, including comprehensive indexing support for property graphs. While functional, it's not
optimized for high performance.
SimpleGraph
is a custom in-memory graph implementation built specifically to demonstrate and validate all Graph API
features, including every type of index. It serves as a clear example for developers implementing the Graph API traits
and is invaluable for testing Graph API consumers against a fully compliant backend. It handles property graph use cases
where elements have labels (enum variants) and indexed properties.
use graph_api_simplegraph::SimpleGraph;
use graph_api_derive::{VertexExt, EdgeExt};
use graph_api_lib::Graph;
// Define vertex and edge types
#[derive(Debug, Clone, VertexExt)]
pub enum Vertex {
Person {
#[index(hash)]
name: String,
#[index(range)]
age: u64,
},
Project {
name: String
},
}
#[derive(Debug, Clone, EdgeExt)]
pub enum Edge {
Knows { since: i32 },
Created,
}
// Create a new graph
let mut graph = SimpleGraph::new();
// Use the graph
let alice = graph.add_vertex(Vertex::Person {
name: "Alice".to_string(),
age: 30
});
let project = graph.add_vertex(Vertex::Project {
name: "Graph API".to_string()
});
graph.add_edge(alice, project, Edge::Created);
SimpleGraph
uses a custom data structure designed specifically for property graphs:
Vertex Storage: Vertices are stored in collections grouped by label (enum variant), allowing for efficient label-based filtering.
Edge Storage: Edges are stored with both head and tail connections, enabling fast traversal in both directions.
Indexes: Multiple index types are implemented to support different query patterns:
Adjacency Lists: Each vertex maintains an adjacency list for fast edge traversal.
SimpleGraph
supports all Graph API features:
SimpleGraph
is primarily designed for feature completeness and ease of understanding, not for high performance:
SimpleGraph
is ideal for:
While SimpleGraph
is a robust implementation, it has some limitations:
Learn more in the graph-api book.