From: Andreas K. <aku...@sh...> - 2009-07-21 05:27:48
|
> now - > > 1761: #we set u at the beginning of the queue > > 1762: if { [lsearch $queue $u] < 0 } { > > 1763: set queue [linsert $queue 0 $u] > > 1764: } > > Ok, this makes the index method (1) more complex, because now the > 'linsert' happens at $at, not 0. > > For 'struct::queue' the method to insert at the front is > 'unget'. Unfortunately there is no 'seach' method however, so using > struct::queue is not possible, contrary to what I thought before/above. > > > I have the feeling I should step the algorithm with an example to see > how this optimization works. > > (The other branch is clear: Node not visited before, mark as visited > and put on queue for processing). > > Your 'lsearch' <=3D> '$u ni $queue' Ok, should you choose to go for a rewrite using $at etc. to iterate over the queue then 'in' is not applicable anymore, because then the option -start is needed to start your search at 'at' instead of the beginning of the queue. Realized that a bit late, while walking through the park. -- So long, Andreas Kupries <aku...@sh...> <http://www.purl.org/NET/akupries/> Developer @ <http://www.activestate.com/> ------------------------------------------------------------------------------- |