forked from Qiskit/rustworkx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch is_directed_acyclic_graph to use toposort internally (Qiskit#217)
Previously the retworkx.is_directed_acyclic_graph() function was internally using the petgraph::algo::is_cyclic_directed function to look for a potential cycle in the graph. However, as noted in the docs[1] this function is recursive and as reported in Qiskit/qiskit#5502 with very large graphs this is causing segfaults. To avoid this potential issue this commit changes the internal implementation to use petgraph::algo::toposort which isn't recursive and should be more reliable. Fixes: Qiskit/qiskit#5502 [1] https://docs.rs/petgraph/0.5.1/petgraph/algo/fn.is_cyclic_directed.html
- Loading branch information
Showing
3 changed files
with
21 additions
and
2 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
releasenotes/notes/fix-segfault-is_dag_fn-8335e900ffca6af9.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
fixes: | ||
- | | ||
Fixed a potential segfault that could occur when calling | ||
:func:`~retworkx.is_directed_acyclic_graph` with a a very deep | ||
:class:`~retworkx.PyDiGraph` object as reported in | ||
`Qiskit/qiskit-terra#5502 <https://github.com/Qiskit/qiskit-terra/issues/5502>`__. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters