Onager is a DuckDB extension that adds a large number of graph analytics functions to DuckDB, including centrality measures, community detection algorithms, pathfinding algorithms, graph metrics, and graph generators. Onager is written in Rust and uses Graphina graph library under the hood.
Compared to DuckPGQ, Onager is focused on graph analytics instead of graph querying. More specifically, DuckPGQ tries to implement SQL/PGQ (the SQL:2023 standard) for graph pattern matching and path-finding queries with a property graph model. Onager instead provides a collection of ready-to-use graph algorithms (like PageRank, Louvain community detection, Dijkstra's shortest path, etc.) as simple table functions. Users typically want something like DuckPGQ when they need to query graph patterns or model the data in a property graph model (like a graph database), and use Onager when they need to run specific graph algorithms on their graph data for a specific application.
- Adds over 40 graph algorithms as SQL table functions
- Provides a simple and uniform API
- Supports both directed and undirected graphs
- Supports weighted and unweighted edges
- Includes multi-threaded algorithm implementations
See ROADMAP.md for the list of implemented and planned features.
Important
Onager is in early development, so bugs and breaking changes are expected. Please use the issues page to report bugs or request features.
You can install and load Onager from the DuckDB community extensions repository by running the following SQL commands in the DuckDB shell:
install onager from community;
load onager;Alternatively, you can build Onager from source and use it by following these steps:
- Clone the repository and build the Onager extension from source:
git clone --recursive https://github.com/CogitatorTech/onager.git
cd onager
# This might take a while to run
make release- Start DuckDB shell (with Onager statically linked to it):
./build/release/duckdbNote
After building from source, the Onager binary will be build/release/extension/onager/onager.duckdb_extension.
You can load it using the load 'build/release/extension/onager/onager.duckdb_extension'; in the DuckDB shell.
Note that the extension binary will only work with the DuckDB version that it was built against.
You can download the pre-built binaries from the releases page for
your platform.
-- Create an edge table
create table edges as
select * from
(values (1::bigint, 2::bigint),
(2, 3),
(3, 1),
(3, 4)) t(src, dst);
-- Compute PageRank
select * from onager_ctr_pagerank((select src, dst from edges));
-- Detect communities
select * from onager_cmm_louvain((select src, dst from edges));
-- Find shortest paths
select * from onager_pth_dijkstra((select src, dst from edges), source := 1);
-- Generate a random graph
select * from onager_gen_erdos_renyi(100, 0.1, seed := 42);Check out the Onager documentation for the API documentation and examples.
See CONTRIBUTING.md for details on how to make a contribution.
Onager is available under either of the following licenses:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)