test_class.file: tool/hash/src/test/java/org/openscience/cdk/hash/MinimumEquivalentCyclicSetUnionTest.java
test_class.identifier: MinimumEquivalentCyclicSetUnionTest
test_case.body: @Test
      public void testFind() throws Exception {
          IAtomContainer dummy = mock(IAtomContainer.class);
          int[][] g = new int[][]{{1, 5, 6}, {0, 2}, {1, 3}, {2, 4, 7}, {3, 5}, {0, 4}, {0}, {3}};
  
          // mock the invariants
          long[] values = new long[]{1, 4, 3, 1, 3, 5, 7, 8};
  
          EquivalentSetFinder finder = new AllEquivalentCyclicSet();
          Set<Integer> set = finder.find(values, dummy, g);
  
          assertThat(set.size(), is(4));
          // the first size vertex are all in a cycle
          assertTrue(set.contains(0));
          assertTrue(set.contains(2));
          assertTrue(set.contains(3));
          assertTrue(set.contains(4));
      }
test_case.class_method_signature: MinimumEquivalentCyclicSetUnionTest.testFind()
test_case.full_signature: @Test public void testFind()
test_case.identifier: testFind
test_case.invocations: mock find assertThat size is 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()
focal_class.file: tool/hash/src/main/java/org/openscience/cdk/hash/MinimumEquivalentCyclicSetUnion.java
focal_class.identifier: MinimumEquivalentCyclicSetUnion
focal_class.class_method_signature: MinimumEquivalentCyclicSetUnion.find(long[] invariants, IAtomContainer container, int[][] graph)
focal_class.full_signature: @Override public Set<Integer> find(long[] invariants, IAtomContainer container, int[][] graph)
focal_class.identifier: find
focal_class.modifiers: @Override public
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
      public 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();
              } else if (vertices.size() == minSize) {
                  min.addAll(vertices);
              }
          }
  
          return min;
      }
focal_method.class_method_signature: MinimumEquivalentCyclicSetUnion.find(long[] invariants, IAtomContainer container, int[][] graph)
focal_method.full_signature: @Override public 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 size addAll
focal_method.modifiers: @Override public
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)