Designing a graph study program

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue May 8 07:29:04 EDT 2007


In <1178622700.228390.237310 at n59g2000hsh.googlegroups.com>, andrea wrote:

> But I have some design doubts, I'd like to keep the algorithm (for
> example bfs) as clean as possible, being independent from the drawing
> methods.
> And how could I make it step through algorithms without having a more
> complicated code? Maybe using threads?

Create an API that informs some "observer" about actions like visiting a
node, traversing or adding an egde and so on.  This way you can register
callbacks that translate between the graph and the GUI.

If you don't want to change the algorithm or graph and node classes this
notification can be injected by wrapper classes to some degree.

For very fine grained observation of an algorithm you might try to
implement a step by step debugger.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list