------
## 最终结论
```python
from .node import Node
from .topological_ordering import topological_ordering


"""
Driver to test topological ordering
"""
def main():
    # Case 1: Wikipedia graph
    # Output: 5 7 3 11 8 10 2 9
    
    five = Node(5)
    seven = Node(7)
    three = Node(3)
    eleven = Node(11)
    eight = Node(8)
    two = Node(2)
    nine = Node(9)
    ten = Node(10)

    five.outgoing_nodes = [eleven]
    five.incoming_nodes = []
    seven.outgoing_nodes = [eleven, eight]
    seven.incoming_nodes = []
    three.outgoing_nodes = [eight, ten]
    three.incoming_nodes = []
    eleven.incoming_nodes = [five, seven]
    eleven.outgoing_nodes = [two, nine, ten]
    eight.incoming_nodes = [seven, three]
    eight.outgoing_nodes = [nine]
    two.incoming_nodes = [eleven]
    two.outgoing_nodes = []
    nine.incoming_nodes = [eleven, eight]
    nine.outgoing_nodes = []
    ten.incoming_nodes = [eleven, three]
    ten.outgoing_nodes = []

    try:
        [print(x.value, end=" ") for x in topological_ordering([five, seven, three, eleven, eight, two, nine, ten])]
    except Exception as e:
        print(e)
    print()


    # Case 2: GeekforGeeks example
    # Output: 4 5 0 2 3 1

    five = Node(5)
    zero = Node(0)
    four = Node(4)
    
    five.incoming_nodes = []
    
    zero.outgoing_nodes = []
    
   
   
   
  
   
 
   
 
   
  
   
 
   
  
 
    

  
    

  

  
 
   

   

 
   

   

 
 

  
 

  
  
  

  
  
  

 
  
  

 
  
 


  
    

  
    

  

  
 
   

   

 
   

   

 
  

  
  
  

  
  
  

 
  
  

 
  
 


  
    
  
  
  



    
     
        
      
        
      
        
      
     
    
     
        
      
        
      
        
      
     
    
     
        
      
        
      
        
      
     
    
     
        
      
        
      
        
      
     
    
     
        
      
        
      
        
      
     
    
     
        
      
        
      


    
     
        

      

        
        
      

        
        
      

        

      

        
        
      

        
        
      

        

      

        
        
      

        
        
      


    
    
    
    
    
    


    
    
    
    
    
    


    
    
    
    
    
    


    
    
    
    
    
    



    
    
    
    
    
    


    
    
    
    
    
    


    
    
    
    
    
    



    
    
    
    
    
    


    
    
    
    
    
    


    
    
    
    
    
    



    
    
    
    
    
    


    
    
    
    
    
    


    
    
    
    
    
    



    
  


  
  


  
  


  
  



  
  


  
  


  
  



  
  


  
  


  
    
  
  
  



    
     

     

     

     

     

     

     


    

    
     

     

     

     

     

     


    

    
     

     

     

     

     


    

    
     

     


    

    
     
       
       
       
       
       
       
        
        
        
        
        
        
        
        
        


        

        

        

        

        

        


        


        


        




        




        




        




        




        




        




        




        




        




         
         
         
         
         
         
         
         
         

         

         

         

         

         

         

         

         

         

         

         

         

         

          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
          
        
          
           
            
             
              
               
                
                 
                  
                   
                    
                     
                      
                       
                        
                         
                          
                           
                            
                             
                              
                               
                                
                                 
                                  
                                   
                                    
                                     
                                      
                                       
                                        
                                         
                                          
                                           
                                            
                                             
                                              
                                               
                                                
                                                 
                                                  
                                                   
                                                    
                                                     
                                                      
                                                       
                                                        
                                                         
                                                          
                                                           
                                                            
                                                             
                                                              
                                                               
                                                                
                                                                 
                                                                  
                                                                   
   
 


 


 


 


 


 



 
    
 


 


 


 


 


 



 
    
 

four.outgoing_nodes=[zero,one]

one=Node(1)

two=Node(2)

three=Node(3)

five.outgoing_nodes=[two,zero]

four.outgoing_nodes=[zero,one]

two.incoming_nodes=[five]

two.outgoing_nodes=[]#correctedmissinginitialization

zero.incoming_nodes=[five,four]

one.incoming_nodes=[four]

three.incoming_nodes=[two]

three.outgoing_nodes=[one]

try:

[print(x.value,end="")forxin topological_ordering([zero ,one ,two ,three ,four ,five])]

exceptExceptionase:

print(e)

print()

#Case3:CookingwithInteractivePython#Output:

milk=Node("3/4cupmilk")

egg=Node("1egg")

oil=Node("1Tbloil")

mix=Node("1cupmix")

milk .incoming _nodes=[] egg .incoming _nodes=[] oil .incoming _nodes=[] griddle .incoming _nodes=[] pour .outgoing _nodes=[] eat .outgoing _nodes=[] syrup=Node("heatsyrup") griddle=Node("heatgriddle") pour=Node("pour1/4cup") turn=Node("turnwhenbubbly") eat=Node("eat") milk .outgoing _nodes=[mix] egg .outgoing _nodes=[mix] oil .outgoing _nodes=[mix] mix .incoming _nodes=[milk ,egg ,oil] mix .outgoing _nodes=[syrup ,pour] griddle .outgoing _nodes=[pour] pour .incoming _nodes=[mix ,griddle] pour .outgoing _nodes=[turn] turn .incoming _nodes=[pour] turn .outgoing _nodes=[eat] syrup .incoming _nodes=[mix] syrup .outgoing _nodes=[eat] eat .incoming _nodes=[syrup ,turn]

try:

[print(x.value,end="")forxin topological_ordering([milk ,egg ,oil ,mix ,syrup ,griddle ,pour ,turn ,eat])]

exceptExceptionase:

print(e)

print()

if__name__=="__main__":

main()