Qiskit / rustworkx

A high performance Python graph library implemented in Rust.
https://www.rustworkx.org
Apache License 2.0
967 stars 140 forks source link

Update mpl_draw() to fix multigraph plots #1204

Closed maxwell04-wq closed 4 weeks ago

maxwell04-wq commented 1 month ago

Fixes #774. Updates:

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 9448236772

Details


Files with Coverage Reduction New Missed Lines %
rustworkx-core/src/generators/random_graph.rs 2 85.04%
src/shortest_path/all_pairs_bellman_ford.rs 6 95.53%
<!-- Total: 8 -->
Totals Coverage Status
Change from base Build 9447555728: -0.04%
Covered Lines: 17380
Relevant Lines: 18135

💛 - Coveralls
maxwell04-wq commented 1 month ago

@mtreinish one major hiccup in the implementation is that the position of the edges is calculated on the plot in the draw_edges() function and the position of the labels can only be evaluated relative to the position of the nodes and not the edges in the draw_edge_labels() function. While the current parameters for the curved edges of multigraphs work for plotting the labels, maybe there's a better way to evaluate the position of the labels.

maxwell04-wq commented 1 month ago

@IvanIsCoding I have not tried to align the labels vertically as, following the logic of rad in connectionstyle=arc3, simply offsetting the y coordinates of labels to rad generates a figure wherein the labels are perfectly placed on the edges. test_fig Would you suggest that I work on aligning the edge labels?

IvanIsCoding commented 4 weeks ago

release_notes_2_0 It seems to be working, I will merge the PR