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.
Add PyDiGraph method to make edges symmetric (Qiskit#814)
* Add PyDiGraph method to make edges symmetric This commit adds a new method make_symmetric() to PyDiGraph which will modify the graph and add a reverse edge to each edge in the graph if it is not already present. * Simplyify logic * Add initial tests * Update docstring wording Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Add release notes * Expand testing * Fix tests and cycle checking * Remove stray debug prints * Update src/digraph.rs Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix lint --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Edwin Navarro <enavarro@comcast.net>
- Loading branch information
1 parent
becb18e
commit ad8e8b8
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
releasenotes/notes/add-digraph-make-symmetric-60d0287a7f7eec04.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,16 @@ | ||
--- | ||
features: | ||
- | | ||
Added a new method, :meth:`~.PyDiGraph.make_symmetric`, to the | ||
:class:`~.PyDiGraph` class. This method is used to make all the edges | ||
in the graph symmetric (there is a reverse edge in the graph for each edge). | ||
For example: | ||
.. jupyter-execute:: | ||
import rustworkx as rx | ||
from rustworkx.visualization import graphviz_draw | ||
graph = rx.generators.directed_path_graph(5, bidirectional=False) | ||
graph.make_symmetric() | ||
graphviz_draw(graph) |
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