Saturday, February 04, 2012

Graphviz and Finite Automata diagrams - III

Now, to bring down the state q3, I have used subgraph cluster, which works. If you try the same subgraph cluster technique for your graph, you may need to try to tweak few times.
digraph finite_state_machine {
    rankdir=LR;
    ranksep=0.5;
    
    node [shape = point, color=white, fontcolor=white]; start;
    node [shape = doublecircle, color=black, fontcolor=black]; q3;
    node [shape = circle]; q1;
   
    subgraph cluster0 {
    start -> q1;
      q1 -> q2 [ label = "a" ];
      q2 -> q1 [ label = "a" ];
      q1 -> q3 [ label = "b" ];
      q2 -> q2 [ label = "b" ];
    }
    subgraph cluster1 {
      q3;
    }
    q3 -> q2 [ label = "a" ];
    q3 -> q1 [ label = "b" ];
 
}

Graphviz and Finite Automata diagrams - II

another example with source code. But the state q3 is placed in the top side of the generated graph, which I don't like. It is not possible to place a arrow for the start circle without having the source->target syntax, so I did some workaround, by changing the color of the point to white and make it invisible, and it works!!

source code:
digraph finite_state_machine {
    rankdir=LR;
    ranksep=0.5;
     
    node [shape = point, color=white, fontcolor=white]; start;
    node [shape = doublecircle, color=black, fontcolor=black]; q3;
    node [shape = circle]; q1;
    start -> q1;
    q1 -> q2 [ label = "a" ];
    q2 -> q1 [ label = "a" ];
    q2 -> q2 [ label = "b" ];
 
    q3 -> q2 [ label = "a" ];
    q3 -> q1 [ label = "b" ];
    q1 -> q3 [ label = "b" ];
    
}


Graphviz and Finite Automata diagrams

Graphviz is a freeware application developed to draw diagrams for given specification. This specification or language is easier to understand, so easier to program (or specify).
 Graphviz is a collection of utilities, for different types of graphs. For the Finite automata diagrams, dot is used for directed graphs type. There is a specification for finite automata.

and the specification for that is shown below.
digraph finite_state_machine {
    rankdir=LR;
      node [shape = point, color=white, fontcolor=white]; start;
    node [shape = doublecircle, color=black, fontcolor=black]; q2;
    node [shape = circle]; q1;
    start -> q1;
      q1 -> q1 [ label = "0" ];
    q1 -> q2 [ label = "1" ];
    q2 -> q3 [ label = "1" ];
      q2 -> q3 [ label = "0" ];
      q3 -> q2 [ label = "0,1" ];
}


10th June 2023, Debian 12.0 (bookworm) distro is released

Bookworm Debian 12 has 11089 new packages are added to this Bookworm, with a total of over 64419 packages.  Most of the software in the dist...