Given a graph of n vertices, you have to topologically sort that graph.
Example:
Input:
If there is graph be like the below:

Output: A → B → C → D → E → F → G
Topological sort
It is a technique where each node comes after it's parent node.
Here, node A and node B are two nodes which have no parents. So A comes first then D node comes but to print F we need D and E both the nodes so it is not possible. Then comes node B and node C also available and then E, F and G come.
Algorithm:
To solve this problem we follow this process:
C++ implementation:
Output