7/27/2017 Dependency graph - Wikipedia
Dependency graph
From Wikipedia, the free encyclopedia
In mathematics, computer science and digital electronics, a dependency graph is a directed graph representing
dependencies of several objects towards each other. It is possible to derive an evaluation order or the absence of an
evaluation order that respects the given dependencies from the dependency graph.
Contents
1 Definition
2 Recognizing impossible evaluations
3 Deriving an evaluation order
4 Examples
5 See also
6 References
Definition
Given a set of objects and a transitive relation with
modeling a dependency "a needs b evaluated first", the
dependency graph is a graph with and T being
the transitive closure of R.
For example, assume a simple calculator. This calculator supports
assignment of constant values to variables and assigning the sum of
exactly 2 variables to a third variable. Given several equations like
"A = B+C; B = 5+D; C=4; D=2;", then and
. You can derive this relation directly: A depends on B and C, because you can add
two variables if and only if you know the values of both variables. Thus, B must be calculated before A can be
calculated. However, the values of "C" and D's are known immediately, because they are number literals.
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
https://en.wikipedia.org/wiki/Dependency_graph 1/3
7/27/2017 Dependency graph - Wikipedia
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 . Furthermore, there
can be more than a single 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.
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.
Spreadsheet calculators. They need to derive a correct calculation order similar to that one in the example
used in this article.
Web Forms standards such as XForms to know what visual elements to update if data in the model changes.
Dependency graphs are one aspect of:
Manufacturing Plant Types. Raw materials are processed into products via several dependent stages.
Job Shop Scheduling. A collection of related theoretical problems in computer science.
See also
Call graph
Topological sort
Data dependency
References
Balmas, Francoise (2001) Displaying dependence graphs: a hierarchical approach (http://www.ai.univ-paris
8.fr/~fb/version-ps/pdep.ps), [1] (http://doi.ieeecomputersociety.org/10.1109/WCRE.2001.957830) wcre,
p. 261, Eighth Working Conference on Reverse Engineering (WCRE'01)
Retrieved from "https://en.wikipedia.org/w/index.php?title=Dependency_graph&oldid=781812363"
Categories: Directed graphs Application-specific graphs
This page was last edited on 23 May 2017, at 10:59.
https://en.wikipedia.org/wiki/Dependency_graph 2/3
7/27/2017 Dependency graph - Wikipedia
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply.
By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia is a registered trademark
of the Wikimedia Foundation, Inc., a non-profit organization.
https://en.wikipedia.org/wiki/Dependency_graph 3/3