Sunday, February 5, 2017

How to install and use Graphviz on Ubuntu

Graphviz is an open source tool for creating diagrams on ubuntu, you can create flowchart, data structure and all kind of scientific diagrams using graphviz.

Graphviz consist of several command line programs such as dot, neato, fdp, circo, twopi, and there are also graphical (GUI) based tool such as dotty, lefty, lneato.

How to install graphviz on ubuntu:
sudo apt-get install graphviz

Basically after installing graphviz, you will get all of these tools:

Graph layout programs
  1.        dot      [filter for hierarchical layouts of graphs]
  2.        neato  [filter for symmetric layouts of graphs]
  3.        twopi  [filter for radial layouts of graphs]
  4.        circo   [filter for circular layout of graphs]
  5.        fdp      [filter for symmetric layouts of graphs]
Graph drawing programs
  1.        lefty      [A Programmable Graphics Editor]
  2.        lneato   [lefty + neato]
  3.        dotty     [lefty + dot]
Graph layout enhancement
  1.        gvcolor    [flow colors through a ranked digraph]
  2.        unflatten  [adjust directed graphs to improve layout aspect ratio]
  3.        gvpack     [merge and pack disjoint graphs]
Graph information and transformation
  1.        gc               [count graph components]
  2.        acyclic       [make directed graph acyclic]
  3.        nop            [pretty-print graph file]
  4.        ccomps      [connected components filter for graphs]
  5.        sccmap      [extract strongly connected components of directed graphs]
  6.        tred            [transitive reduction filter for directed graphs]
  7.        dijkstra      [single-source distance filter]
  8.        bcomps     [biconnected components filter for graphs]
  9.        gvpr          [graph pattern scanning and processing language]
  10.        prune        [prune directed graphs]

When using graphviz, there is a learning curve that we need to understand before we can actually use it to create diagram, hopefully with this example can give you an idea of how graphviz works.

Creating a simple diagram using graphviz

Open gedit or other text editor and then copy paste the code below:
digraph G {
start_here [label="it's me
(start here)"];
start_here -> 2017;
bloglife1 [label="create more blog"];
bloglife2 [label="make more money"];
bloglife3 [label="become rich"];
life_goal1[label="married with someone"];
life_goal2[label="have a baby"];
life_goal3[label="happy life"];
2017 -> bloglife1 -> bloglife2 -> bloglife3;
2017 -> life_goal1 -> life_goal2;
node [shape=box,style=filled,color=".7 .3 1.0"];
life_goal2 -> life_goal3

Save as 'diagram.txt', and then go to the command line and run this to create the diagram:
dot -Tpng diagram.txt -o diag.png

Open diag.png to see the result, it should be like this:

No comments:

Post a Comment