the code is:

``````// graph.h
#include <iostream>
#include <vector>
#include <queue>
template <typename ItemType>
class Graph

{
public:
Graph(){ };
~Graph() { Clear(); }
bool Empty() const;
bool EdgeExists(int n, int m) const;
bool VertexExists(int n) const;
void Clear();
void SetItem(const ItemType& newItem, int n);
ItemType GetItem(int n) const;
int VertexCount() const;
int DegreeOfVertex(int n) const;
void ShowGraph() const;
bool Hamilton(vector<int>& x);

private:
class VertexNode;
typedef VertexNode * NodePointer;
class VertexNode
{
public:
VertexNode(int n) { vert = n; next = 0; }
int vert;
NodePointer next;
};
vector<ItemType> vertex;
vector<bool> visit;

bool RecursHamilton(int k, vector<int>& x);

bool PathOK(int k, const vector<int>& x);

};
template <typename ItemType>
{
vertex.push_back(theItem);
}
template <typename ItemType>
{
NodePointer nPtr = new VertexNode(n),
mPtr = new VertexNode(m);
}
template <typename ItemType>
bool Graph<ItemType>::Empty() const
{
return vertex.size() == 0;
}
template <typename ItemType>
bool Graph<ItemType>::EdgeExists(int n, int m) const
{
while (ptr != 0)
{
if (ptr->vert == m) return true;
ptr = ptr->next;
}
return false;
}
template <typename ItemType>
bool Graph<ItemType>::VertexExists(int n) const
{
return n >= 0 && n < int(vertex.size());
}
template <typename ItemType>
void Graph<ItemType>::Clear()
{
NodePointer ptr;
for (int i = 0; i < int(adj.size()); i++)
{
while (ptr != 0)
{
delete ptr;
}
}
vertex.clear();
}
template <typename ItemType>
void Graph<ItemType>::SetItem(const ItemType& newItem, int n)
{
vertex[n] = newItem;
}
template <typename ItemType>
ItemType Graph<ItemType>::GetItem(int n) const
{
return vertex[n];
}
template <typename ItemType>
int Graph<ItemType>::VertexCount() const
{
return int(vertex.size());
}
template <typename ItemType>
int Graph<ItemType>::DegreeOfVertex(int n) const
{
int degree = 0;
while (ptr != 0)
{
degree++;
ptr = ptr->next;
}
return degree;
}
template <typename ItemType>
void Graph<ItemType>::ShowGraph() const
{
for (int i = 0; i < int(vertex.size()); i++)
{
cout << "[#" << i << ":" << vertex[i] << "]:";
while (ptr != 0)
{
cout << "  " << ptr->vert;
ptr = ptr->next;
}
cout << endl;
}
}

template <typename ItemType>
bool Graph<ItemType>::RecursHamilton(int k, vector<int>& x)
{
vector< vector<int> > graph;
int start = k;
vector<bool> used;
for( x[k] = 2;x[k] < x[n];x[k]++)
if(PathOK(start,x))
{
used[x[k]] = true;
if(k == n || RecursHamilton(start,x))
cout<<' '<< x[k];
}
return false;
}

template <typename ItemType>
bool Graph<ItemType>::PathOK(int k, const vector<int>& x)
{
// need to implement this function..
}

template <typename ItemType>
bool Graph<ItemType>::Hamilton(vector<int>& x)
{
vector<bool> used;
x[1] = 1;
used[1] = true;
for(int i = 2;i<n;i++)
if(used[i] = false)
RecursHamilton(2, x);
return false;
}``````

I need to find out Hamiltonian circuit, it is a cycle starting from one vertex of undirected graph and visiting all th evertices only once except the starting n ending vertex being same.
eg. 012340

I have main problem on PathOk function..
Any help would be highly appreciated.

I did put this code on
pathOk function but it does not work.

``````template <typename ItemType>
bool Graph<ItemType>:athOK(int k, const vector<int>& x)
{
vector<bool> used;

if(used[x[k]])
return false;

if(k<n)