Skip to content

Add node numbers to the graphviz rendering in hugr-py #2384

@CalMacCQ

Description

@CalMacCQ

Would be nice to have the node numbers available in the graphviz rendering for hugr-py.

Consider this hugr graph.

Image

Currently to get the node number associated with the exit node we need to print the output of Hugr.nodes() and compare with the diagram which isn't ideal

Node(0) NodeData(op=Module(), parent=None, metadata={})
Node(1) NodeData(op=FuncDefn(f_name='prepare_qubit', inputs=[Bool, Qubit], params=[]), parent=Node(0), metadata={})
Node(2) NodeData(op=Input(types=[Bool, Qubit]), parent=Node(1), metadata={})
Node(3) NodeData(op=Output(), parent=Node(1), metadata={})
Node(4) NodeData(op=OneQbGate(_enum=<_Enum.H: 'H'>), parent=Node(1), metadata={})
Node(5) NodeData(op=_NotOp(), parent=Node(1), metadata={})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomerspythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions