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

Enhancement: graphviz_layout without drawing #917

Open
jamestwebber opened this issue Jul 2, 2023 · 2 comments
Open

Enhancement: graphviz_layout without drawing #917

jamestwebber opened this issue Jul 2, 2023 · 2 comments

Comments

@jamestwebber
Copy link
Contributor

First off, I'm excited to have found this package and I'm hoping to try it out soon. Thanks for building it!

What is the expected enhancement?

In networkx it is possible to get the coordinates of a graphviz-provided layout without actually drawing the graph. This is nice because it provides access to the algorithms (e.g. sfdp) without constraining the user to their display methods. I typically use nx.nx_agraph.graphviz_layout to get coordinates for a graph and then plot the resulting graph with matplotlib where I have better control over the display options (if only because I'm more familiar with the API).

I found #280 which is somewhat related to this. In that issue the decision was to not re-implement the algorithms (makes sense) but leave the layout interface entirely within the drawing code.

It looks like the interface with graphviz is via python, so maybe this is as simple as copying emulating the code in networkx.nx_agraph?

@mtreinish
Copy link
Member

Yeah, I like this idea it was something I was recently discussing in a Qiskit PR that was leveraging graphviz_draw() (see: Qiskit/qiskit#10208). Yeah we can use use similar code to networkx.nx_agraph with an appropriately documented optional dependency on pygraphviz. The other option would be to just call graphviz with subprocess and use the json output (or some other raw text format) and parse the layout information from that. I guess it really depends on whether we need the full pygraphviz representation or not.

@jamestwebber
Copy link
Contributor Author

The other option would be to just call graphviz with subprocess and use the json output (or some other raw text format) and parse the layout information from that.

I don't love this version because of the overhead of writing/reading the data. Unless graphviz can deal with streams?

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

No branches or pull requests

2 participants