Topological sorting [OI]

Topological sorting

 

Pictured first asked DAG

 

Algorithm:
First, a node of degree 1 is added to the queue
in each case taking the first team point u, and u omitted in the figure adjacent edges
continue to point to a degree enqueue

In the end,

If there is no point of degree 1, the figure is not DAG

 

By topological sort can give the DAG node number may be used to determine DAG

 

Because DAG strict order, there is no connection side from back to front, so you can do dp

Guess you like

Origin www.cnblogs.com/dudujerry/p/11622172.html
Recommended