-
Notifications
You must be signed in to change notification settings - Fork 164
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 generators module #121
Conversation
This commit adds a new module to retworkx, generators, which contains a bunch of helper functions to quickly create various types of graphs. To start it adds generators for a star graph, path graph, and cycle graph. We can continue to grow this set out.
Hmm, I think coveralls is a little confused. There was no change in coverage from the previous commit (it was just a merge commit pulling in a requirements bump). Looking at https://coveralls.io/builds/32982740 it shows the new generator module having 97% coverage but files not changed decreasing. I'm not sure how to retrigger it, rerunning the job didn't work. |
Yeah looking a bit more closely at the coverage reporting there it's missing |
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'll have to read generators.rs
tomorrow
|
||
def test_directed_cycle_graph_weights(self): | ||
graph = retworkx.generators.directed_cycle_graph( | ||
weights=list(range(20))) |
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.
Weights are attached to nodes, rather than edges? And it's also separate from node data (which seems to be None
, here)?
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.
Yeah, the weights here are attached to the nodes, the edge weights end up as None
in the generator. I use data and weights interchangeably in retworkx (which is probably pretty sloppy on my part). The None
s below are actually the edge weight/data PyDiGraph.out_edges()
returns a list of tuples of the form (source node index, target node index, edge weight)
https://github.com/Qiskit/retworkx/blob/master/src/digraph.rs#L852-L871. The assertEqual
at L32 is checking the node weights, PyDigraph.nodes()
returns a list of all the node data https://github.com/Qiskit/retworkx/blob/master/src/digraph.rs#L391-L401
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.
thank you:)
This commit adds a new module to retworkx, generators, which contains a
bunch of helper functions to quickly create various types of graphs. To
start it adds generators for a star graph, path graph, and cycle graph.
We can continue to grow this set out over time.