This is an opinionated follow up for #975. It is mostly about renaming the arguments and making it accept None as argument. The reasoning:
Despite the docstring of initial_node_count making it explictly that it does not initialize with nodes, I have a bad feeling eventually we will get an issue complaining about it. I think the name with hint is clearer that you are giving rustworkx a heads-up to pre-allocate memory
By using the prefix _hint I feel that we can have much more freedom to make optimizations later. If it's a hint we can pre-allocate another value e.g. 2^ceil(log2(hint))
None seems like a more sensible default value for the argument because it means we didn't specify anything. I think if in Rust we had to do with_capacity(0) we'd find it weird, but doing with_capacity(capacity.unwrap_or_default()) seems like "ok we want to initialize with capacity but it could be unspecified`
Lastly, we completely forgot about the __init__ method for PyGraph! So I added that as well.
This is an opinionated follow up for #975. It is mostly about renaming the arguments and making it accept
None
as argument. The reasoning:initial_node_count
making it explictly that it does not initialize with nodes, I have a bad feeling eventually we will get an issue complaining about it. I think the name withhint
is clearer that you are giving rustworkx a heads-up to pre-allocate memory_hint
I feel that we can have much more freedom to make optimizations later. If it's a hint we can pre-allocate another value e.g.2^ceil(log2(hint))
None
seems like a more sensible default value for the argument because it means we didn't specify anything. I think if in Rust we had to dowith_capacity(0)
we'd find it weird, but doingwith_capacity(capacity.unwrap_or_default())
seems like "ok we want to initialize with capacity but it could be unspecified`Lastly, we completely forgot about the
__init__
method forPyGraph
! So I added that as well.