Dependency diagram
   HOME

TheInfoList



OR:

In mathematics,
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includi ...
and
digital electronics Digital electronics is a field of electronics involving the study of digital signals and the engineering of devices that use or produce them. This is in contrast to analog electronics and analog signals. Digital electronic circuits are usual ...
, a dependency graph is a
directed graph In mathematics, and more specifically in graph theory, a directed graph (or digraph) is a graph that is made up of a set of vertices connected by directed edges, often called arcs. Definition In formal terms, a directed graph is an ordered pa ...
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.


Definition

Given a set of objects S and a
transitive relation In mathematics, a relation on a set is transitive if, for all elements , , in , whenever relates to and to , then also relates to . Each partial order as well as each equivalence relation needs to be transitive. Definition A ho ...
R \subseteq S \times S with (a,b) \in R modeling a dependency "''a'' depends on ''b''" ("''a'' needs ''b'' evaluated first"), the dependency graph is a graph G = (S, T) with T \subseteq R the
transitive reduction In the mathematical field of graph theory, a transitive reduction of a directed graph is another directed graph with the same vertices and as few edges as possible, such that for all pairs of vertices , a (directed) path from to in exists i ...
of ''R''. For example, assume a simple calculator. This calculator supports assignment of constant values to variables and assigning the sum of exactly two variables to a third variable. Given several equations like "''A'' = ''B''+''C''; ''B'' = 5+''D''; ''C''=4; ''D''=2;", then S=\ and R=\. You can derive this relation directly: ''A'' depends on ''B'' and ''C'', because you can add two variables
if and only if In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is b ...
you know the values of both variables. Thus, ''B'' must be calculated before ''A'' can be calculated. However, the values of ''C'' and ''D'' 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 In mathematics, particularly graph theory, and computer science, a directed acyclic graph (DAG) is a directed graph with no directed cycles. That is, it consists of vertices and edges (also called ''arcs''), with each edge directed from one v ...
, and an evaluation order may be found by
topological sorting In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge ''uv'' from vertex ''u'' to vertex ''v'', ''u'' comes before ''v'' in the ordering. For in ...
. Most topological sorting algorithms are also capable of detecting cycles in their inputs; however, it may be desirable to perform
cycle detection In computer science, cycle detection or cycle finding is the algorithmic problem of finding a cycle in a sequence of iterated function values. For any function that maps a finite set to itself, and any initial value in , the sequence of itera ...
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 In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly. Such modules are also known as mutually recursive. Overview Circular depend ...
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 n : S \rightarrow \mathbb of the objects that form the nodes of the dependency graph so that the following equation holds: n(a) < n(b) \Rightarrow (a, b) \notin R with a, b \in S. This means, if the numbering orders two elements a and b so that a will be evaluated before b, then a must not depend on b. There can be more than one correct evaluation order. In fact, a correct numbering is a
topological order In physics, topological order is a kind of order in the zero-temperature phase of matter (also known as quantum matter). Macroscopically, topological order is defined and described by robust ground state degeneracy and quantized non-Abelian ...
, 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 In computer science, a trace is a set of strings, wherein certain letters in the string are allowed to commute, but others are not. It generalizes the concept of a string, by not forcing the letters to always be in a fixed order, but allowing certa ...
as follows: * A function \phi : S \to \Sigma labels each vertex with a symbol from the alphabet \Sigma * There is an edge a \to b or b \to a if and only if (\phi(a),\phi(b)) is in the
dependency relation In computer science, in particular in concurrency (computer science), concurrency theory, a dependency relation is a binary relation on a finite domain \Sigma, symmetric relation, symmetric, and reflexive relation, reflexive; i.e. a finite toleran ...
D. * 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
monoid In abstract algebra, a branch of mathematics, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being 0. Monoid ...
al operation (S_,R_)=(S_1,R_1)\bullet (S_2,R_2) takes the
disjoint union In mathematics, a disjoint union (or discriminated union) of a family of sets (A_i : i\in I) is a set A, often denoted by \bigsqcup_ A_i, with an injection of each A_i into A, such that the images of these injections form a partition of A ( ...
S_=S_1 \sqcup S_2 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, :R_ = R_1 \sqcup R_2 \sqcup \ The identity is the empty graph.


Examples

Dependency graphs are used in: * Automated software
installer Installation (or setup) of a computer program (including device drivers and plugins), is the act of making the program ready for execution. Installation refers to the particular configuration of a software or hardware with a view to making it us ...
s: They walk the graph looking for software packages that are required but not yet installed. The dependency is given by the
coupling A coupling is a device used to connect two shafts together at their ends for the purpose of transmitting power. The primary purpose of couplings is to join two pieces of rotating equipment while permitting some degree of misalignment or end mov ...
of the packages. * Software build scripts such as
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, an ...
Make Make or MAKE may refer to: * Make (magazine), a tech DIY periodical *Make (software), a software build tool *Make, Botswana, in the Kalahari Desert *Make Architects Make Architects is an international architecture practice headquartered in Londo ...
,
Node In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex). Node may refer to: In mathematics * Vertex (graph theory), a vertex in a mathematical graph *Vertex (geometry), a point where two or more curves, lines ...
npm install, php composer,
Twitter Twitter is an online social media and social networking service owned and operated by American company Twitter, Inc., on which users post and interact with 280-character-long messages known as "tweets". Registered users can post, like, and ...
bower install, or
Apache Ant Apache Ant is a software tool for automating software build processes which originated from the Apache Tomcat project in early 2000 as a replacement for the Make build tool of Unix. It is similar to Make, but is implemented using the Java langua ...
. They need to know what files have changed so only the correct files need to be recompiled. * In
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
technology and
formal language In logic, mathematics, computer science, and linguistics, a formal language consists of words whose letters are taken from an alphabet and are well-formed according to a specific set of rules. The alphabet of a formal language consists of sy ...
implementation: **
Instruction scheduling In computer science, instruction scheduling is a compiler optimization used to improve instruction-level parallelism, which improves performance on machines with instruction pipelines. Put more simply, it tries to do the following without changing ...
: Dependency graphs are computed for the operands of
assembly Assembly may refer to: Organisations and meetings * Deliberative assembly, a gathering of members who use parliamentary procedure for making decisions * General assembly, an official meeting of the members of an organization or of their representa ...
or intermediate instructions and used to determine an optimal order for the instructions. **
Dead code elimination In compiler theory, dead-code elimination (also known as DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove code which does not affect the program results. Removing such code has several benefits: ...
: 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 for incremental computing when graph structure changes. *
Spreadsheet A spreadsheet is a computer application for computation, organization, analysis and storage of data in tabular form. Spreadsheets were developed as computerized analogs of paper accounting worksheets. The program operates on data entered in c ...
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 XForms is an XML format used for collecting inputs from web forms. XForms was designed to be the next generation of HTML / XHTML forms, but is generic enough that it can also be used in a standalone manner or with presentation languages other th ...
to know what visual elements to update if data in the model changes. * Video games, especially puzzle and adventure video games, which are frequently designed as a graph of dependent relationships between in-game actions. Dependency graphs are one aspect of: * Manufacturing plant types: Raw materials are processed into products via several dependent stages. *
Job shop scheduling Job-shop scheduling, the job-shop problem (JSP) or job-shop scheduling problem (JSSP) is an optimization problem in computer science and operations research. It is a variant of optimal job scheduling. In a general job scheduling problem, we are give ...
: A collection of related theoretical problems in computer science.


See also

*
Call graph A call graph (also known as a call multigraph) is a control-flow graph, which represents calling relationships between subroutines in a computer program. Each node represents a procedure and each edge ''(f, g)'' indicates that procedure ''f'' cal ...
* Topological sort *
Data dependency A data dependency in computer science is a situation in which a program statement (instruction) refers to the data of a preceding statement. In compiler theory, the technique used to discover data dependencies among statements (or instructions) is c ...


References

{{Reflist *Balmas, Francoise (2001)
Displaying dependence graphs: a hierarchical approach
'

wcre, p. 261, Eighth Working Conference on Reverse Engineering (WCRE'01) Directed graphs Application-specific graphs