Skip to content

Commit

Permalink
Tweak Symbol.to_networkx() following review suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: Theodor Isacsson <[email protected]>
Co-authored-by: Joel Pasvolsky <[email protected]>
  • Loading branch information
3 people authored Jul 12, 2024
1 parent fe1d801 commit db40ff0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions dwave/optimization/model.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ cdef class Model:
`drawing <https://networkx.org/documentation/stable/reference/drawing.html>`_
documentation.
This example uses a `DAGVIZ <https://wimyedema.github.io/dagviz/>`_ to
This example uses `DAGVIZ <https://wimyedema.github.io/dagviz/>`_ to
draw the NetworkX graph created in the example above.
>>> import dagviz # doctest: +SKIP
Expand All @@ -877,7 +877,7 @@ cdef class Model:
.. figure:: /_images/to_networkx_example.svg
:width: 500 px
:name: to-networkx-example
:name: dwave-optimization-to-networkx-example
:alt: Image of NetworkX Directed Graph
"""
Expand Down Expand Up @@ -909,9 +909,8 @@ cdef class Model:
G.add_edge(repr(self.objective), "minimize")

# Likewise if we have constraints, add a special node for them
if self.num_constraints():
for symbol in self.iter_constraints():
G.add_edge(repr(symbol), "constraint(s)")
for symbol in self.iter_constraints():
G.add_edge(repr(symbol), "constraint(s)")

return G

Expand Down Expand Up @@ -1216,8 +1215,8 @@ cdef class Symbol:
def __repr__(self):
"""Return a representation of the symbol.
The representation refers to the id of the underlying node, rather than
the id of the Python symbol.
The representation refers to the identity of the underlying node, rather than
the identity of the Python symbol.
"""
cls = type(self)
# We refer to the node_ptr, which is not necessarily the address of the
Expand Down

0 comments on commit db40ff0

Please sign in to comment.