How to install Graphviz and get started tutorial under Windows

How to install Graphviz and get started tutorial under Windows

Download and installConfigure environment variablesintallConfigure environment variablesVerifyBasic drawing introductiongraphdigraphA complex exampleInteract with Python

Discovering good tools is like discovering a new world. Sometimes, we are curious about how those vivid illustrations in papers and various professional books are made. Without exception, they are the result of skillful use of drawing tools.

Download and install, configure environment variables

intall

Windows version download address: http://www.graphviz.org/Download_windows.php

這里寫圖片描述

Double-click the msi file, then keep clicking next (remember the installation path, as the path information will be used when configuring environment variables later). After the installation is complete, a shortcut will be created in the Windows start menu. The default shortcut is not placed on the desktop.

這里寫圖片描述

Configuring environment variables

Add the bin folder under the graphviz installation directory to the Path environment variable:

這里寫圖片描述

這里寫圖片描述

verify

Enter the Windows command line interface, enter dot -version , and press Enter. If the relevant version information of graphviz is displayed, the installation and configuration are successful.

這里寫圖片描述

Basic drawing tutorial

Open the graphviz editor gvedit under Windows, write the following dot script language, and save it as a gv format text file. Then enter the command line interface and use the dot command to convert the gv file into a png graphic file.

dot D:\test\1.gv -Tpng -o image.png

graph

Graph usage -- describing relationships

graph pic1 { 
 a -- b
 a -- b
 b -- a [color=blue]
} 

這里寫圖片描述

digraph

Use -> describe relationship

digraph pic2 { 
 a -> b
 a -> b
 b -> a [style=filled color=blue]
} 

這里寫圖片描述

A complex example

digraph startgame {
  label="Game resource update process"
  rankdir="TB"
  start[label="Start the game" shape=circle style=filled]
  ifwifi[label="Network environment determines whether it is WIFI" shape=diamond]
  needupdate[label="Whether there are resources that need to be updated" shape=diamond]
  startslientdl[label="Silent download" shape=box]
  enterhall[label="Enter the game lobby" shape=box]

  enterroom[label="Enter room" shape=box]
  resourceuptodate[label="Resource incomplete" shape=diamond]
  startplay[label="Normal game" shape=circle fillcolor=blue]
  warning[label="Remind players whether to update" shape=diamond]
  startdl[label="Enter the download interface" shape=box]
  //{rank=same; needupdate, enterhall}

  {shape=diamond; ifwifi, needupdate}

  start -> ifwifi
  ifwifi->needupdate[label="yes"]
  ifwifi->enterhall[label="no"]
  needupdate->startslientdl[label="yes"]
  startslientdl->enterhall
  needupdate->enterhall[label="no"]

  enterhall -> enterroom
  enterroom->resourceuptodate
  resourceuptodate -> warning[label="yes"]
  resourceuptodate -> startplay[label="no"]
  warning -> startdl[label="Confirm download"]
  warning -> enterhall[label="Cancel download"]
  startdl -> enterhall[label="Cancel download"]
  startdl -> startplay[label="Download completed"]
} 

這里寫圖片描述

Interacting with Python

Graphviz's powerful and convenient relationship diagram/flowchart drawing method easily reminds us of the display method of Decision Tree in machine learning. Fortunately, scikit-learn provides an interface for generating .dot files. The specific operations are as follows:

In the Python editing environment:

from sklearn.tree import export_graphviz # Imports a function # tree represents a trained model, that is, the fit(X_train, y_train) method of the DecisionTreeClassifier instance has been called export_graphviz(tree, out_file='tree.dot', 
    feature_names=['petal length', 'petal width'])

Enter the Windows command line interface, switch to the path where tree.dot is located, and execute

dot -Tpng tree.dot -o tree.png 

這里寫圖片描述

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Python calls graphviz to draw a structured graph network example
  • Solve the problem of using export_graphviz to visualize the tree
  • An example of implementing a decision tree in Python and visualizing it using Graphviz
  • A diagram of the Youdao translation process based on Python
  • Graphical tutorial on how to use VSCode and debug Python programs in VSCode
  • Python uses graphviz to draw flowcharts

<<:  MySQL query example explanation through instantiated object parameters

>>:  Detailed explanation of the principle of js Proxy

Recommend

Detailed usage of MYSQL row_number() and over() functions

Syntax format: row_number() over(partition by gro...

Solve the black screen problem after VMware installs Linux system and starts

1. Installation environment 1. HUAWEI mate x cpu ...

Css3 realizes seamless scrolling and anti-shake

question The seamless scrolling of pictures and t...

Sample code using scss in uni-app

Pitfalls encountered I spent the whole afternoon ...

Nest.js authorization verification method example

Table of contents 0x0 Introduction 0x1 RBAC Imple...

How to use Typescript to encapsulate local storage

Table of contents Preface Local storage usage sce...

JavaScript to make the picture move with the mouse

This article shares the specific code of JavaScri...

HTML+CSS to achieve text folding special effects example

This article mainly introduces the example of rea...

Detailed explanation of MySQL monitoring tool mysql-monitor

1. Overview mysql-monitor MYSQL monitoring tool, ...

JavaScript+html to implement front-end page sliding verification

This article shares the specific code of JavaScri...

Have you carefully understood Tags How it is defined How to use

Preface : Today I was asked, "Have you carefu...

Install MySQL 5.7.18 using rpm package under CentOS 7

I have been using MySQL recently. The article mys...