Affected

Finds the changed vertices and every vertex reachable from them, such as all the cells a spreadsheet edit recomputes.

Time complexity O(V+E), gograph function dag.Affected.

Build pipeline

The jobs of a CI pipeline for a web service. Each edge points from a job to a job that waits for it.

A directed graph with 7 vertices and 9 edges.

A commit changes the Lint and Docker image jobs. Which jobs have to run again?

Use it in Go

jobs, err := dag.Affected(g, "Lint", "Docker image")
if err != nil {
	return err
}
for _, v := range jobs {
	fmt.Println(v.Label())
}

Example graphs

More in Dependencies

  • Descendants: Finds every vertex reachable from a vertex, such as all the jobs that wait for one step of a build.
  • Ancestors: Finds every vertex that can reach a vertex, such as all the courses one course needs first.
  • Transitive reduction: Drops every edge that a longer path already implies. Each vertex still reaches the same vertices.

All algorithms