need to draw finite state machines

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

need to draw finite state machines

Ralph Boland
I am writing an open source project in Squeak for constructing
finite state machines from regular expressions.  It contains
a large number of algorithms (I am comparing them to determine
the best ones).  To help me debug the FSM minimization algorithms
and for other reasons I want a package that can draw a finite state machine
given the FSM as input.
But I don't want to implement this from scratch.

Is there any software in Squeak (or other version of Smalltalk from which
I can do a port) that draws finite state machines (directed edge labeled graphs)?
I need to be able to modify the graph easily in software (add and remove edges,
color nodes or edges, etc).  I am not particularly interested in being able to
draw a FSM interactively though such a facility wouldn't hurt.

Also if there is anyone who is interested in adding this functionality to my
project that would be great.

Thanks

Ralph Boland


Reply | Threaded
Open this post in threaded view
|

Re: need to draw finite state machines

Frank Shearar

----- Original Message -----
From: "Ralph Boland" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, April 17, 2007 5:24 PM
Subject: need to draw finite state machines


> I am writing an open source project in Squeak for constructing
> finite state machines from regular expressions.  It contains
> a large number of algorithms (I am comparing them to determine
> the best ones).  To help me debug the FSM minimization algorithms
> and for other reasons I want a package that can draw a finite state
machine
> given the FSM as input.
> But I don't want to implement this from scratch.
>
> Is there any software in Squeak (or other version of Smalltalk from which
> I can do a port) that draws finite state machines (directed edge labeled
> graphs)?
> I need to be able to modify the graph easily in software (add and remove
> edges,
> color nodes or edges, etc).  I am not particularly interested in being
able
> to
> draw a FSM interactively though such a facility wouldn't hurt.
>
> Also if there is anyone who is interested in adding this functionality to
my
> project that would be great.

What about Ned Konz's Connectors, as a place to start?

* http://bike-nomad.com/squeak/
* http://squeak.pbwiki.com/Connector%20Tutorial

frank


Reply | Threaded
Open this post in threaded view
|

Re: need to draw finite state machines

Bryce Kampjes
Frank Shearar writes:
 > What about Ned Konz's Connectors, as a place to start?
 >
 > * http://bike-nomad.com/squeak/
 > * http://squeak.pbwiki.com/Connector%20Tutorial

Connectors are a good as is GraphViz for layout. Both are
availible via SqueakMap. I use the two together to layout
control flow graphs in inspectors in Exupery.

Bryce

Reply | Threaded
Open this post in threaded view
|

Re: need to draw finite state machines

Göran Krampe
In reply to this post by Ralph Boland
Hi!

> I am writing an open source project in Squeak for constructing
> finite state machines from regular expressions.  It contains
> a large number of algorithms (I am comparing them to determine
> the best ones).  To help me debug the FSM minimization algorithms
> and for other reasons I want a package that can draw a finite state
> machine
> given the FSM as input.

Just use the Graphviz package, available on SM. We use it in Gjallar btw
and let it produce gifs (but it can produce lots of formats, including
svg), here are some screenshots:

http://www.gjallar.se/gjallar/8

> But I don't want to implement this from scratch.

The code needed is trivial, here is the method building the graphs shown
above:

        | graph stageStyle transitionStyle fillcolor |
        graph := GraphViz new.
        graph beDirected; name: self name.
        stageStyle := {#shape -> #ellipse. #fontsize -> 12. #style -> #filled}.
        graph add: #node with: stageStyle.
        transitionStyle := {#arrowsize -> 1.2. #fontsize -> 10}.
        graph add: #edge with: transitionStyle.
        stages do: [:stage |
                fillcolor := #gray.
                stage isClosed ifTrue: [fillcolor := #palegreen].
                stage isInbox ifTrue: [fillcolor := #red].
                stage isNew ifTrue: [fillcolor := #orange].
                graph add: stage name with: {#fillcolor -> fillcolor. #label -> (stage
name, '\n(',stage numberOfCases asString,')') }.
                graph ].
        self transitionsDo: [:trans |
                graph add: (trans from name -> trans to name) with: {#label -> trans
name}].
        ^graph


And then we just do "graph make: #gif" to get it out.

regards, Göran