Bifalgorithm post · Brisk · Chapter 1

What is a directed acyclic graph, or DAG?

What is a directed acyclic graph, or DAG? (Brisk · Chapter 1) — "DAG (directed, acyclic graph). One common use of graphs is to represent flows of dependencies,…

Ideas in this flowchart

  • Directed Acyclic Graph (DAG)
  • A DAG must be both directed and acyclic.
  • Directed means that one task can require another task without the reverse requirement.
  • Dependencies form one-way prerequisite relationships between tasks.
  • Mutual dependencies would create an infinite loop.
  • Acyclic means that the graph contains no cycles.
  • A cycle may pass through multiple vertices.
  • Any dependency cycle could make the project impossible to complete.
  • DAGs represent flows of dependencies.
  • College courses can be represented through prerequisite dependencies.
  • Project workflows represent tasks as vertices and their dependencies as edges.
  • A brownie-making workflow is an example of a dependency graph.
  • Eggs must be cracked before mixing, the oven must be preheated before baking, and the pan must be greased before pouring.
  • An arrow from baking back to greasing the pan would create a dependency cycle.
  • The resulting cycle would leave the tasks stuck and prevent the brownies from being completed.
Feed/

What is a directed acyclic graph, or DAG?

Channel

Brisk

1 page

"DAG (directed, acyclic graph). One common use of graphs is to represent flows of dependencies, for instance the prerequisites that different college courses have for one another. Another example is project management workflows: the tasks needed to complete a project become vertices, and then the dependencies they have on one another become edges. The graph in Figure 5.4 shows the steps in making a batch of brownies, and how these steps depend on each other. The eggs have to be cracked before the ingredients can be mixed, and the oven has to be preheated before baking, but the pan can be greased any old time, provided that it’s done before pouring the brown goop into it.\n\nA graph of dependencies like this must be both directed and acyclic, or it wouldn’t make sense. Directed, of course, means that task X can require task Y to be completed before it, without the reverse also being true. If they both depended on each other, we’d have an infinite loop, and no brownies could ever get baked! Acyclic means that no kind of cycle can exist in the graph, even one that goes through multiple vertices. Such a cycle would again result in an infinite loop, making the project hopeless. Imagine if there were an arrow from bake for 30 mins back to grease pan in Figure 5.4. Then, we’d have to grease the pan before pouring the goop into it, and we’d have to pour the goop before baking, but we’d also have to bake before greasing the pan! We’d be stuck right off the bat: there’d be no way to complete any of those tasks since they’d all indirectly depend on each other. A graph that is both directed and acyclic (and therefore free of these problems) is sometimes called a DAG for short."

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.