public void IsValidTest()
        {
            // Cycle exist
            var graphe = new Graphe(4);
            graphe.AddConnection(0, 1);
            graphe.AddConnection(1, 2);
            graphe.AddConnection(2, 3);
            graphe.AddConnection(3, 0);

            var hamiltonCycle = new HamiltonianCycleProblem.Hamiltonian_Backtracking(graphe);
            Assert.IsTrue(hamiltonCycle.Solve());

            // Cycle not exist
            var graphe2 = new Graphe(4);
            graphe.AddConnection(0, 1);
            graphe.AddConnection(1, 2);
            graphe.AddConnection(2, 3);

            var hamiltonCycle2 = new HamiltonianCycleProblem.Hamiltonian_Backtracking(graphe2);
            Assert.IsFalse(hamiltonCycle2.Solve());
        }
        public static bool IsValid(Graphe graphe ,int[] partialSolution, int position, int value)
        {
            if (position > 0)
            {
                // Is connected
                if (!graphe.IsConnected(partialSolution[position - 1], value))
                {
                    return false;
                }

                // Already exist
                for (int i = 0; i < position; i++)
                {
                    if (partialSolution[i] == value)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
 public Hamiltonian_Backtracking(Graphe graphe)
 {
     _graphe = graphe;
     possibleSolutions = new int[graphe.Size];
 }