A diagram is an acyclic graph with (linear) maps associated with arcs. The problem considered is which set of relations characterizes the commutativity of a given diagram and how to find such a set of relations. The dependence among parallel paths of an acyclic graph is analyzed by means of 'preordered matroid', which is a composite algebraic structure of preorder and matroid. The notation of 'homotopy base' is introduced; any two bases are shown to be equicardinal, and a base can be found by an efficient greedy elimination algorithm, which, starting with a spanning set, deletes dependent elements one by one in an arbitrary order.