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

visualisation via GraphViz #37

Open
m4lvin opened this issue Nov 13, 2024 · 2 comments
Open

visualisation via GraphViz #37

m4lvin opened this issue Nov 13, 2024 · 2 comments

Comments

@m4lvin
Copy link

m4lvin commented Nov 13, 2024

(First, thanks for the very nice library - it is great to have a pure Haskell BDD package!)

Would you be interested in adding function to visualize BDDs? There already is the toGraph function, but in an ongoing project I found it helpful to convert to the GraphViz types. See here for the code.

I did not make a PR immediately, as I can also imagine that adding the dependency on the Haskell library graphviz is a bit overkill for anyone not wanting to use it but just wanting to have DDs 🤔

@msakai
Copy link
Owner

msakai commented Nov 27, 2024

Thank you for using the library and suggestions.

I think basic visualization is a handy feature for BDD packages.

Can the graphviz package be built without foreign libraries and is not too large?
If these are the case and the API and implementation are solid, I would like to include the feature in this package.

Below are a few quick comments on the current code:

  • The file name is hard-coded to “example.pdf”, but it should be user-specifiable.
  • If functions are exported from BDD or BDD.Visuals, it may be redundant to include Bdd in the function names.
  • It would be nice to have an implementation not only for BDD but also for ZDD.

@m4lvin
Copy link
Author

m4lvin commented Nov 27, 2024

I updated my fork now, see here. I added functions to show ZDDs, reworked the "remove unreachable nodes" part and for bddPdf the file name is now an argument. It is now one module Data.DecisionDiagram.Visuals instead of being BDD specific, so I kept the bdd and zdd prefixes.

Can the graphviz package be built without foreign libraries and is not too large?

Yes, I think the Haskell library graphviz even compiles when graphviz is not installed and has no non-Haskell dependencies. It does depend on a bunch of other Haskell libraries, that is what I meant with a bit overkill, as it increases the footprint of decision-diagrams.

A more naive approach would be to just create a String output instead of a proper DotGraph value - that is actually what I did in Data.HasCacBDD.Visuals, so HasCacBDD does not depend on graphviz, but it feels unsafe and wrong (and the show function there depends on a hard-coded binary location /usr/bin/dot etc 🥴)

I can make a PR later, but probably also should add tests. (For example to check that the DotGraph for specific DDs is as expected.)

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