Use topological sort when you need to process nodes in dependency order. Use it for DP on DAGs where you compute values from predecessors. Use it to detect cycles since only DAGs have valid topological orders.
Two main approaches exist: Kahn's algorithm (BFS with in-degree tracking) and DFS with post-order reversal. I'll explain both so you can choose based on your needs.