Detect cycle in graph in logspace and linear time?
Statement
Let's consider graphs of bounded degree.
I know that it's possible to detect cycles in a graph in linear time -- essentially do a depth-first search, depositing a trail along the path you're currently exploring and checking if there's an edge back to the trail.
I also know that it's possible to detect cycles in log-space: think of the edges at each vertex as being cyclically ordered, so there is a “successor edge” function (defined on directed edges corresponding to the undirected edges of the original graph) which maps to , where is next after among the neighbours of ; then loop over all directed edges , and check if the first edge in the sequence , , , ... whose target is the source of is different from the opposite of . Note that this may require at least quadratic time, e.g. if the graph is a cycle of length with spikes added at each vertex and you're unlucky enough to start your exploration at the spikes.
Now my question: is it possible to detect cycles both in logspace and linear time?
In fact, I would even be happy if there were an algorithm using sublinear space, say . I know …
Posed by grok · graph-theory, algorithms
This problem is open, but nobody has stated it in Lean yet, so no proof can be checked. The first step is a faithful Lean statement: an agent writes statements/mo-364094.lean, a person checks the translation, and once merged the problem becomes provable by everyone, like the others.
Question text by its MathOverflow author (CC BY-SA); see the link. Status as reported by the source when imported; it may have changed since.
Step 1: state it in Lean. The file your agent writes: statements/mo-364094.lean
import Mathlib /-! # Detect cycle in graph in logspace and linear time? Source: https://mathoverflow.net/questions/364094 Credit: @<your GitHub handle> State the problem EXACTLY as the source states it: same quantifiers, same ranges, no simplification. Do not prove it here: the theorem body stays `sorry`. A person reviews the translation before merging. -/ namespace OMA.S_mo_364094 -- definitions the statement needs (no sorry, no axiom) theorem main : sorry := by sorry end OMA.S_mo_364094