test_class.file: tool/hash/src/test/java/org/openscience/cdk/hash/MinimumEquivalentCyclicSetTest.java
test_class.identifier: MinimumEquivalentCyclicSetTest
test_case.body: @Test
      public void testFind_TwoChoices() throws Exception {
  
          IAtomContainer dummy = mock(IAtomContainer.class);
          int[][] g = new int[][]{{1, 5, 6}, {0, 2, 8}, {1, 3, 9}, {2, 4, 7}, {3, 5, 10}, {0, 4, 11}, {0, 14, 15},
                  {3, 20, 21}, {1, 12, 13}, {2, 22, 23}, {4, 18, 19}, {5, 16, 17}, {8, 13}, {8, 12}, {6, 15}, {14, 6},
                  {11, 17}, {16, 11}, {10, 19}, {10, 18}, {7, 21}, {7, 20}, {9, 23}, {22, 9}};
  
          // this mock the invariants
          long[] values = new long[]{0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
  
          EquivalentSetFinder finder = new MinimumEquivalentCyclicSet();
          Set<Integer> set = finder.find(values, dummy, g);
  
          assertThat(set.size(), is(6));
          assertTrue(set.contains(0));
          assertTrue(set.contains(1));
          assertTrue(set.contains(2));
          assertTrue(set.contains(3));
          assertTrue(set.contains(4));
          assertTrue(set.contains(5));
  
          // invert values, we should now get the other set
          values = new long[]{1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
  
          set = finder.find(values, dummy, g);
  
          assertThat(set.size(), is(6));
          assertTrue(set.contains(6));
          assertTrue(set.contains(7));
          assertTrue(set.contains(8));
          assertTrue(set.contains(9));
          assertTrue(set.contains(10));
          assertTrue(set.contains(11));
      }
test_case.class_method_signature: MinimumEquivalentCyclicSetTest.testFind_TwoChoices()
test_case.full_signature: @Test public void testFind_TwoChoices()
test_case.identifier: testFind_TwoChoices
test_case.invocations: mock find assertThat size is assertTrue contains assertTrue contains assertTrue contains assertTrue contains assertTrue contains assertTrue contains find assertThat size is assertTrue contains assertTrue contains assertTrue contains assertTrue contains assertTrue contains assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFind_TwoChoices()
focal_class.file: tool/hash/src/main/java/org/openscience/cdk/hash/MinimumEquivalentCyclicSet.java
focal_class.identifier: MinimumEquivalentCyclicSet
focal_class.class_method_signature: MinimumEquivalentCyclicSet.find(long[] invariants, IAtomContainer container, int[][] graph)
focal_class.full_signature: @Override Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph)
focal_class.identifier: find
focal_class.modifiers: @Override
focal_class.parameters: (long[] invariants, IAtomContainer container, int[][] graph)
focal_class.return: Set<Integer>
focal_class.signature: Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph)
focal_class.superclass: extends EquivalentSetFinder
focal_method.body: @Override
      Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph) {
  
          int n = invariants.length;
  
          // find cyclic vertices using DFS
          RingSearch ringSearch = new RingSearch(container, graph);
  
          // ordered map of the set of vertices for each value
          Map<Long, Set<Integer>> equivalent = new TreeMap<Long, Set<Integer>>();
  
          // divide the invariants into equivalent indexed and ordered sets
          for (int i = 0; i < invariants.length; i++) {
  
              Long invariant = invariants[i];
              Set<Integer> set = equivalent.get(invariant);
  
              if (set == null) {
                  if (ringSearch.cyclic(i)) {
                      set = new HashSet<Integer>(n / 2);
                      set.add(i);
                      equivalent.put(invariant, set);
                  }
              } else {
                  set.add(i);
              }
          }
  
          // find the smallest set of equivalent cyclic vertices
          int minSize = Integer.MAX_VALUE;
          Set<Integer> min = Collections.emptySet();
          for (Map.Entry<Long, Set<Integer>> e : equivalent.entrySet()) {
              Set<Integer> vertices = e.getValue();
              if (vertices.size() < minSize && vertices.size() > 1) {
                  min = vertices;
                  minSize = vertices.size();
              }
          }
  
          return min;
      }
focal_method.class_method_signature: MinimumEquivalentCyclicSet.find(long[] invariants, IAtomContainer container, int[][] graph)
focal_method.full_signature: @Override Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph)
focal_method.identifier: find
focal_method.invocations: get cyclic add put add emptySet entrySet getValue size size size
focal_method.modifiers: @Override
focal_method.parameters: (long[] invariants, IAtomContainer container, int[][] graph)
focal_method.return: Set<Integer>
focal_method.signature: Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph)