Search code examples
graphviz

Graphviz _ installation and the instruction for use


I did install the Graphviz from this link: http://www.graphviz.org/download/, and since I have windows, I used this version: graphviz-4.0.0 (64-bit) EXE installer [sha256]. I am not familiar with this program, and now I don't know where I should write my codes? There is no shortcut on my desktop. Do I need any other software like Python to be able to use this program? I couldn't find any tutorial for a super beginner; I would be grateful if someone could help me!


Solution

  • If you followed the default installation options...

    enter image description here

    ...then GraphViz will be installed here:

    C:\Program Files\Graphviz
    

    To verify this, you can run one of the programs it uses - such as dot.exe.

    1 - Open a command promt.

    2 - Run the following command:

    "C:\Program Files\Graphviz\bin\dot" -V
    

    Note the uppercase V.

    That will print the installed version number to confirm that the installation was succesful:

    dot - graphviz version 4.0.0 (20220529.0937)
    

    After that, you can create dot files (you can find a tutorial for that) and run them at the command line.


    Update

    Here is a simple example of creating a graph after completing the installation:

    I will choose a directory in which to work, to keep my work separate from the installation directory:

    C:\Users\me\graphviz-work
    

    In this directory I create the following text file called demo.dot. I create this file manually using Notepad++, and just type it all in:

    digraph G {
      main -> parse -> execute;
      main -> init;
      main -> cleanup;
      execute -> make_string;
      execute -> printf
      init -> make_string;
      main -> printf;
      execute -> compare;
    }
    

    In the same directory, at the command line, I run the following command to generate the graph from this file:

    "C:\Program Files\Graphviz\bin\dot" -Tsvg demo.dot -o demo.svg
    

    This generates the output file demo.svg:

    enter image description here

    This example is taken from the dot user's manual.


    Everything I have shown here involves working at the command line (and editing text files by hand), and using the various Graphviz tools directly. As you have seen, you don't have to do this. You can use a tool such as Visual Studio to make things more convenient; you can use languages such as Python which allow you to build graphs programmatically (without you needing to directly interact with GraphViz).

    So, there are various different ways to use GraphViz. Personally, I think it helps to understand the basics (as shown here) before using another tool.