Graphviz installation and introduction under windows

Download installation configuration environment variable intall Configure environment variables verification Introduc...
intall
Configure environment variables
verification
graph
digraph
A complex example

Finding good tools is like finding a new continent. Sometimes, we will be curious about how to make such image illustrations in papers and various professional books, without exception, the skillful use of drawing tools.

Download, install and configure environment variables

intall

Download address of windows version: http://www.graphviz.org/Download_windows.php

Double click the msi file, and then continue to next (remember the installation path, the path information will be used to configure the environment variables later). After the installation is completed, the shortcut information will be created in the windows start menu. The default shortcut is not placed on the desktop.



Configure environment variables

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





verification

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



Introduction to basic drawing

Open gvedit, the graphviz Editor under windows, write the following dot script language, and save it as 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 use -- describe 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 games" shape=circle style=filled] ifwifi[label="Network environment judgment WIFI" shape=diamond] needupdate[label="Whether there are resources to be updated" shape=diamond] startslientdl[label="Silent Download" shape=box] enterhall[label="Enter the game hall" shape=box] enterroom[label="get into the room" shape=box] resourceuptodate[label="Incomplete resources" 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] // 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 complete"] }



Interact with python

graphviz's powerful and convenient method of drawing diagram / flow chart makes us easily associate with the way of displaying 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 # Imported is a function # tree represents the trained model, that is, the fit (x) of DecisionTreeClassifier instance has been called_ train, y_ Train) method export_graphviz(tree, out_file='tree.dot', feature_names=['petal length', 'petal width'])

Enter the windows command line interface and switch cd to tree.dot Path, executing

dot -Tpng tree.dot -o tree.png



16 June 2020, 22:40 | Views: 4548

Add new comment

For adding a comment, please log in
or create account

0 comments