我需要知道我应该为以下情况选择哪种算法

I need to know which algorithm i should choose for following situation

我有四个组件 A,B,C,D。哪个依赖流像 A -> B -> C -> D。 A依赖于B,B依赖于C,C依赖于D。在这种情况下我应该使用什么类型的算法。

您要查找的算法是拓扑排序

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of
vertices such that for every directed edge u-v, vertex u comes before v in the 
ordering. Topological Sorting for a graph is not possible if the graph is not 
a DAG.