Exemple #1
0
        public override long[] Generate(IAtomContainer container)
        {
            int[][]    graph      = ToAdjList(container);
            Suppressed suppressed = suppression.Suppress(container);

            return(Generate(seedGenerator.Generate(container), factory.Create(container, graph), graph, suppressed));
        }
Exemple #2
0
        private long[] Generate(IAtomContainer container, long[] seeds, IStereoEncoder encoder, int[][] graph)
        {
            Suppressed suppressed = suppression.Suppress(container);

            // compute original values then find indices equivalent values
            long[] original      = simple.Generate(seeds, encoder, graph, suppressed);
            var    equivalentSet = finder.Find(original, container, graph);
            var    equivalents   = equivalentSet.ToArray();

            // size of the matrix we need to make
            int n = original.Length;
            int m = equivalents.Length;

            // skip when there are no equivalent atoms
            if (m < 2)
            {
                return(original);
            }

            // matrix of perturbed values and identity values
            long[][] perturbed = Arrays.CreateJagged <long>(n, m + 1);

            // set the original values in the first column
            for (int i = 0; i < n; i++)
            {
                perturbed[i][0] = original[i];
            }

            // systematically perturb equivalent vertex
            for (int i = 0; i < m; i++)
            {
                int equivalentIndex = equivalents[i];

                // perturb the value and reset stereo configuration
                original[equivalentIndex] = Rotate(original[equivalentIndex]);
                encoder.Reset();

                // compute new hash codes and copy the values a column in the matrix
                long[] tmp = simple.Generate(Copy(original), encoder, graph, suppressed);
                for (int j = 0; j < n; j++)
                {
                    perturbed[j][i + 1] = tmp[j];
                }

                // reset value
                original[equivalentIndex] = perturbed[equivalentIndex][0];
            }

            return(Combine(perturbed));
        }
Exemple #3
0
        public long[] Generate(IAtomContainer container)
        {
            Suppressed suppressed = suppression.Suppress(container);

            int n    = container.Atoms.Count;
            int m    = n - suppressed.Count; // number of non-suppressed vertices
            int seed = m > 1 ? 9803 % m : 1;

            long[] hashes = new long[n];

            for (int i = 0; i < n; i++)
            {
                hashes[i] = Distribute(seed * encoder.Encode(container.Atoms[i], container));
            }
            return(hashes);
        }