Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Jul 12, 2024

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

image

With the parameter -x, the problem seems fixed:

image

@coveralls
Copy link

Pull Request Test Coverage Report for Build 9906449128

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.803%

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

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@@ -210,7 +214,7 @@ def node_attr(node):
return image
else:
subprocess.run(
[prog, "-T", output_format, "-o", filename],
[prog, "-x", "-T", output_format, "-o", filename] + extra_args,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[prog, "-x", "-T", output_format, "-o", filename] + extra_args,
[prog, "-T", output_format, "-o", filename] + extra_args,

@mtreinish
Copy link
Member

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
Copy link
Collaborator

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
Copy link
Member Author

1ucian0 commented Jul 12, 2024

Closing because Qiskit/qiskit#12770 is the right way to do it.

@1ucian0 1ucian0 closed this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants