-
Notifications
You must be signed in to change notification settings - Fork 152
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
Add barabasi_albert_graph random graph functions #1007
Conversation
This commit adds new random graph functions to rustworkx and rustworkx-core to implement a random graph generator using the Barabási–Albert preferential attachment method. It takes an input graph (defaulting to a star graph) and then extends it to a given size.
Pull Request Test Coverage Report for Build 6567441488
💛 - Coveralls |
I'll take a look at this. |
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.
A few minor changes and a couple of questions.
n, | ||
m, | ||
seed, | ||
initial_graph.map(|x| x.graph), |
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.
Not exactly sure what this line is doing.
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.
Option<T>.map()
is just syntactical sugar and this is the equivalent of
match initial_graph {
Some(graph) => Some(graph.graph),
None => None,
}
Basically the type for initial_graph
is Option<PyGraph>
but the rustworkx-core function needs Option<StablePyGraph>
so I'm using a map here to pass the inner .graph
attribute if initial graph is set.
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.
Ah, got it. Thanks.
Co-authored-by: Edwin Navarro <enavarro@comcast.net>
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.
LGTM.
This commit adds new random graph functions to rustworkx and rustworkx-core to implement a random graph generator using the Barabási–Albert preferential attachment method. It takes an input graph (defaulting to a star graph) and then extends it to a given size.