Definition
Recognizing impossible evaluations
In a dependency graph, the cycles of dependencies (also called circular dependencies) lead to a situation in which no valid evaluation order exists, because none of the objects in the cycle may be evaluated first. If a dependency graph does not have any circular dependencies, it forms a directed acyclic graph, and an evaluation order may be found by topological sorting. Most topological sorting algorithms are also capable of detecting cycles in their inputs; however, it may be desirable to perform cycle detection separately from topological sorting in order to provide appropriate handling for the detected cycles. Assume the simple calculator from before. The equation system "''A''=''B''; ''B''=''D''+''C''; ''C''=''D''+''A''; ''D''=12;" contains a circular dependency formed by ''A'', ''B'' and ''C'', as ''B'' must be evaluated before ''A'', ''C'' must be evaluated before ''B'' and ''A'' must be evaluated before ''C''.Deriving an evaluation order
A correct evaluation order is a numbering of the objects that form the nodes of the dependency graph so that the following equation holds: with . This means, if the numbering orders two elements and so that will be evaluated before , then must not depend on . There can be more than one correct evaluation order. In fact, a correct numbering is a topological order, and any topological order is a correct numbering. Thus, any algorithm that derives a correct topological order derives a correct evaluation order. Assume the simple calculator from above once more. Given the equation system "''A'' = ''B''+''C''; ''B'' = 5+''D''; ''C''=4; ''D''=2;", a correct evaluation order would be (''D'', ''C'', ''B'', ''A''). However, (''C'', ''D'', ''B'', ''A'') is a correct evaluation order as well.Monoid structure
An acyclic dependency graph corresponds to a trace of a trace monoid as follows: * A function labels each vertex with a symbol from the alphabet * There is an edge or if and only if is in the dependency relation . * Two graphs are considered to be equal if their labels and edges correspond. Then the string consisting of the vertex labels ordered by a correct evaluation order corresponds to a string of a trace. The monoidal operation takes the disjoint union of two graphs' vertex sets, preserves the existing edges in each graph, and draws new edges from the first to the second where the dependency relation allows, : The identity is the empty graph.Examples
Dependency graphs are used in: * Automated software installers: They walk the graph looking for software packages that are required but not yet installed. The dependency is given by the coupling of the packages. * Software build scripts such as Unix Make, Node npm install, php composer, Twitter bower install, or Apache Ant. They need to know what files have changed so only the correct files need to be recompiled. * In compiler technology and formal language implementation: ** Instruction scheduling: Dependency graphs are computed for the operands of assembly or intermediate instructions and used to determine an optimal order for the instructions. ** Dead code elimination: If no side effected operation depends on a variable, this variable is considered dead and can be removed. * Dynamic graph analytics: GraphBolt and KickStarter capture value dependencies forSee also
* Call graph *References
{{Reflist *Balmas, Francoise (2001)