The user can then create vertices, edges and step through the algorithm by clicking on appropriate buttons. These individual algorithm morphs implement the different steps of the algorithm. We pushed as much other functionality nto the superclass as possible. Since the actual drawing of the graph and the animation of the algorithm is similar for all algorithms, we decided to reuse the code for doing these things. All this code is encapsulated in a GraphWindowMorph.
Every algorithm has as an instance variable a graphWindow.
It performs all it's animation on this instance variable. Any new graph algorithm can be easily implemented by just writing the code of the algorithm and reusing all the code for the drawing, animation and button handling. In order to allow the user to step through the animation, we made use of semaphores. What happens is that the algorithm proceeds for a certain extent and then stops to wait for user input - this wait is achieved by making the algorithm wait on a semaphore. The algorithm and the user interface are separate threads in this system.