// Path: src/main/java/org/chocosolver/graphsolver/GraphModel.java
// public class GraphModel extends Model implements IGraphVarFactory, IGraphConstraintFactory {
// 
// 	//***********************************************************************************
// 	// CONSTRUCTORS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Creates a model to handle graph variables with Choco Solver
// 	 *
// 	 * @param name label of the model
// 	 */
// 	public GraphModel(String name) {
// 		super(name, new DefaultSettings() {
// 			@Override
// 			public AbstractStrategy makeDefaultSearch(Model model) {
// 				return GraphSearch.defaultSearch((GraphModel)model);
// 			}
// 		});
// 	}
// 
// 	/**
// 	 * Creates a model to handle graph variables with Choco Solver
// 	 */
// 	public GraphModel() {
// 		this("Graph Model");
// 	}
// 
// 	//***********************************************************************************
// 	// METHODS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Iterate over the variable of <code>this</code> and build an array that contains the GraphVar only.
// 	 *
// 	 * @return array of GraphVar in <code>this</code> model
// 	 */
// 	public GraphVar[] retrieveGraphVars() {
// 		ArrayList<GraphVar> gvars = new ArrayList<>();
// 		for (Variable v : getVars()) {
// 			if ((v.getTypeAndKind() & Variable.KIND) == GraphVar.GRAPH) {
// 				gvars.add((GraphVar) v);
// 			}
// 		}
// 		return gvars.toArray(new GraphVar[gvars.size()]);
// 	}
// 
// 	@Override
// 	public GraphModel _me() {
// 		return this;
// 	}
// }
// 
// Path: src/main/java/org/chocosolver/graphsolver/variables/UndirectedGraphVar.java
// public class UndirectedGraphVar extends GraphVar<UndirectedGraph> {
// 
// 	//////////////////////////////// GRAPH PART /////////////////////////////////////////
// 
// 	//***********************************************************************************
// 	// CONSTRUCTORS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Creates a graph variable
// 	 *
// 	 * @param name
// 	 * @param solver
// 	 * @param LB
// 	 * @param UB
// 	 */
// 	public UndirectedGraphVar(String name, Model solver, UndirectedGraph LB, UndirectedGraph UB) {
// 		super(name, solver, LB, UB);
// 	}
// 
// 	//***********************************************************************************
// 	// METHODS
// 	//***********************************************************************************
// 
// 	@Override
// 	public boolean removeArc(int x, int y, ICause cause) throws ContradictionException {
// 		assert cause != null;
// 		if (LB.edgeExists(x, y)) {
// 			this.contradiction(cause, "remove mandatory arc");
// 			return false;
// 		}
// 		if (UB.removeEdge(x, y)) {
// 			if (reactOnModification) {
// 				delta.add(x, GraphDelta.AR_TAIL, cause);
// 				delta.add(y, GraphDelta.AR_HEAD, cause);
// 			}
// 			GraphEventType e = GraphEventType.REMOVE_ARC;
// 			notifyPropagators(e, cause);
// 			return true;
// 		}
// 		return false;
// 	}
// 
// 	@Override
// 	public boolean enforceArc(int x, int y, ICause cause) throws ContradictionException {
// 		assert cause != null;
// 		enforceNode(x, cause);
// 		enforceNode(y, cause);
// 		if (UB.edgeExists(x, y)) {
// 			if (LB.addEdge(x, y)) {
// 				if (reactOnModification) {
// 					delta.add(x, GraphDelta.AE_TAIL, cause);
// 					delta.add(y, GraphDelta.AE_HEAD, cause);
// 				}
// 				GraphEventType e = GraphEventType.ADD_ARC;
// 				notifyPropagators(e, cause);
// 				return true;
// 			}
// 			return false;
// 		}
// 		this.contradiction(cause, "enforce arc which is not in the domain");
// 		return false;
// 	}
// 
// 	/**
// 	 * Get the set of neighbors of vertex 'idx' in the lower bound graph
// 	 * (mandatory incident edges)
// 	 *
// 	 * @param idx a vertex
// 	 * @return The set of neighbors of 'idx' in LB
// 	 */
// 	public ISet getMandNeighOf(int idx) {
// 		return getMandSuccOrNeighOf(idx);
// 	}
// 
// 	/**
// 	 * Get the set of neighbors of vertex 'idx' in the upper bound graph
// 	 * (potential incident edges)
// 	 *
// 	 * @param idx a vertex
// 	 * @return The set of neighbors of 'idx' in UB
// 	 */
// 	public ISet getPotNeighOf(int idx) {
// 		return getPotSuccOrNeighOf(idx);
// 	}
// 
// 	@Override
// 	public boolean isDirected() {
// 		return false;
// 	}
// }


import org.chocosolver.graphsolver.GraphModel;
import org.chocosolver.graphsolver.variables.UndirectedGraphVar;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.util.objects.graphs.UndirectedGraph;
import org.chocosolver.util.objects.setDataStructures.SetType;
import org.testng.Assert;
import org.testng.annotations.Test;
package org.chocosolver.checked;


public class CycleTest {

