#11950: Bug in topological_sort
----------------------------+-----------------------------------------------
   Reporter:  andrejv       |          Owner:  jason, ncohen, rlm
       Type:  defect        |         Status:  needs_review      
   Priority:  major         |      Milestone:  sage-4.7.3        
  Component:  graph theory  |       Keywords:                    
Work_issues:                |       Upstream:  N/A               
   Reviewer:                |         Author:                    
     Merged:                |   Dependencies:                    
----------------------------+-----------------------------------------------
Changes (by ncohen):

  * status:  new => needs_review


Comment:

 For the story, I stared at this algorithm for 50 minutes thinking it was
 returning a wrong ordering (I must have misread the ordering when first
 checking), to end up convinced that the orderings returned *HAD* to be
 valid.

 Only then I noticed that the problem lied in some vertices being returned
 twice. The fix was easy : once you have said that a vertex needs to be
 deactivated *DO NOT CONSIDER IT EVER AGAIN*. The fix lies in the lines :

 {{{
                 # This vertex may have been deactivated since we added it.
                 if bitset_not_in(activated, u):
                     stack.pop(-1)
                     continue
 }}}

 But I modified the code in some other places to make it clearer, and added
 some documentation. Sorry for that `:-)` !

 Nathann

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11950#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to