Chess knight move in 8x8 chessboard I've recently shown some interests in chess, and I wonder if there is a solution for the following problem: 
In a 8x8 chessboard, labeling the cells with numbers from 1 to 8, is there any way to find the minimum moves that a knight should do to reach a given destination? For example, in this configuration:
  1  2  3  4  5  6  7  8
1
2
3
4
5
6
7
8

If the start position is the cell $(1, 1)$, and the destination is $(5, 1)$, we can go there with only 2 moves. First at $(3, 2)$, and then at $(5, 1)$. There are no restricts to be noticed, we can suppose that there is a blank 8x8 chessboard with only a night in it. I only want to know that if the start position is $(x_1, y_1)$ and the destination is $(x_2, y_2)$, how many moves are required to go there (the minimum)? Does anyone has experiences on this?
 A: Following the suggestion of @BarakManos: 
Step 1: Construct a graph where each square of the chess board is a vertex.
Step 2: Place an edge between vertices exactly when there is a single knight-move from one square to another.
Step 3: Dijkstra's algorithm is an algorithm to find the length of a path between two vertices (squares).  It is very classical in graph theory, data structures, and algorithms.
A: There's actually few restrictions that are due to the edge of the board. One  of these (or the only case) is moving from A1 to B2 for example. Normally it would take two moves to move one step diagonally, but here that solution would move you of board. Instead you would have to move to C2 or B3 first and then it's a move one step along file or row which is three steps.
Then it should be quite straight forward to just testing for solutions. The reason you don't get that many restrictions from the edges is that there will be similar solutions by symmetry that would avoid the restriction of the edges.
I wrote a program using the following algorithm:


*

*Create a array of squares

*Write zero in one array, then for each $j\in\mathbb N$:

*For each square with value $j$ put $j+1$ in all empty squares reachable by a knight jump. Repeat for successive $j$'s until the board is filled.


Well this is kind of similar to Dijkstra's algorithm (except in this case the distances are all one). My program confirmed that on a regular chess board the only case where the edges are a restriction is the mentioned case.
A: Dijkstra is overkill here.
Construct the graph as said in other answers, since the weight of edges are add one, one can find shortest path in a simple graph using Breadth First Search in O(V+E) instead of O(E + VlogV) as in Dijkstra.
If you want to find all of shortest paths from all cell to all others, you can use Floyd-Warshall algorithm since your vertexes in the graph are 64, this can be computed in O(n^3).
I should add that between Dijkstra, BFS and Floyd-Warshall , Floyd-Warshall is the easiest one to implement . and it is feasible to use it up to a 10*10 board.

In this video you can find out more about finding shortest path using BFS
And in this wiki you can learn about Floyd-Warshall algorithm.
