-
Notifications
You must be signed in to change notification settings - Fork 167
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 random_layout function and Pos2DMapping #305
Conversation
This commit adds a new function random_layout() which is used to generate a random layout for a graph that can be used in visualization. This is necessary for building a matplotlib drawer (issue Qiskit#298 and a first draft of the implementation Qiskit#304). To make the function more efficient it also adds a new custom return type Pos2DMapping which is used to build an imutable readonly dict compatible result container for the output type from this function. Related to Qiskit#280
Pull Request Test Coverage Report for Build 763754537
💛 - Coveralls |
Co-authored-by: Jielun (Chris) Chen <[email protected]>
Co-authored-by: Nahum Rosa Cruz Sa <[email protected]>
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.
@@ -154,3 +165,4 @@ Return Iterator Types | |||
retworkx.NodeIndices | |||
retworkx.EdgeList | |||
retworkx.WeightedEdgeList | |||
retworkx.Pos2DMapping |
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.
with retworkx.*_layout(graph).keys()
a user will see Pos2DMappingKeys
. similar with.values()
. Should we have docs for these types?
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'm not sure if it matters too much, we can add it to the documentation it doesn't hurt. I just left it out since there really isn't any documentation for those types and we don't actually export them in the retworkx module. I basically modeled these types on how python's dict works it 'returns a dict_keys
, dict_values
, and dict_items
class for .keys()
, .values()
, and .items()
. I couldn't find any documentation on those classes except in the C-API: https://docs.python.org/3/c-api/dict.html?highlight=dict_keys#c.PyDict_Keys
Co-authored-by: georgios-ts <[email protected]>
This commit changes the input type of the center option to be a fixed 2 element array instead of a tuple. This still works as a tuple for the python interface but has a defined contiguous memory layout in rust. It also is consistent with the type for elements in the position mapping.
This commit adds a new function
random_layout()
which is used togenerate a random layout for a graph that can be used in visualization.
This is necessary for building a matplotlib drawer (issue #298 and a
first draft of the implementation #304). To make the function more
efficient it also adds a new custom return type
Pos2DMapping
which isused to build an immutable readonly dict compatible result container for
the output type from this function.
Related to #280