Documentation

Mathlib.Tactic.Order.Graph.Tarjan

Tarjan's Algorithm #

This file implements Tarjan's algorithm for finding the strongly connected components (SCCs) of a graph.

State for Tarjan's algorithm.

  • id : Array

    id[v] is the index of the vertex v in the DFS traversal.

  • stack : Array

    The stack of visited vertices used in Tarjan's algorithm.

  • onStack : Array Bool

    onStack[v] = true iff v is in stack. The structure is used to check it efficiently.

  • time :

    A time counter that increments each time the algorithm visits an unvisited vertex.

The Tarjan's algorithm. See Wikipedia.

Implementation of findSCCs in the StateM TarjanState monad.

Equations
  • One or more equations did not get rendered due to their size.

Finds the strongly connected components of the graph g. Returns an array where the value at index v represents the SCC number containing vertex v. The numbering of SCCs is arbitrary.

Equations
  • One or more equations did not get rendered due to their size.