#graph-database #graph #adapter #petgraph #traversal

graph-api-petgraph

Integration between graph-api and petgraph - use graph-api's traversal system with petgraph structures

5 releases

Uses new Rust 2024

new 0.1.4 Apr 13, 2025
0.1.3 Apr 13, 2025
0.1.2 Apr 13, 2025
0.1.1 Apr 13, 2025
0.1.0 Apr 13, 2025

#448 in Data structures

Download history

116 downloads per month

Apache-2.0

230KB
3.5K SLoC

Graph-API PetGraph Adapter

Welcome to graph-api-petgraph — bridging the gap between the popular petgraph crate and the Graph-API ecosystem!

Already using petgraph for your graph data structures? Love its efficiency but wish it had more expressive traversal capabilities? This adapter brings the best of both worlds to your Rust projects!

The Perfect Combination

This crate allows you to keep using petgraph's excellent StableGraph implementation while gaining access to all the intuitive traversal patterns and type-safety features of Graph-API. It's the ideal way to enhance your existing petgraph-based code without rewriting your storage layer.

Simple Integration

With just a few lines of code, unlock powerful new capabilities:

fn main() {
    // Your existing petgraph code
    let mut graph = petgraph::stable_graph::StableGraph::new();
    
    // Add some vertices and edges...
    
    // Now enjoy the rich Graph-API traversal system!
    let people = graph
        .walk()
        .vertices(VertexIndex::person())
        .edges(EdgeIndex::knows().direction(Direction::Outgoing))
        .tail()
        .filter_by_person(|person, _| person.age() > 30)
        .collect::<Vec<_>>();
}

Benefits

  • Keep Your Existing Code: No need to migrate your graph storage
  • Enhance Capabilities: Add expressive traversals to your petgraph applications
  • Type-Safe Operations: Enjoy compile-time checks for your graph operations
  • Performance: Benefit from petgraph's efficient implementation with Graph-API's intuitive interface

Implementation Note

This adapter implements the Graph-API traits for petgraph's StableGraph. Other petgraph graph types are not currently supported due to Rust's orphan rule limitations.

Explore the integration between two powerful graph libraries with graph-api-petgraph!

Learn more in the graph-api book.

Dependencies

~6–18MB
~172K SLoC