Closed ryanhill1 closed 1 week ago
We might need to revert that PR, not respecting the edge colours is a serious flaw. I would rather find a fix of course, but I think a wrong output for regular graphs is a bigger issue
I noticed the same bug; I believe the issue is L638-L641 of matplotlib.py, where edge_pos is constructed as a set, which does not respect the order of edge_list when iterating over edge_pos later in the code. I manually changed this to a list and that worked for me.
https://github.com/Qiskit/rustworkx/blob/main/rustworkx/visualization/matplotlib.py#L638C1-L641C59
I noticed the same bug; I believe the issue is L638-L641 of matplotlib.py, where edge_pos is constructed as a set, which does not respect the order of edge_list when iterating over edge_pos later in the code. I manually changed this to a list and that worked for me.
https://github.com/Qiskit/rustworkx/blob/main/rustworkx/visualization/matplotlib.py#L638C1-L641C59
Thanks for investigating. I will try to fix if the issue is simply iterables not preserving order
Information
What is the current behavior?
rustworkx.visualization.matplotlib.draw_edges()
does not correctly applyedge_color
of typelist
. Edge colors are not being applied to the edges ofgraph.edge_list()
in the correct order. Issue sourced from: https://github.com/qBraid/qBraid/issues/802What is the expected behavior?
The entries of a given
edge_color
list should be mapped to the correct edges, corresponding to the order ofgraph.edge_list()
.Steps to reproduce the problem
The code below plots 3 nodes and 3 edges. Edge
(c, a)
should be coloredblue
. But if you run the code multiple times, you will find that the blue edge changes, and is not always(c, a)
.If you
pip install rustworkx<0.15.0
, and run the code again, it works fine.Therefore, I was able to trace this bug back the following commit: https://github.com/Qiskit/rustworkx/commit/646057ae16505293f48fcc260cfa384bcad78fbc
Using the
draw_edges()
function from before that commit (i.e.rustworkx
version 0.14.2) resolves the issue. But the latest update seems to form anarrow_color
list that is not consistent with the indexing of theedge_color
list.