petgraph's default branch is an unreleased multi-crate rewrite, and its two stated Rust floors do not match
Graph data structure library for Rust.
At a glance
- What is it?
- A Rust graph library with four graph types, extensible algorithms and DOT import and export, released monthly on a zero point eight line while the default branch is mid-transition to a split crate layout. The README's minimum Rust version, its own badge and the workspace manifest give three different answers.
- Who is it for?
- Petgraph is a good fit if you need graph algorithms in Rust and want them to be there in four years, because the released line has been shipping on a steady monthly cadence and the standard library has been stable long enough to plan around. Four things to know.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 1 day ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- petgraph/petgraph4,061 ★ · +43
| Repository | 2026-09-24 | 2026-11-22 |
|---|---|---|
| petgraph/petgraph | 4k | 4.1k |
43 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The default branch is a rewrite in progress
The first thing the README says is a warning. The version currently on the trunk branch is a new development version that is in the process of transitioning to a multi-crate layout and a new architecture, and the previous release is available under a separate branch. So the repository a newcomer clones is not the library most people are using. Two details confirm the split is real rather than aspirational: the tree holds a crates directory and a separate crate for serialization tests, and the release tags are already prefixed with the crate name, which is what a multi-crate release tool does. The default branch also keeps the traditional branch name rather than the newer one, which means a tool that follows that convention will fetch the rewrite and not the release.
Two minimum Rust versions, in three places
The README says the library supports Rust 1.64 and later, and adds that this will only change on major releases. A badge in the same file asserts the same floor. The workspace manifest says something quite different: an edition that itself requires a much newer compiler, and a minimum version a long way past the one on the badge. Nobody is being dishonest. The README is describing the released line, where the promise about major releases is a commitment, and the manifest is describing the development line, which has moved to a recent edition as part of the rewrite. The practical consequence is narrow and annoying: a reader who trusts the badge and the prose will pick a toolchain that the current default branch will not accept, and find out from a compiler error rather than from the README.
Dual licensed in three places, recorded once in the metadata
The README says the project is dual licensed to be compatible with the wider Rust ecosystem, offering the Apache licence or the MIT licence at your choice. The workspace manifest agrees, spelling the pair the way the ecosystem expects. The root carries both licence files side by side. The repository's own licence field records only the Apache one. That last one is the problem: anything that reads metadata rather than the readme, including tooling that stamps licence headers into derived files or a downstream policy checker, will conclude the project is Apache-only when it is in fact your choice, and your options get narrowed without anybody telling you. For a library whose stated reason for dual licensing is ecosystem compatibility, the metadata field undoes part of the point.
The no-std build is checked against the first WebAssembly version
One of the build tasks compiles the library with default features turned off, against a bare target with no standard library at all, enabling the feature set that includes the generators and the unstable flag. A comment says it works the same way as the automated pipeline, and that the target has to be installed before it will run. Choosing the first version of that instruction set rather than the current one is the detail that makes the check worth having: it is the closest thing to a freestanding embedded target the toolchain offers, which is the environment the feature exists for. The library also states plainly that disabling the standard library feature is what makes the no-std context possible at all, rather than leaving it to be discovered by reading the feature list. The command itself is one line, and the target name is the interesting part:
cargo check --no-default-features -p petgraph --target wasm32v1-none --features graphmap,serde-1,stable_graph,matrix_graph,generate,unstableThree hash implementations and one very old random number crate
The workspace dependency list turns off default features on almost everything, which is the standing cost of supporting several graph backends and a no-std target: you cannot have a dependency that assumes a standard library. Two entries sit at much older major versions than everything around them. A hashing library and the random number generator are both pinned well behind their current majors, while the iterator utilities, the parallelism library and the hash map implementation are all on recent ones. Holding one dependency back is usually a wait for a major release rather than an oversight, and in a workspace like this it can also be a deliberate choice, since the older major may be the one that still builds without the standard library. Either way it is worth knowing before you go looking for a fix.
An interpreter over the whole test suite
Among the build tasks is one that runs the Rust interpreter over every test, with a comment warning that it might take a very long time. For a library whose entire job is indexing and traversal, an interpreter that reports undefined behaviour rather than letting it execute unnoticed is a stronger correctness signal than a green test run, because most memory errors in a graph library are exactly the kind that pass tests on one machine and fail on another. It is also the kind of check that usually lives only in a continuous pipeline. Here it is a recipe in a file of eleven short commands, sitting next to build and test, which means anybody can run it and nobody is forced to.
Two task runners, and a local aggregate that is not the pipeline
The repository has a file of task recipes and a separate version and task manager file, so there are two ways to ask the project to do something and the README describes neither. The recipes themselves are well commented, and two of the comments say the command matches what continuous integration runs. But the aggregate recipe runs the formatter, the linter and the tests, while the no-std check and the interpreter run are separate recipes. So a developer who runs the one command apparently meant to mirror the pipeline is not running everything the pipeline runs. Two comments pointing at a pipeline that has drifted is the classic shape of this, and the fix is usually to make the aggregate depend on the same recipes the pipeline calls.
Editorial conclusion
Petgraph is a good fit if you need graph algorithms in Rust and want them to be there in four years, because the released line has been shipping on a steady monthly cadence and the standard library has been stable long enough to plan around. Four things to know. The default branch is a rewrite in progress, so pin the released line or the one before it rather than tracking the head of the repository, and read the warning at the top of the file before you do anything else. The minimum Rust version is stated three times and the manifest disagrees with the badge. If you are a library author, the dual licence is your choice between two permissive terms, but the licence field in the repository's own metadata records only one of them, so anything that reads metadata will narrow your options silently. And if you work without the standard library, that path is genuinely tested rather than aspirational, against a bare WebAssembly target. Licence terms are Apache-2.0 or MIT at your option, and the last push is dated 2026-10-04.
Frequently asked questions
What is petgraph?
A Rust library of graph data structures and algorithms supporting directed and undirected graphs with arbitrary data on nodes and edges. It ships four graph types, algorithms such as path finding, minimum spanning trees and isomorphism with traits exposed for custom implementations, and DOT import and export for Graphviz.
Which Rust version does petgraph need?
The README says 1.64 and later, changing only on major releases, and carries a badge with the same floor. The workspace manifest for the development line declares a much newer minimum and a recent edition, because the default branch is mid-transition to a multi-crate layout while the released line keeps the old floor.
Does petgraph support no_std?
Yes, by disabling the default standard library feature. The build tasks check it by compiling with default features off against a bare target with no standard library, enabling the feature set that includes generators and the unstable flag.
What licence is petgraph under?
Dual licensed at your choice, the Apache Licence version 2.0 or the MIT licence, with both files in the repository root and the workspace manifest recording the pair. The repository's own licence metadata records only the Apache one.
How do I get the released version of petgraph?
From the separate branch the README points to for the previous release, since the default branch holds the new development version that is mid-transition to a multi-crate layout and a new architecture. The published versions are on the 0.8 line.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/petgraph-petgraph)Star history chart for your README
[](https://hysenlabs.com/projects/petgraph-petgraph)Was this useful?