public static void CDC_pairwise(CDCRelation p, boolean connected)
	{
		int count=0;
		//int[] c = new int[511];	//counters
		int i,j;

		//first we calculate all the valid CDC relations, stored in valid_rel[]
		List<CDCRelation> valid_rel = new ArrayList<CDCRelation>();
		CDCRelation r = new CDCRelation(0);
		r.connected=connected;

		for (i=1;i<=511;i++)
		{
			r = new CDCRelation(i); //TODO compare this with r.set(i);
			if (!connected || r.valid()) valid_rel.add(r);
		}
		//now we check the consistency of each pair of basic CDC relations
				

		CDCNetwork n = new CDCNetwork();
		n.resize(2);
		n.connected=connected;
		n.setConstraint(0,0,new CDCRelation("O".toCharArray()));
		n.setConstraint(1,1,new CDCRelation("O".toCharArray()));
		n.setConstraint(0,1,p);
		
		for (j=0;j<valid_rel.size();j++)
		{
			
			n.setConstraint(1,0,valid_rel.get(j));
			if (n.consistent()) 
			{
				count++;
				System.out.println(j);

			}
		}		

		if (connected)
			System.out.print("for connected case, ");
		else 
			System.out.print("for possibly disconnected case, ");

		System.out.format("there are total %d consistent pairwise relation.\n", count);
		
	}