This post originated from an RSS feed registered with Python Buzz
by maxim khesin.
Original Post: generator-based graph algorithms - take 1, part deux
Feed Title: python and the web
Feed URL: http://feeds.feedburner.com/PythonAndTheWeb
Feed Description: blog dedicated to python and the networks we live in
So Jeremypointed out that my combo of graph visitors and generators reminded him of Dietmar Kuehl's "loop kernel" pattern. I went hunting for Dietmar's thesis just to find out that his uni link to the paper is dead. Fortunately my quiery to the boost list did not go ananswered. (And despite Dietmar's self-deprecation, the paper is still useful). I took a look at the paper, and sure enough the loop kernels sounds exactly like what I am doing, so I get the reinventor's credit ;). Or you tell me:
"An algorithm implemented as loop kernel consists of an object used to store the state of the algorithm, some functions modifying the current state (i.e. advancing the algorithm) and some functions used to query the current state. Hence, the algorithm does not solve the problem in one call but rather operates in small steps. After each step the user may decide to terminate or preempt the algorithm. Depending on the algorithm and the objective, it may also be useful to modify the problem while the algorithm is active. "
The only difference is the fact that the previous statemant carries a bit of flavor of a language without generators. While it is indeed true that a generator "an object [read: generator] used to store the state of the algorithm [read: function]", this is not something you think consciously in Python. Which reminds me that a lot of Design Patterns are language-specific.