First, the definition of topological ordering
1.AOV mesh: In a graph that represents a project, a vertex is used to represent the activity, and an arc is used to denote the priority relationship between the activities, so that the graph is the vertex of the active network, called the AOV Network (activity on Vertex Network).
2. Topology sequence: Set G={v,e} is a forward graph with n vertices, the vertex sequence v1,v2,...,vn in V, satisfies if there is a path from Vertex VI to VJ, in the vertex sequence, vertex VI must precede VJ, such vertex sequence is a topological sequence.
3. Topological ordering: The topological ordering is the process of constructing a topological sequence of a forward graph. The structure will have two results, if all the vertices of this network are output, then it is no ring (loop) of the AOV network, if the output of the vertex less, indicating that the network exists ring (loop), not AOV network.
For example
This AOV topology sequence is more than one. Sequence V0v1v2v3v4v5v6v7v8v9v10v11v12v13v14v15v16 is a topological sequence, sequence v0v1v4v3v2v7v6v5v8v10v9v12v11v14v13v15v16.
Second, topological sorting algorithm
1. Basic idea of topological sorting algorithm:
Select a vertex output of 0 in the AoV net, then delete the vertex and remove the arc with this vertex as the tail, continue repeating this step until all vertices in the output or AOV are not present in the 0-degree vertex.
Data structure (34) Topology sequencing