TopSort in Python?

Carl Banks pavlovevidence at gmail.com
Fri Jan 18 20:08:53 EST 2008


On Jan 18, 7:01 pm, Paddy <paddy3... at googlemail.com> wrote:
> On Jan 18, 9:47 pm, startec... at gmail.com wrote:> Tim,
>
> > Thanks for the topsort code.  It would be useful in a project I'm
> > working on.  Can I use the code for free under public domain?  Thanks!
>
> When I needed one I didn't know the name. I'm curious, how did you
> know to look for the topological sort algorithm by name?

I spent quite a bit of time looking for this one myself.  It was quite
a stumper.  Sometimes Google gets us in the habit of just firing
random search terms when we ought to be thinking it out.

After quite of bit of dead end searching--like a week--I stepped back,
thought about what I was looking for.  I wanted a sort of dependency
system: A must happen before B.  What other programs do that?  make,
of course.  I looked at the documents for make and found the term
"directed acyclic graph", and pretty much instantly knew I had it.
(It seems silly in retrospect that I didn't think of graphs before
that, but then it also seems silly no one invented movable type before
1436.)

Once I had that term, a quick Google search led me to the Wikipedia
article, which led me to the topsort algorithm.  I did a dance of joy.


Ten minutes later I saw it mentioned it on comp.lang.python.


Carl Banks



More information about the Python-list mailing list