Qiskit / rustworkx

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

add -x to graphviz to prune isolated nodes and peninsulas #1249

Closed 1ucian0 closed 1 month ago

1ucian0 commented 1 month ago

On many nodes, neato seems to fold on its own.

image

With the parameter -x, the problem seems fixed:

image

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 9906449128

Details


Totals Coverage Status
Change from base Build 9859812730: 0.0%
Covered Lines: 18035
Relevant Lines: 18825

💛 - Coveralls
mtreinish commented 1 month ago

As an alternative approach, from qiskit's usage of graphviz_draw may give setting overlap in the graph attributes a try: https://graphviz.org/docs/attrs/overlap/ I'm not sure how well that will work, but it sounds like what you're looking for instead of pruning nodes.

IvanIsCoding commented 1 month ago

We should really add an extra kwarg option for this, or a better choice would be generic way to set extra flags when calling graphviz. We definitely don't want to always do this with neato because it removes nodes from the graph. If you look at the examples from the pr summary the after example is missing a fair number of nodes.

That all being said does neato not expose this option via graph attributes or something a user can already set today?

I agree with Matthew that we should have kwargs. We can have default kwargs that are sane (like what you provided), but graphviz has a big surface of settings so forwarding kwargs to the CLI seems like the best path forward

1ucian0 commented 1 month ago

Closing because https://github.com/Qiskit/qiskit/pull/12770 is the right way to do it.