#graph #algorithm


A general purpose, extensible Graph Theory data type and algorithm library for Rust

5 releases

Uses old Rust 2015

0.1.5 Apr 15, 2018
0.1.4 Apr 7, 2018
0.1.3 Jun 14, 2017
0.1.0 May 17, 2017

#902 in Algorithms

47 downloads per month

MIT license



Build Status

A general purpose, extensible Graph Theory data type and algorithm library for Rust.

This project is still in early design and development stage and is still changing a lot. A good public API is not the focus of the project yet, documentation may be scarce, and bugs may be rampant.


extern crate graphene;
use graphene::core::*;
use graphene::core::constraint::*;
use graphene::common::AdjListGraph;
	// Name of the resulting graph type
	struct MyGraph<V,W>
	// The BaseGraph implementation to base the new graph on.
	as AdjListGraph<V,W>
	// The graph wrappers that will constrain the BaseGraph implementation so that
	// it upholds the constraint traits.
	use UniqueGraph,UndirectedGraph
	// The constraint traits the new graph implements
	impl Unique,Undirected
	// The generic bounds
	where V: Vertex, W: Weight

fn main(){
    let mut g = MyGraph::graph(vec![1,2,3], vec![(1,2,1),(2,3,2),(3,1,3)]).unwrap();
	assert_eq!(g.edges_between(1,2).len(), 2);

	// Cannot add an edge that is already there because the graph
	// is declared as Unique, meaning no two edges may be incident
	// on the same vertices and have the weight.
	assert_eq!(g.edges_between(1,2).len(), 2);


Licensed under the MIT license.

Any file with its own license header is also licensed under the above license, at your option. If the header specifies a different license than the above, it must be seen as an additional choice of license and the above license or the header license can be chosen at your option.

Any intentional contribution to this repository is licensed under the above license in addition to any contribution specific license without exception.

No runtime deps