Skip to content
BENIBIX Learn

Directed Acyclic Graph (DAG)

Development🧮 Algorithms & Data StructuresData Structures

Also known as DAG, Acyclic Graph, Directed Acyclic Graphs

A graph of one-way arrows with no loops. It shows what must come first.

Think of it like

Think of it like a family tree. Arrows go from mums and dads to kids, and never back up.

Example

A data job has five steps. Get data comes first, then clean data, then two reports, then one email. That plan is a DAG.

Why it matters

With no loops, a program can always find a safe order to run the steps in.

Definition

A directed acyclic graph is a graph where every link points one way and no path loops back. Directed means each edge has an arrow. Acyclic means you can never follow the arrows back to where you began. That makes it perfect for steps that must happen in order. Task runners, build tools and Git history all use one.
Every arrow points forward. An arrow back would make a loop.

Common mistake

Adding a step that depends on a later step. That makes a loop, and the plan can never finish.

Key takeaways

  1. 1
    One-way arrows. Each edge points from first to next.
  2. 2
    No loops. You never come back to the start.
  3. 3
    Gives an order. There is always a safe order to run.

Compare