GenerateRandomSearch

DAG Generator

Anything that resolves dependencies needs DAGs to test against: build systems, task schedulers, migration runners, spreadsheet engines. Generating one by adding random edges and retrying whenever a cycle appears is slow and can fail to terminate. This gives the nodes a random order and only ever points edges forwards, which makes acyclicity structural — there is no cycle to reject because none can be created.

What this generator does

Produces a directed graph guaranteed to contain no cycle. The nodes are given a random order and edges only ever run from earlier to later in that order, so a cycle is impossible rather than merely unlikely. Acyclicity is still re-verified with Kahn's algorithm before display, because a property worth relying on is worth checking.

How to use this tool

  1. Choose how many nodes and how dense the dependencies should be.
  2. Generate — every edge points forwards in a hidden random order.
  3. Copy the edge list or DOT to feed your scheduler.
  4. Seed it when a test needs the same graph every run.

Understanding the controls

How many nodes
Between 2 and 60. Density and node count together decide whether the graph is a long chain or a wide fan.
Edge density
The chance each forward-pointing edge is included. At 100% you get the complete DAG on that order, which is the densest acyclic graph possible.
Weighted edges
Whole-number weights, useful when the DAG stands in for durations or costs.
Seed
Any word reproduces the same result exactly. Leave it empty and the browser's cryptographic generator is used instead.

Common use cases

  • Testing a topological sort with graphs bigger than you would draw by hand
  • Producing dependency input for a build or migration tool
  • Checking a scheduler handles wide graphs as well as deep ones
  • Demonstrating why a cycle breaks dependency resolution, by contrast
  • Generating a DAG for a teaching exercise on ordering

How this generator works

A random permutation of the nodes fixes a topological order. Every pair is then considered in that order and an edge from the earlier to the later node is included with the chosen probability. Because no edge ever points backwards, the result cannot contain a cycle. Kahn's algorithm confirms it.

Randomness and fairness

The hidden topological order and the edge choices are both random. Acyclicity is not: it holds for every possible draw. A seed makes the graph reproducible, which by definition means it is not cryptographically secure.

For how randomness is produced across the whole site, see how Generate Random works.

Limitations and good to know

  • A DAG is not a tree: nodes can have several parents. Use the tree generator if you need exactly one.
  • The hidden topological order is not the node labelling, so the edge list will not look sorted.
  • Close the tab and the DAG is gone. A seed is the only way to get the same one back.

Privacy and your data

The DAG is built in your browser. Your node count, density and seed stay on the page, and no generated graph is uploaded or stored between visits.