-
Notifications
You must be signed in to change notification settings - Fork 17
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 a method for calculating num_edges #32
Conversation
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.
Also needs a release note.
dwave/optimization/model.pyx
Outdated
>>> model.num_edges() | ||
0 | ||
""" | ||
return sum(1 for sym in self.iter_symbols() for _ in sym.iter_successors()) |
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.
We might as well do the more performant thing. Something like
cdef Py_ssize_t num_edges = 0
for i in range(self._graph.num_nodes()):
num_edges += self._graph.nodes()[i].successors().size()
return num_edges
dwave/optimization/model.pyx
Outdated
This example add a single (size 20) decision symbol and | ||
a single (size 3) constant symbol checks the number of |
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 think these numbers are incorrect?
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.
Ughh, forgot to update this. Thanks!
--- | ||
features: | ||
- | | ||
Adds a method for calculating num_edges |
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.
Maybe something like
Add `Model.num_edges()` method. See `#28 <https://github.com/dwavesystems/dwave-optimization/issues/28>`_.
Closes #28