@Test
 public void testGraphWithNoCycles() {
   CobwebGraph unbound = new CobwebGraph(3);
   unbound.setEdge(1, 2, Edge.EdgeOperation.MULTIPLICATION, 2);
   unbound.setEdge(2, 3, Edge.EdgeOperation.ADDITION, 5);
   CobwebSolver solver = new CobwebSolver(unbound.map);
   assertEquals(CobwebSolver.SolverState.INFINITE_SOLUTIONS, solver.numberOfSolutions());
 }
 @Test
 public void testGraphOnlySolvableWithNegativeNumbers() {
   CobwebGraph negative = new CobwebGraph(3);
   negative.setEdge(1, 2, Edge.EdgeOperation.MULTIPLICATION, 2);
   negative.setEdge(2, 3, Edge.EdgeOperation.ADDITION, 5);
   negative.setEdge(3, 1, Edge.EdgeOperation.ADDITION, 1);
   CobwebSolver solver = new CobwebSolver(negative.map);
   assertEquals(CobwebSolver.SolverState.NO_SOLUTION, solver.numberOfSolutions());
 }
 @Test
 public void testUnsolvableGraph() {
   CobwebGraph bad = new CobwebGraph(3);
   bad.setEdge(1, 2, Edge.EdgeOperation.MULTIPLICATION, 2);
   bad.setEdge(2, 3, Edge.EdgeOperation.ADDITION, 5);
   bad.setEdge(3, 1, Edge.EdgeOperation.DIVISION, 2);
   CobwebSolver solver = new CobwebSolver(bad.map);
   assertEquals(CobwebSolver.SolverState.NO_SOLUTION, solver.numberOfSolutions());
 }
 @Test
 public void testInfiniteSolutions() {
   CobwebGraph infinite = new CobwebGraph(3);
   infinite.setEdge(1, 2, Edge.EdgeOperation.ADDITION, 1);
   infinite.setEdge(2, 3, Edge.EdgeOperation.ADDITION, 1);
   infinite.setEdge(3, 1, Edge.EdgeOperation.SUBTRACTION, 2);
   CobwebSolver solver = new CobwebSolver(infinite.map);
   assertEquals(CobwebSolver.SolverState.INFINITE_SOLUTIONS, solver.numberOfSolutions());
 }
 @Test
 public void testGraphWithBadCycle() {
   CobwebGraph bad = new CobwebGraph(5);
   bad.setEdge(1, 2, Edge.EdgeOperation.SUBTRACTION, 1);
   bad.setEdge(2, 3, Edge.EdgeOperation.SUBTRACTION, 1);
   bad.setEdge(3, 4, Edge.EdgeOperation.SUBTRACTION, 1);
   bad.setEdge(4, 5, Edge.EdgeOperation.SUBTRACTION, 1);
   bad.setEdge(2, 4, Edge.EdgeOperation.ADDITION, 2);
   CobwebSolver solver = new CobwebSolver(bad.map);
   CobwebSolver.SolverState result = solver.numberOfSolutions();
   assertEquals(CobwebSolver.SolverState.NO_SOLUTION, result);
 }
 @Test
 public void testGraphPentagram() {
   CobwebGraph bad = new CobwebGraph(5);
   bad.setEdge(1, 2, Edge.EdgeOperation.MULTIPLICATION, 2);
   bad.setEdge(2, 3, Edge.EdgeOperation.ADDITION, 1);
   bad.setEdge(3, 4, Edge.EdgeOperation.SUBTRACTION, 5);
   bad.setEdge(4, 5, Edge.EdgeOperation.DIVISION, 6);
   bad.setEdge(5, 1, Edge.EdgeOperation.ADDITION, 8);
   CobwebSolver solver = new CobwebSolver(bad.map);
   CobwebSolver.SolverState result = solver.numberOfSolutions();
   assertEquals(CobwebSolver.SolverState.SINGLE_SOLUTION, result);
 }
  @Test
  public void testEasyTriangle() {
    CobwebGraph easy = new CobwebGraph(3);
    CobwebSolver solver;
    easy.setEdge(1, 2, Edge.EdgeOperation.MULTIPLICATION, 2);
    easy.setEdge(1, 3, Edge.EdgeOperation.ADDITION, 1);
    easy.setEdge(3, 2, Edge.EdgeOperation.ADDITION, 2);
    easy.setNode(1, 2);

    solver = new CobwebSolver(easy.map);
    assertEquals(CobwebSolver.SolverState.NO_SOLUTION, solver.numberOfSolutions());

    easy.setNode(1, 3);
    solver = new CobwebSolver(easy.map);
    assertEquals(CobwebSolver.SolverState.SINGLE_SOLUTION, solver.numberOfSolutions());
  }
  @Test
  public void testEasyQuad() {
    CobwebGraph quad = new CobwebGraph(4);
    CobwebSolver solver;
    quad.setEdge(1, 2, Edge.EdgeOperation.ADDITION, 6);
    quad.setEdge(2, 3, Edge.EdgeOperation.MULTIPLICATION, 2);
    quad.setEdge(1, 4, Edge.EdgeOperation.MULTIPLICATION, 3);
    quad.setEdge(4, 3, Edge.EdgeOperation.ADDITION, 1);
    solver = new CobwebSolver(quad.map);
    assertEquals(CobwebSolver.SolverState.SINGLE_SOLUTION, solver.numberOfSolutions());

    quad.setNode(4, 33);
    solver = new CobwebSolver(quad.map);
    assertFalse(solver.hasUnreachableNodes());
    assertEquals(CobwebSolver.SolverState.SINGLE_SOLUTION, solver.numberOfSolutions());

    quad.setNode(4, 15);
    solver = new CobwebSolver(quad.map);
    assertEquals(CobwebSolver.SolverState.NO_SOLUTION, solver.numberOfSolutions());
  }
  @Test
  public void testSolverInit() {
    CobwebGraph cw = new CobwebGraph(3);
    CobwebSolver solver = new CobwebSolver(cw.map);
    assertTrue(solver.hasUnreachableNodes());
    solver.setEdge(1, 2, Edge.EdgeOperation.ADDITION, 1);
    solver.setEdge(1, 3, Edge.EdgeOperation.ADDITION, 1);
    assertFalse(solver.hasUnreachableNodes());

    assertEquals(null, solver.getNodeValue(1));
    solver.setNode(1, 5);
    assertTrue(solver.getNodeValue(1).equals(5));
  }
 @Test
 public void testAlreadySolved() {
   CobwebSolver solver = new CobwebSolver(new CobwebGraph(3).map);
   solver.setEdge(1, 2, Edge.EdgeOperation.DIVISION, 2);
   solver.setEdge(3, 2, Edge.EdgeOperation.ADDITION, 1);
   solver.setEdge(1, 3, Edge.EdgeOperation.DIVISION, 3);
   solver.setNode(1, 6);
   solver.setNode(2, 3);
   solver.setNode(3, 2);
   assertEquals(CobwebSolver.SolverState.SOLVED_ALREADY, solver.numberOfSolutions());
 }
 @Test
 public void testIncompleteGraph() {
   CobwebGraph easy = new CobwebGraph(3);
   CobwebSolver solver = new CobwebSolver(easy.map);
   assertEquals(CobwebSolver.SolverState.NO_SOLUTION, solver.numberOfSolutions());
 }
 @Test
 public void testCircularCobweb() {
   CobwebSolver circularSolver = new CobwebSolver(createCircularWeb(5).map);
   assertFalse(circularSolver.hasUnreachableNodes());
 }