pnevyk / gryf

Graph data structure library aspiring to be convenient, versatile, correct and performant.
MIT License
69 stars 1 forks source link

Tweak API for using a custom storage in graphs #40

Closed pnevyk closed 1 year ago

pnevyk commented 1 year ago

Currently, the way to specify a custom storage when initializing a graph is this:

let mut graph = Graph::with_storage(AdjMatrix::<_, _, Undirected, DefaultIndexing>::new());

The need for specifying the Undirected and DefaultIndexing generic parameters brings unnecessary clutter. Moreover, we should follow the convention of the Rust standard library, which uses new_in naming convention for specifying allocators.

To improve the user experience, we should make these changes:

After all, the above example will look like this:

let mut graph = Graph::new_undirected_in(AdjMatrix::default());