Graphviz: How to go from .dot to a graph?

后端 未结 11 1412
傲寒
傲寒 2020-11-27 08:44

I can\'t seem to figure this out. I have a .dot file, which is valid according to the syntax. How do I use graphviz to convert this into an image?

(note that I\'m on

相关标签:
11条回答
  • 2020-11-27 09:14

    This should combine a lot of answers.

    # Convert dot to png via graphviz
    dot -Tpng filename.dot -o filename.png
    
    # Convert dot to svg via graphviz
    dot -Tsvg filename.dot -o filename.svg
    
    # Convert dot to eps via graphviz
    dot -Tps filename.dot -o filename.eps
    

    Keep in mind that on OSX (MAC), you need to install homebrew to install graphviz to be able to use the dot commands above.

    brew install graphviz
    

    It is also possible to install Graphviz (and use the commands above) through the package manager functionality of conda if you have Anaconda installed.

    conda install python-graphviz
    
    0 讨论(0)
  • 2020-11-27 09:15

    You can use the VS code and install the Graphviz extension or,

    1. Install Graphviz from https://graphviz.gitlab.io/_pages/Download/Download_windows.html
    2. Add C:\Program Files (x86)\Graphviz2.38\bin (or your_installation_path/ bin) to your system variable PATH
    3. Open cmd and go to the dir where you saved the .dot file
    4. Use the command dot music-recommender.dot -Tpng -o image.png

    0 讨论(0)
  • 2020-11-27 09:16

    Get the graphviz-2.24.msi Graphviz.org. Then get zgrviewer.

    Zgrviewer requires java (probably 1.5+). You might have to set the paths to the Graphviz binaries in Zgrviewer's preferences.

    File -> Open -> Open with dot -> SVG pipeline (standard) ... Pick your .dot file.

    You can zoom in, export, all kinds of fun stuff.

    0 讨论(0)
  • 2020-11-27 09:22

    You can also output your file in xdot format, then render it in a browser using canviz, a JavaScript library.

    Canviz on code.google.com:

    To see an example, there is a "Canviz Demo" link on the page above as of November 2, 2014.

    0 讨论(0)
  • 2020-11-27 09:26

    type: dot -Tps filename.dot -o outfile.ps

    If you want to use the dot renderer. There are alternatives like neato and twopi. If graphiz isn't in your path, figure out where it is installed and run it from there.

    You can change the output format by varying the value after -T and choosing an appropriate filename extension after -o.

    If you're using windows, check out the installed tool called GVEdit, it makes the whole process slightly easier.

    Go look at the graphviz site in the section called "User's Guides" for more detail on how to use the tools:

    http://www.graphviz.org/documentation/

    (See page 27 for output formatting for the dot command, for instance)

    http://www.graphviz.org/pdf/dotguide.pdf

    0 讨论(0)
  • 2020-11-27 09:26

    There's also the online viewers:
    http://www.webgraphviz.com/
    http://sandbox.kidstrythisathome.com/erdos/
    http://viz-js.com/

    0 讨论(0)
提交回复
热议问题