Showing posts with label Graphs. Show all posts
Showing posts with label Graphs. Show all posts

Wednesday, November 2, 2011

Graph's visualization in Linux

A few days ago my friend show me a very simple and convenient program to visualize graphs - "graphviz". It's free and can be used in Linux, Solaris, Windows and Mac. For drawing graphs "graphviz" uses DOT language.

Let's create a simple graph. Open text editor and paste this code:

digraph SimpleGraph {
    rankdir=LR;
    node [shape=circle];
    ranksep=0.5;
    node [style=dashed];
    0 -> 1 [label="A"];
    node [style=solid];
    0 -> 2 [label="B"];
    1 -> 3 [label="C"];
    2 -> 1 [label="D", style=dotted];
    2 -> 3 [label="E", style=dotted];
    2 -> 4 [label="F"];
    3 -> 5 [label="G"];
    4 -> 5 [label="H"];
}