HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

The complexity of checking for short cycles in a graph

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thegraphshortcheckingforcyclescomplexity

Problem

In general, the problem of finding a Hamiltonian cycle is NP-complete (Karp 1972; Garey and Johnson 1983, p. 199).

Next, as for determining the existence of long cycles, I don't hold much hope for efficient algorithms. However, what about short cycles? For instance, 3-cycles, 4-cycles, and so on. For a $k$-cycle, at what value of $k$ does the algorithmic complexity transition from polynomial time to non-polynomial time? Is there a clear boundary?

Solution

If your graph has $n$ vertices and you’re interested in $k$-cycles, then a brute-force inspection will look at each of the $n \choose k$ possible $k$-tuples. Thus, assuming that $k$ is small—in other words, that $k = O(1)$—that approach is $\Theta(n^k)$.

Context

StackExchange Computer Science Q#161786, answer score: 5

Revisions (0)

No revisions yet.