Given an $n \times n$ square grid graph, what is the maximum number of turns a Hamiltonian path can take?
2026-04-28 15:22:45.1777389765
Max-turn hamiltonian path in square grids
1.8k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in GRAPH-THEORY
- characterisation of $2$-connected graphs with no even cycles
- Explanation for the static degree sort algorithm of Deo et al.
- A certain partition of 28
- decomposing a graph in connected components
- Is it true that if a graph is bipartite iff it is class 1 (edge-coloring)?
- Fake induction, can't find flaw, every graph with zero edges is connected
- Triangle-free graph where every pair of nonadjacent vertices has exactly two common neighbors
- Inequality on degrees implies perfect matching
- Proving that no two teams in a tournament win same number of games
- Proving that we can divide a graph to two graphs which induced subgraph is connected on vertices of each one
Related Questions in COMPUTER-SCIENCE
- What is (mathematically) minimal computer architecture to run any software
- Simultaneously multiple copies of each of a set of substrings of a string.
- Ackermann Function for $(2,n)$
- Algorithm for diophantine equation
- Show that if f(n) is O(g(n) and d(n) is O(h(n)), then f(n) + d(n) is O(g(n) + h(n))
- Show that $2^{n+1}$ is $O(2^n)$
- If true, prove (01+0)*0 = 0(10+0)*, else provide a counter example.
- Minimum number of edges that have to be removed in a graph to make it acyclic
- Mathematics for Computer Science, Problem 2.6. WOP
- Partial ordering set subset relation
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
Answer to OP's question (proof follows):
For Hamitlonian paths: if $n$ is even max turns=$n^2-n$
if $n$ is odd max turns equals $n^2-n-1$
The minimum number of turns on an Hamiltonian path on an $n \times n$ lattice is $2n-2$ which can be constructed at least two non-isomorphic ways (rows or spiral) for each graph. The maximum number of turns Hamiltonian path onin a $2 \times n$ lattice is also $2n-2$
To maximize the number of turns, if $n$ is even then you can consider the graph to be a collection of $n \times 2$ graphs each of which can have a maximum of $2n-2$ turns in them starting from an outside corner on each side the $-2$ factor comes from the fact that in order to turn the corner you must have one vertex that does not turn, for an outside $2 \times n$ you lose one going into the corner and one from the starting/ending vertex. For the interior $2 \times n$'s you must have one "straight vertex coming in and one coming out.
$2n-2 \times (n/2)$seperate rectangles gives a formula of $n^2-n$ for even $n$.
If $n$ is odd, it is not so simple to construct a path because the rows do not divide evenly by $2$. The cases for constrcution of a maximal turning path are different if $n$ is 1 or 3 mod $4$.
If $n=1$ mod $4$ you begin again at a corner in the first row you again have $2n-2$ turning vertices in the first $2\times n$ rectangle. You then continue down the side of the graph (a $2\times (n-2)$ rectangle) and collect $2n-4-1$ more turning vertices. Repeat on the bottom of the graph. Continue towards the starting corner now you have a $2 \times (n-4)$ rectangle that yields $2n-8-1$ turning vertices. Continue on towards the center every two new directions you turn the rectangle get smaller and there are $4$ fewer vertices. When you reach the center (where the path ends) you gain only 1 turn for the final $3$ vertices.
Putting it all together there are $n-2$ turns in the first rectangle, $1$ turn for the center and the spiral which contains $n-7+4$ rectangles in sets of two beginning with $2n-5$ turns and adding $4$ less for every set. $2n-2+1+[(n-3)(\frac{2n+5-5}{2})]=n^2-n-1$
If $n=3$ mod $4$ then you can proceed as above but the actual center vertex of the graph is contained in the last rectangle before the end of the paththe last $3$ vertices and their $1$ turn remains the same but the path is off-centered in the graph. The formula for the vertices remains the same $2n-2$ for the first rectangle $n-5$ rectangles at an average of $n$ turns per spiral rectangle and one for the last turn of the path still sums to $n^2-n-1$ for all odd $n$.
Answer to question asked in comments. For Hamiltonian Cycles
If $n$ is odd there is no hamiltonian cycle on a $n \times n$ grid. This can be proved from the contrapositive of theorem 3.16 on page 214 of "Graphs and Digraphs" by Chartrand. By numbering the vertices of an odd $n \times n$ grid from left to right top to bottom from $1,2,3...n^2$ Select the set of vertices $S$ as all the even numbered vertices. Then $|S|=\frac{n^2-1}{2}$ and there are $\frac{n^2+1}{2}$ disconnected components so the graph cannot be hamiltonian.
If $n$ is even you can construct a "spiral" cycle like the spirals for the odd paths given above. I haven't found a closed form expression yet that deals with the center of the cycle. $(\frac{3n^2}{4}+\frac{3n}{2}-12)+C$ where $C$ is the number of turns at the center of the graph is a good description of the maximum number of turns in a hamiltonian cycle on a $n \times n$ grid.