Skip to content
DuckDB community extension

petgraph_ext

Graph algorithms for DuckDB — PageRank, shortest path, SCC, MST, and more via petgraph

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL petgraph_ext FROM community;
LOAD petgraph_ext FROM community;

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

SQL
SELECT * FROM petgraph_shortest_path('[(0,1,2.5),(1,2,1.0),(0,2,5.0)]', 0, 2);
-- → [0,1,2]  3.5

Provided by alitrack. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

A DuckDB extension that brings graph algorithms into SQL, powered by the petgraph Rust crate. Run PageRank, betweenness centrality, closeness centrality, eigenvector centrality, SCC, Louvain community detection, topological sort, cycle detection, shortest path, connected components, and MST — no external graph database required.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
alitrack/duckdb_petgraph
License
MIT
Maintainers
alitrack
Written in
Rust
Build source
75aadaf3fc97
Build definition
Community descriptor