Graph data structure library. Known to support Rust 1.37 and later.
Please read the API documentation here__
__ https://docs.rs/petgraph/
|buildstatus| |crates|_
.. |buildstatus| image:: https://github.com/petgraph/petgraph/workflows/Continuous%20integration/badge.svg?branch=master .. _buildstatus: https://github.com/petgraph/petgraph/actions
.. |crates| image:: http://meritbadge.herokuapp.com/petgraph .. _crates: https://crates.io/crates/petgraph
Crate feature flags:
graphmap (default) enable GraphMap.stable_graph (default) enable StableGraph.matrix_graph (default) enable MatrixGraph.serde-1 (optional) enable serialization for Graph, StableGraph using
serde 1.0. Requires Rust version as required by serde.0.5.1
Default for traversals.EdgesConnecting publicly.is_bipartite_graph.FilterNode implementation for FixedBitSet and HashSet.node_weights_mut and edge_weights_mut for StableGraph.0.5.0
Breaking changes:
The iterative DFS implementation, Dfs, now marks nodes visited when
they are pushed onto the stack, not when they're popped off. This may
require changes to callers that use Dfs::from_parts or manipulate
its internals.
The IntoEdgesDirected trait now has a stricter contract for
undirected graphs. Custom implementations of this trait may have to be
updated. See the trait documentation__ for more.
Other changes:
Upgrade to Rust 2018 edition
MatrixGraph implementation__ https://docs.rs/petgraph/0.5/petgraph/visit/trait.IntoEdgesDirected.html
0.4.13
Csr by @ksadorffind_map in new Rust0.4.12
Time now also implements HashFrozen.0.4.11
petgraph::graph::NodeReferences to be publicly visible0.4.10
IntoEdgesDirected0.4.9
bellman_ford to work correctly with undirected graphs (#152) by
@carrutstickGraph, Stablegraph's .map().0.4.8
StableGraph learned new methods nearing parity with Graph. Note
that the StableGraph methods preserve index stability even in the batch
removal methods like filter_map and retain_edges.
Added .filter_map(), which maps associated node and edge data
Added .retain_edges(), .edge_indices() and .clear_edges()
Existing Graph iterators gained some trait impls:
.node_indices(), .edge_indices() are ExactSizeIterator
.node_references() is now
DoubleEndedIterator + ExactSizeIterator..edge_references() is now ExactSizeIterator.
Implemented From<StableGraph> for Graph.
0.4.7
petgraph::algo::astarOne StableGraph bug fix whose patch was supposed to be in the previous
version:
add_edge(m, n, _) now properly always panics if nodes m or n don't
exist in the graph.
0.4.6
"serde-1", which enables serialization
for Graph and StableGraph using serde.new, add_node to Csr by @jmcomets[] by node index, NodeCompactIndexable for
Csr by @jmcometsGraphMap::into_graph (it has a case where it can panic)From<Graph> for StableGraph.IntoNodeReferences for &StableGraph.StableGraph::map that maps associated dataStableGraph::find_edge_undirectedMany StableGraph bug fixes involving node vacancies (holes left by
deletions):
neighbors(n) and similar neighbor and edge iterator methods now
handle n being a vacancy properly. (This produces an empty iterator.)
find_edge(m, n) now handles m being a vacancy correctly tooStableGraph::node_bound was fixed for empty graphs and returns 0
Add implementation of DoubleEndedIterator to Graph, StableGraph's
edge references iterators.
Graph now shows node and edge count. Graph, StableGraph
show nothing for the edges list if it's empty (no label).Arbitrary implementation for StableGraph now can produce graphs with
vacancies (used by quickcheck)0.4.5
max ambiguity error with current rust nightly by @daboross (#153)0.4.4
GraphMap::all_edges_mut() iterator by @BineroStableGraph::retain_nodes by @RupsbantStableGraph::index_twice_mut by @christolliday0.4.3
0.4.2
visit.rs file due to changed rules for a module’s directory
ownership in Rust, resolving a future compat warning.Cycle, NegativeCycle now implement PartialEq.0.4.1
simple_fast for computing dominators in a control-flow
graph.0.4.0
Breaking changes in Graph:
Graph::edges and the other edges methods now return an iterator of
edge references
Other breaking changes:
toposort now returns an error if the graph had a cycle.
is_cyclic_directed no longer takes a dfs space argument. It is
now recursive.scc was renamed to kosaraju_scc.min_spanning_tree now returns an iterator that needs to be
made into a specific graph type deliberately.dijkstra now uses the IntoEdges trait.NodeIndexable changed its method signatures.IntoExternals was removed, and many other smaller adjustments
in graph traits. NodeId must now implement PartialEq, for example.DfsIter, BfsIter were removed in favour of a more general approach
with the Walker trait and its iterator conversion.
New features:
New graph traits, for example IntoEdges which returns
an iterator of edge references. Everything implements the graph traits
much more consistently.
DataMap,
Build, Create, FromElements.EdgeFiltered. Filtered was renamed to NodeFiltered.Csr).GraphMap implements NodeIndexable.Dot was generalized0.3.2
depth_first_search, a recursive dfs visitor that emits discovery,
finishing and edge classification events.Filtered.Debug, NodeIndexable for Reversed.0.3.1
.edges(), .edges_directed() to StableGraph. Note that these
differ from Graph, because this is the signature they will all use
in the future..update_edge() to StableGraph.stable_graph module (for example
NodeIndex).visit module.0.3.0
Overhaul all graph visitor traits so that they use the IntoIterator
style. This makes them composable.
Multiple graph algorithms use new visitor traits.
Help is welcome to port more algorithms (and create new graph traits in the process)!
GraphMap can now have directed edges. GraphMap::new is now generic
in the edge type. DiGraphMap and UnGraphMap are new type aliases.
DiGraph, UnGraph, StableDiGraph, StableUnGraphGraphMap is based on the indexmap crate. Deterministic iteration
order, faster iteration, no side tables needed to convert to Graph.DfsPostOrderDfs gained new methods from_parts and reset.has_path_connecting.tarjan_scc, a second scc implementation.Dfs, DfsPostOrder, scc, tarjan_scc.has_path_connecting,
is_cyclic_directed, toposort.Debug formatting for Graph, StableGraph.GraphMap now has a method .into_graph() that makes a Graph.Graph::retain_nodes, retain_edges now expose the self graph only
as wrapped in Frozen, so that weights can be mutated but the
graph structure not.StableGraph by defaultGraph::contains_edge.EdgeDirection → Direction.SubTopo.0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
Dot passes on the alternate flag to node and edge label formattingClone impl for some iteratorsGraph::neighborsStableGraph, using feature flag stable_graph0.2.1
is_isomorphic_matching0.2.0
New Features
Add Graph::neighbors().detach() to step edges without borrowing. This is more general than, and replaces now deprecated walkedgesdirected. (#39)
Add method EdgeDirection::opposite()
Breaking changes
Graph::neighbors() for undirected graphs and Graph::neighbors_undirected for any graph now visit self loop edges once, not twice. (#31)
Option<E>Element type of GraphMap<N, E>::all_edges() changed to (N, N, &E)
Minor breaking changes
IntoWeightedEdge changed a type parameter to associated type
0.1.18
0.1.17
quickcheck::Arbitrary implementations,
if optional feature check is enabled.0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.4
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.