	@Test
	public void test() throws ContradictionException {
		GraphModel m = new GraphModel();
		int n = 4;
		UndirectedGraph GLB = new UndirectedGraph(m, n, SetType.BITSET, false);
		UndirectedGraph GUB = new UndirectedGraph(m, n, SetType.BITSET, false);
		for (int i = 0; i < n; i++) {
			GUB.addNode(i);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				GUB.addEdge(i, j);
			}
		}
// Path: src/main/java/org/chocosolver/graphsolver/GraphModel.java
// public class GraphModel extends Model implements IGraphVarFactory, IGraphConstraintFactory {
// 
// 	//***********************************************************************************
// 	// CONSTRUCTORS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Creates a model to handle graph variables with Choco Solver
// 	 *
// 	 * @param name label of the model
// 	 */
// 	public GraphModel(String name) {
// 		super(name, new DefaultSettings() {
// 			@Override
// 			public AbstractStrategy makeDefaultSearch(Model model) {
// 				return GraphSearch.defaultSearch((GraphModel)model);
// 			}
// 		});
// 	}
// 
// 	/**
// 	 * Creates a model to handle graph variables with Choco Solver
// 	 */
// 	public GraphModel() {
// 		this("Graph Model");
// 	}
// 
// 	//***********************************************************************************
// 	// METHODS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Iterate over the variable of <code>this</code> and build an array that contains the GraphVar only.
// 	 *
// 	 * @return array of GraphVar in <code>this</code> model
// 	 */
// 	public GraphVar[] retrieveGraphVars() {
// 		ArrayList<GraphVar> gvars = new ArrayList<>();
// 		for (Variable v : getVars()) {
// 			if ((v.getTypeAndKind() & Variable.KIND) == GraphVar.GRAPH) {
// 				gvars.add((GraphVar) v);
// 			}
// 		}
// 		return gvars.toArray(new GraphVar[gvars.size()]);
// 	}
// 
// 	@Override
// 	public GraphModel _me() {
// 		return this;
// 	}
// }
// 
// Path: src/main/java/org/chocosolver/graphsolver/variables/UndirectedGraphVar.java
// public class UndirectedGraphVar extends GraphVar<UndirectedGraph> {
// 
// 	//////////////////////////////// GRAPH PART /////////////////////////////////////////
// 
// 	//***********************************************************************************
// 	// CONSTRUCTORS
// 	//***********************************************************************************
// 
// 	/**
// 	 * Creates a graph variable
// 	 *
// 	 * @param name
// 	 * @param solver
// 	 * @param LB
// 	 * @param UB
// 	 */
// 	public UndirectedGraphVar(String name, Model solver, UndirectedGraph LB, UndirectedGraph UB) {
// 		super(name, solver, LB, UB);
// 	}
// 
// 	//***********************************************************************************
// 	// METHODS
// 	//***********************************************************************************
// 
// 	@Override
// 	public boolean removeArc(int x, int y, ICause cause) throws ContradictionException {
// 		assert cause != null;
// 		if (LB.edgeExists(x, y)) {
// 			this.contradiction(cause, "remove mandatory arc");
// 			return false;
// 		}
// 		if (UB.removeEdge(x, y)) {
// 			if (reactOnModification) {
// 				delta.add(x, GraphDelta.AR_TAIL, cause);
// 				delta.add(y, GraphDelta.AR_HEAD, cause);
// 			}
// 			GraphEventType e = GraphEventType.REMOVE_ARC;
// 			notifyPropagators(e, cause);
// 			return true;
// 		}
// 		return false;
// 	}
// 
// 	@Override
// 	public boolean enforceArc(int x, int y, ICause cause) throws ContradictionException {
// 		assert cause != null;
// 		enforceNode(x, cause);
// 		enforceNode(y, cause);
// 		if (UB.edgeExists(x, y)) {
// 			if (LB.addEdge(x, y)) {
// 				if (reactOnModification) {
// 					delta.add(x, GraphDelta.AE_TAIL, cause);
// 					delta.add(y, GraphDelta.AE_HEAD, cause);
// 				}
// 				GraphEventType e = GraphEventType.ADD_ARC;
// 				notifyPropagators(e, cause);
// 				return true;
// 			}
// 			return false;
// 		}
// 		this.contradiction(cause, "enforce arc which is not in the domain");
// 		return false;
// 	}
// 
// 	/**
// 	 * Get the set of neighbors of vertex 'idx' in the lower bound graph
// 	 * (mandatory incident edges)
// 	 *
// 	 * @param idx a vertex
// 	 * @return The set of neighbors of 'idx' in LB
// 	 */
// 	public ISet getMandNeighOf(int idx) {
// 		return getMandSuccOrNeighOf(idx);
// 	}
// 
// 	/**
// 	 * Get the set of neighbors of vertex 'idx' in the upper bound graph
// 	 * (potential incident edges)
// 	 *
// 	 * @param idx a vertex
// 	 * @return The set of neighbors of 'idx' in UB
// 	 */
// 	public ISet getPotNeighOf(int idx) {
// 		return getPotSuccOrNeighOf(idx);
// 	}
// 
// 	@Override
// 	public boolean isDirected() {
// 		return false;
// 	}
// }


// Path: src/test/java/org/chocosolver/checked/CycleTest.java
import org.chocosolver.graphsolver.GraphModel;
import org.chocosolver.graphsolver.variables.UndirectedGraphVar;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.exception.ContradictionException;
import org.chocosolver.util.objects.graphs.UndirectedGraph;
import org.chocosolver.util.objects.setDataStructures.SetType;
import org.testng.Assert;
import org.testng.annotations.Test;

package org.chocosolver.checked;


public class CycleTest {

	@Test
	public void test() throws ContradictionException {
		GraphModel m = new GraphModel();
		int n = 4;
		UndirectedGraph GLB = new UndirectedGraph(m, n, SetType.BITSET, false);
		UndirectedGraph GUB = new UndirectedGraph(m, n, SetType.BITSET, false);
		for (int i = 0; i < n; i++) {
			GUB.addNode(i);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				GUB.addEdge(i, j);
			}
		}
		UndirectedGraphVar g = m.graphVar("g", GLB, GUB);