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.

  • visited : Std.HashSet â„•
  • id : Std.HashMap â„• â„•

    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 : Std.HashSet â„•

    onStack.contains v 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.

Instances For
    partial def Mathlib.Tactic.Order.Graph.tarjanDFS (g : Graph) (v : â„•) :
    StateM TarjanState Unit

    The Tarjan's algorithm. See Wikipedia.

    Implementation of findSCCs in the StateM TarjanState monad.

    Instances For
      def Mathlib.Tactic.Order.Graph.findSCCs (g : Graph) :
      Std.HashMap â„• â„•

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

      Instances For