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

Docker learning method steps to build ActiveMQ message service

Preface ActiveMQ is the most popular and powerful...

Detailed explanation of HTML's <input> tag and how to disable it

Definition and Usage The <input> tag is use...

JavaScript implements product details of e-commerce platform

This article shares a common example of viewing p...

Analyze Mysql transactions and data consistency processing issues

This article analyzes the consistency processing ...

IE8 browser will be fully compatible with Web page standards

<br />According to foreign media reports, in...

Summary of the main attributes of the body tag

bgcolor="text color" background="ba...

JavaScript canvas realizes the effect of nine-square grid cutting

This article shares the specific code of canvas t...

Detailed discussion of the differences between loops in JavaScript

Table of contents Preface Enumerable properties I...

Issues with locking in MySQL

Lock classification: From the granularity of data...

In-depth study of how to use positioning in CSS (summary)

Introduction to Positioning in CSS position attri...

Docker container from entry to obsession (recommended)

1. What is Docker? Everyone knows about virtual m...

How to run py files directly in linux

1. First create the file (cd to the directory whe...

Why Google and Facebook don't use Docker

The reason for writing this article is that I wan...

Implementation of mysql decimal data type conversion

Recently, I encountered a database with the follo...