Introduction - If you have any usage issues, please Google them yourself
A topological sort
The basic steps of the algorithm are as follows:
1. Select a vertex of 0 from the diagram and output the vertex;
2. Remove the vertex and its associated arc from the diagram, and adjust the entry of the arc head of the deleted arc (entry - 1);
Repeat execution, until all the vertices are output, the topological sort is completed or the graph has no more than 0 at the vertex (which indicates that the original graph contains the loop).