Quick graphs?

Table of contents
Graphviz is a simple markup language to create simple quick graphs.
How to install
firstly to install it on linux u know what to ofc
on windows just use wsl
on mac :
brew install graphviz
Usage
create a file which has a (.gv) extension
here is a simple graphviz script :
digraph {
label="Life cycle of a programmer";
fontsize=10;
labelloc=top;
splines=curved;
node [shape=rectangle];
Coding -> Eating -> Sleeping -> Coding
}
This one renders the following graph :
first we specify the type of the graph :
graph for a normal graph, digraph for a directional graph (has arrows instead of simple links)
and then we open curly braces to begin the graph, we begin to tweak some properties. we might choose the title of it by modifying the “label” option, “fontsize” changes the font size (ofc), “labelloc” stands for label location ie. title location and splines are the linkes between the nodes. a node is anything that can be linked into another thing.
in line 6 we have the type selector node for selecting all nodes in the graph.
and then we can change its properties without affecting other stuff by putting them inside brackets.
and then to run it you can do :
neato graph.gv -Tpng -o output.png
well u might be asking… why does the command begin with “neato”
neato is the engine we are going to render the image with
option -Tpng means set the output file type to png
and -o to set the output file name
feel free to experiment with the different engine (each one gives a different feel), neato gives a rounded feel to the image (like the previous one)
for fast switching between the engines, take a look at this makefile :
all:
dot graph.gv -Tpng -o output.png
neato:
neato graph.gv -Tpng -o output.png
circo:
circo graph.gv -Tpng -o output.png
fdp:
fdp graph.gv -Tpng -o output.png
twopi:
twopi graph.gv -Tpng -o output.png
so to run it make sure the name of your file is graph.gv and to run it :
make <your engine, ex: neato>
for more info i recommend watching this youtube video : graphviz tutorial
these are the different stuff i made with it (chatgpt helped me quiet a lot ngl):
(this one made with dot engine)
code :
digraph {
node [shape=circle, style=filled];
features, output [shape=square, fillcolor="#FFEF00"];
overlap=scale;
rankdir=LR;
label="neural network"
features -> {1,2,3,4}
subgraph cluster_0 {
fillcolor=lightblue;
style=filled;
label="hidden layers";
{1,2,3,4} -> {a,b,c,d}
}
{a,b,c,d} -> output
}
graph {
overlap=scale;
node [style=filled, shape=circle];
A [label="linux distros", fillcolor="#FFEF00"];
{Debian, Ubuntu, Kali, "Arch btw", NixOs, EndeavourOs, Manjaro} -- A
}
// can't wait to see yours!!!
Subscribe to my newsletter
Read articles from ghiles touzi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
