ArticleslgStudy

computer science

Directed acyclic graph

Directed acyclic graph is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Directed acyclic graph rather than just read about it. In short: 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 vertex to another, such that following those directions will never form a closed loop.

Directed acyclic graph — main illustration
Directed acyclic graph — illustration

Key takeaways

  • Directed acyclic graph belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Directed acyclic graph to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Directed acyclic graph from memory before moving on to harder problems.

Reference excerpt

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 vertex to another, such that following those directions will never form a closed loop. A directed graph is a DAG if and only if it can be topologically ordered, by arranging the vertices as a linear ordering that is consistent with all edge directions. DAGs have numerous scientific and computational applications, ranging from biology (evolution, family trees, epidemiology) to information science (citation networks) to computation (scheduling). Directed acyclic graphs are also called acyclic directed graphs or acyclic digraphs.

Definitions A graph is formed by vertices and by edges connecting pairs of vertices, where the vertices can be any kind of object that is connected in pairs by edges. In the case of a directed graph, each edge has an orientation, from one vertex to another vertex. A walk in a directed graph is a (finite or infinite) sequence (v1,v2,…) of vertices such that each consecutive pair (vi,vi+1) is connected by a directed edge. A path is a walk where all vertices are distinct. A cycle is a walk (v1,v2,…,vn) where the only repeated vertex is vn=v1, meaning the last vertex equals the first vertex. A directed acyclic graph is a directed graph that has no cycles.

Mathematical properties

Reachability relation, transitive closure, and transitive reduction

The reachability relation of a DAG can be formalized as a partial order ≤ on the vertices of the DAG. In this partial order, two vertices u and v are ordered as u ≤ v exactly when there exists a directed path from u to v in the DAG; that is, when u can reach v (or v is reachable from u). However, different DAGs may give rise to the same reachability relation and the same partial order. For example, a DAG with two edges u → v and v → w has the same reachability relation as the DAG with three edges u → v, v → w, and u → w. Both of these DAGs produce the same partial order, in which the vertices are ordered as u ≤ v ≤ w. The transitive closure of a DAG is the graph with the most edges that has the same reachability relation as the DAG. It has an edge u → v for every pair of vertices (u, v) in the reachability relation ≤ of the DAG, and may therefore be thought of as a direct translation of the reachability relation ≤ into graph-theoretic terms. The same method of translating partial orders into DAGs works more generally: for every finite partially ordered set (S, ≤), the graph that has a vertex for every element of S and an edge for every pair of elements in ≤ is automatically a transitively closed DAG, and has (S, ≤) as its reachability relation. In this way, every finite partially ordered set can be represented as a DAG.

The transitive reduction of a DAG is the graph with the fewest edges that has the same reachability relation as the DAG. It has an edge u → v for every pair of vertices (u, v) in the covering relation of the reachability relation ≤ of the DAG. It is a subgraph of the DAG, formed by discarding the edges u → v for which the DAG also contains a longer directed path from u to v. Like the transitive closure, the transitive reduction is uniquely defined for DAGs. In contrast, for a directed graph that is not acyclic, there can be more than one minimal subgraph with the same reachability relation. Transitive reductions are useful in visualizing the partial orders they represent, because they have fewer edges than other graphs representing the same orders and therefore lead to simpler graph drawings. A Hasse diagram of a partial order is a drawing of the transitive reduction in which the orientation of every edge is shown by placing the starting vertex of the edge in a lower position than its ending vertex.

Topological ordering

A topological ordering of a directed graph is an ordering of its vertices into a sequence, such that for every edge the start vertex of the edge occurs earlier in the sequence than the ending vertex of the edge. A graph that has a topological ordering cannot have any cycles, because the edge into the earliest vertex of a cycle would have to be oriented the wrong way. Therefore, every graph with a topological ordering is acyclic. Conversely, every directed acyclic graph has at least one topological ordering. The existence of a topological ordering can therefore be used as an equivalent definition of a directed acyclic graphs: they are exactly the graphs that have topological orderings. In general, this ordering is not unique; a DAG has a unique topological ordering if and only if it has a directed path containing all the vertices, in which case the ordering is the same as the order in which the vertices appear in the path. The family of topological orderings of a DAG is the same as the family of linear extensions of the reachability relation for the DAG, so any two graphs representing the same partial order have the same set of topological orders.

Convex hull A set X of vertices of an acyclic digraph D is convex if X≠∅ and there is no directed path between vertices of X which contains a vertex not in X. Expressed differently, a set X of vertices is convex if for every pair of vertices u, v ∈ X, every directed path from u to v is entirely contained within X. The convex hull of a subset of vertices S is the smallest convex set containing S. That is, the convex hull of a set S in a DAG consists of all vertices that lie on any directed path between two vertices in S. It can be computed as the intersection of the set of all vertices that are reachable from any vertex in S (including S itself) and the set of all vertices that can reach any vertex in S (including S itself).

Combinatorial enumeration The graph enumeration problem of counting directed acyclic graphs was studied by Robinson (1973). The number of DAGs on n labeled vertices, for n = 0, 1, 2, 3, … (without restrictions on the order in which these numbers appear in a topological ordering of the DAG) is

1, 1, 3, 25, 543, 29281, 3781503, … (sequence A003024 in the OEIS). These numbers may be computed by the recurrence relation

… excerpt ends here. Continue reading the full article.

Illustrations

Directed acyclic graph: Example of a directed acyclic graph
Example of a directed acyclic graph
Directed acyclic graph illustration
Directed acyclic graph: A Hasse diagram representing the partial order of set inclusion (⊆) among the subsets of a three-element set
A Hasse diagram representing the partial order of set inclusion (⊆) among the subsets of a three-element set
Directed acyclic graph illustration
Directed acyclic graph illustration

Worked examples

Example 1 — a first encounter with Directed acyclic graph

Start with the simplest possible case. Write down what Directed acyclic graph claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Directed acyclic graph before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Directed acyclic graph ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Directed acyclic graph

In research
Directed acyclic graph appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Directed acyclic graph in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Directed acyclic graph is common in secondary-school and first-year university syllabi. It links to neighbouring topics Causality, Data structures, Directed acyclic graphs, so understanding it makes those chapters shorter.
In everyday life
Look for Directed acyclic graph outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Directed acyclic graph” →

How to study Directed acyclic graph in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Directed acyclic graph means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Directed acyclic graph out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Directed acyclic graph in simple terms?

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 vertex to another, such that following those directions will n…

Why does Directed acyclic graph matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Directed acyclic graph?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Directed acyclic graph.

Tags

  • Causality
  • Data structures
  • Directed acyclic graphs
  • Directed graphs
  • Network science
  • Order theory
  • Scheduling algorithms
  • Software architecture

Keep exploring