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:
Provide undirected and directed constructor methods, the same way as we do with default new_undirected and new_directed. This removes the need of specifying directionality generic parameter.
Use new_in naming convention. That is, there will be these three constructors: new_in (directionality unspecified), new_undirected_in and new_directed_in.
For the graph storages, change the implementation of Default to fix the indexing to DefaultIndexing. This removes the need of specifying DefaultIndexing (but a custom indexing would still be allowed via new (e.g., AdjList::new())).
After all, the above example will look like this:
let mut graph = Graph::new_undirected_in(AdjMatrix::default());
Currently, the way to specify a custom storage when initializing a graph is this:
The need for specifying the
Undirected
andDefaultIndexing
generic parameters brings unnecessary clutter. Moreover, we should follow the convention of the Rust standard library, which usesnew_in
naming convention for specifying allocators.To improve the user experience, we should make these changes:
undirected
anddirected
constructor methods, the same way as we do with defaultnew_undirected
andnew_directed
. This removes the need of specifying directionality generic parameter.new_in
naming convention. That is, there will be these three constructors:new_in
(directionality unspecified),new_undirected_in
andnew_directed_in
.Default
to fix the indexing toDefaultIndexing
. This removes the need of specifyingDefaultIndexing
(but a custom indexing would still be allowed vianew
(e.g.,AdjList::new()
)).After all, the above example will look like this: