public static int hamiltonianPath(int[][] G, int s, int i, Set<Integer>path, int cost, int opcost) {
		int n=G.length;
		if (path.size()==n&&i==s) {
			return opcost=Math.min(opcost, cost);
		}
		if (cost >opcost || path.contains(i)) {
			return Integer.MAX_VALUE;
		}
		path.add(i);
		int minval=Integer.MAX_VALUE;
		for (int j=0;j<n;++j)
			if (G[i][j]>=0)
				minval=hamiltonianPath(G, s, j, path, cost+G[i][j], opcost);
		path.remove(i);
		return minval;
	}