--- warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github.com/duckdb/community-extensions repository, check README there title: petgraph_ext excerpt: | DuckDB Community Extensions Graph algorithms for DuckDB — PageRank, shortest path, SCC, MST, and more via petgraph extension: name: petgraph_ext description: Graph algorithms for DuckDB — PageRank, shortest path, SCC, MST, and more via petgraph version: 0.5.0 language: Rust build: cargo license: MIT excluded_platforms: "wasm_mvp;wasm_eh;wasm_threads;linux_amd64_musl;windows_amd64_rtools;windows_amd64_mingw" requires_toolchains: "rust" maintainers: - alitrack repo: github: alitrack/duckdb_petgraph ref: 75aadaf3fc97f55f41baf46fb045c0a5160c3650 ref_next: 75aadaf3fc97f55f41baf46fb045c0a5160c3650 docs: hello_world: | INSTALL petgraph_ext FROM community; LOAD petgraph_ext; SELECT * FROM petgraph_shortest_path('[(0,1,2.5),(1,2,1.0),(0,2,5.0)]', 0, 2); -- → [0,1,2] 3.5 extended_description: | ## duckdb_petgraph A DuckDB extension that brings graph algorithms into SQL, powered by the [petgraph](https://github.com/petgraph/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. ### Features - **17 table functions**: build_graph, list_graphs, drop_graph, edges, neighbors, shortest_path, connected_components, pagerank, betweenness_centrality, closeness_centrality, eigenvector_centrality, scc, mst, louvain, toposort, is_cyclic - **Named graph cache**: build once with `petgraph_build_graph('name', ...)` and reference with `@name` for zero-reparse repeated queries - **Multi-batch streaming**: all multi-row functions stream results across scan calls — no artificial 2048-row ceiling - **Edge format**: `[(src,dst,weight),...]` string syntax, usable inline or built from DuckDB tables via `string_agg` ### Algorithms | Function | Description | |---|---| | `petgraph_shortest_path` | A\* shortest path with path reconstruction | | `petgraph_connected_components` | DFS component labeling (undirected) | | `petgraph_pagerank` | PageRank with configurable alpha/iterations | | `petgraph_betweenness_centrality` | Brandes' algorithm (undirected) | | `petgraph_closeness_centrality` | BFS-based closeness (directed) | | `petgraph_eigenvector_centrality` | Power-iteration eigenvector | | `petgraph_scc` | Tarjan's strongly connected components | | `petgraph_louvain` | Louvain community detection | | `petgraph_toposort` | Kahn's topological sort | | `petgraph_is_cyclic` | Directed cycle detection | | `petgraph_mst` | Kruskal's minimum spanning tree | ### Limitations - Graphs must fit in memory (no disk-backed storage) - Louvain is a simplified greedy pass with 20 iterations — useful for quick community detection but not a full implementation - Edge weights are f64 only - Node IDs are i32 extension_star_count: 6 extension_star_count_pretty: 6 extension_download_count: 1169 extension_download_count_pretty: 1.2k image: '/images/community_extensions/social_preview/preview_community_extension_petgraph_ext.png' layout: community_extension_doc --- ### Compatibility Matrix This table covers all DuckDB releases that have not reached [end-of-life](https://duckdb.org/release_calendar), including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 | | :--- | :---: | :---: | :---: | :---: | :---: | | Linux AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Linux ARM64 | ❌ | ❌ | ✅ | ✅ | ✅ | | macOS AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | macOS ARM64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Windows AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Windows ARM64 | ❌ | ❌ | ❌ | ❌ | ❌ | | WebAssembly | ❌ | ❌ | ❌ | ❌ | ❌ | ### Installing and Loading ```sql INSTALL {{ page.extension.name }} FROM community; LOAD {{ page.extension.name }}; ``` {% if page.docs.hello_world %} ### Example ```sql {{ page.docs.hello_world }}``` {% endif %} {% if page.docs.extended_description %} ### About {{ page.extension.name }} {{ page.docs.extended_description }} {% endif %} ### Added Functions | function_name | function_type | description | comment | examples | |---------------------------------|---------------|-------------|---------|----------| | petgraph_betweenness_centrality | table | NULL | NULL | | | petgraph_build_graph | table | NULL | NULL | | | petgraph_build_graph_list | table | NULL | NULL | | | petgraph_closeness_centrality | table | NULL | NULL | | | petgraph_connected_components | table | NULL | NULL | | | petgraph_drop_graph | table | NULL | NULL | | | petgraph_edges | table | NULL | NULL | | | petgraph_eigenvector_centrality | table | NULL | NULL | | | petgraph_is_cyclic | table | NULL | NULL | | | petgraph_list_graphs | table | NULL | NULL | | | petgraph_louvain | table | NULL | NULL | | | petgraph_mst | table | NULL | NULL | | | petgraph_neighbors | table | NULL | NULL | | | petgraph_pagerank | table | NULL | NULL | | | petgraph_scc | table | NULL | NULL | | | petgraph_shortest_path | table | NULL | NULL | | | petgraph_toposort | table | NULL | NULL | | ### Overloaded Functions This extension does not add any function overloads. ### Added Types This extension does not add any types. ### Added Settings | name | description | input_type | scope | aliases | typed_value | |----------------|---------------------------------------------------------|------------|--------|---------|-------------| | temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |