algorithm for sorting functional expressions

Fredrik Lundh fredrik at pythonware.com
Mon Dec 4 03:36:25 EST 2006


Marc 'BlackJack' Rintsch wrote:

>> So I suspect that this is a common problem for those familiar with
>> partially ordered sets or directed graphs. I'm wondering if anyone else
>> is familiar with this problem and knows an efficient algorithm that
>> will solve it. It would be good if any such algorithm would be able to
>> check for circular definitions in the input.
> 
> You are looking for "topological sort".  Feed a search engine with that
> term.  :-)

including "python" in the search request might be a good idea.  here's a 
topsort in Python:

http://mail.python.org/pipermail/python-list/1999-July/006660.html

(note that most code in that module is for analyzing cycles in case the 
sort fails, not for the sort itself).

</F>




More information about the Python-list mailing list