-
Notifications
You must be signed in to change notification settings - Fork 191
Adding random regular graph generator for rustworkx-core #1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding random regular graph generator for rustworkx-core #1423
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will review the algorithm from NetworkX more closely, but currently the implementation LGTM.
I left a couple Rust comments. The majority are about using IndexSet and DictMap.
In Rust, HashMap
and HashSet
have random iteration order. That means that calling the same function twice with the same seeds would generate different graphs. Despite random
in the name, when users pass a seed the expect a reproducible result. So let's stick with DictMap
and IndexSet
as they will preserve the iteration order.
I also added a minor comment to make the test slightly stronger. Also, remember to run cargo fmt
it will fix the failure in CI.
Last but not least: congrats on your first contribution! I think the strategy of starting with the rustworkx-core
is best. This PR is very close to getting merged.
edit: use DictMap instead of IndexMap, it is our alias for IndexMap with the hasher rustworkx uses
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
…graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
…ctMap, added test case
Hi @IvanIsCoding, I have made the required changes. Let me know if there is anything else. |
There are some You’ll need to fix the lint findings first before I can merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestions to make CI pass
We got one test failure on CI:
You'll need to investigate the bug. I will also try to found out why |
So there were two mistakes:
|
Oh sorry, forgot to fix the number of edges generated in the doctest place. However, the particular error post that arises due to a bug. We switched from
to
this led to some of the edges being ignored, so I am reverting this back and will see if this help pass the tests |
Indeed, I introduced a bug with that comment. It turns out that the I am also happy the tests caught it. |
Pull Request Test Coverage Report for Build 14420374667Details
💛 - Coveralls |
* adding random regular graph generator * correct spelling rustworkx-core/src/generators/random_graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> * Update from HashSet to IndexSet rustworkx-core/src/generators/random_graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> * Correct spelling rustworkx-core/src/generators/random_graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> * Hashset to indexset rustworkx-core/src/generators/random_graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> * Index Set rustworkx-core/src/generators/random_graph.rs Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> * corrected formatting, replaced HashSet and Hashmap to IndexSet and DictMap, added test case * fixing bug * Apply suggestions from code review * Make doctest failure reproducible * fixed bug leading to doctest issue * fix hyperlink --------- Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
This pull request adds a random regular graph function in rustworkx-core(this partly resolves - #1391). I will be adding the PyO3 connection and this functionality to rustworkx in a bit. Just wanted to get review on this first.