Graph Girth Calculator

shortest cycle length

CalculatorsFreeNo Signup
4.8(505 reviews)
All Tools

Loading tool...

About Graph Girth Calculator

A graph girth calculator computing g(G) = minimum cycle length. g = ∞ for acyclic (trees/forests). g = 3 for graphs with triangles. Used in cage theory, Ramsey theory, and network analysis. Related to local clustering coefficient. Client-side BFS.

Graph Girth Calculator Features

  • g(G)
  • Min cycle
  • BFS
  • Cage theory
  • Common graphs
Graph girth g(G) = length of shortest cycle. g(tree) = ∞. g(K_n) = 3. g(C_n) = n. g(Petersen) = 5. Fundamental in cage theory: (r,g)-cage is smallest r-regular graph with girth g. Girth constrains graph density and chromatic number.

How to Use

Select graph:

  • g: Girth
  • ∞: Acyclic
  • 3: Has triangles

BFS Algorithm

For each vertex: BFS. If BFS reaches an already-visited vertex (not parent), found a cycle. Track minimum length across all vertices. O(n·(n+m)).

Cage Theory

(r,g)-cage: smallest r-regular graph with girth g. Petersen: (3,5)-cage (10 vertices). Moore bound: n ≥ 1+r+r(r-1)+...+r(r-1)^{(g-3)/2} for odd g. Finding cages is a major open problem!

Step-by-Step Instructions

  1. 1Select graph.
  2. 2Run BFS from each vertex.
  3. 3Detect shortest cycle.
  4. 4Report girth.
  5. 5Check: tree → ∞.

Graph Girth Calculator — Frequently Asked Questions

Girth vs diameter?+

Diameter: longest shortest path. Girth: shortest cycle. Different focus: diameter measures distance extremes, girth measures cyclic structure. Both are fundamental.

Girth and chromatic number?+

High girth forces high chromatic number for dense graphs. The Mycielskian construction creates triangle-free (g≥4) graphs with arbitrarily high χ. But sparse graphs: high girth → low χ.

Girth ∞?+

g = ∞ iff no cycles iff acyclic iff forest (or tree if connected). The convention ∞ emphasizes that 'shortest cycle' doesn't exist. Some authors use g=0 instead.

Share this tool: