Exemple #1
0
        private IList <int> FindMcGregorMapping(List <int> mArcs, McgregorHelper mcGregorHelper)
        {
            int        neighborBondNumA  = mcGregorHelper.NeighborBondNumA;
            int        neighborBondNumB  = mcGregorHelper.NeighborBondNumB;
            List <int> currentMapping    = new List <int>(mcGregorHelper.GetMappedAtomsOrg());
            List <int> additionalMapping = new List <int>();

            for (int x = 0; x < neighborBondNumA; x++)
            {
                for (int y = 0; y < neighborBondNumB; y++)
                {
                    if (mArcs[x * neighborBondNumB + y] == 1)
                    {
                        ExtendMapping(x, y, mcGregorHelper, additionalMapping, currentMapping);
                    }
                }
            }

            int additionalMappingSize = additionalMapping.Count;

            //add McGregorBondTypeInSensitive mapping to the Clique mapping
            for (int a = 0; a < additionalMappingSize; a += 2)
            {
                currentMapping.Add(additionalMapping[a + 0]);
                currentMapping.Add(additionalMapping[a + 1]);
            }

            //        remove recurring mappings from currentMapping

            var uniqueMapping = McGregorChecks.RemoveRecurringMappings(currentMapping);

            return(uniqueMapping);
        }
Exemple #2
0
        private int Iterator(McgregorHelper mcGregorHelper)
        {
            bool       mappingCheckFlag = mcGregorHelper.IsMappingCheckFlag;
            int        mappedAtomCount  = mcGregorHelper.MappedAtomCount;
            List <int> mappedAtoms      = new List <int>(mcGregorHelper.GetMappedAtomsOrg());
            int        neighborBondNumA = mcGregorHelper.NeighborBondNumA;
            int        neighborBondNumB = mcGregorHelper.NeighborBondNumB;

            //        //check possible mappings:
            bool furtherMappingFlag = McGregorChecks.IsFurtherMappingPossible(source, target, mcGregorHelper,
                                                                              IsBondMatch);

            if (neighborBondNumA == 0 || neighborBondNumB == 0 || mappingCheckFlag || !furtherMappingFlag)
            {
                SetFinalMappings(mappedAtoms, mappedAtomCount);
                return(0);
            }

            modifiedARCS.Clear();
            int size = neighborBondNumA * neighborBondNumB;

            for (int i = 0; i < size; i++)
            {
                modifiedARCS.Insert(i, 0);
            }
            SetModifedArcs(mcGregorHelper);
            first         = new BinaryTree(-1);
            last          = first;
            last.Equal    = null;
            last.NotEqual = null;
            bestarcsleft  = 0;

            Startsearch(mcGregorHelper);
            var bestArcsCopy = new Stack <IReadOnlyList <int> >();

            foreach (var bestArc in bestArcs)
            {
                bestArcsCopy.Push(bestArc);
            }
            while (bestArcs.Count != 0)
            {
                bestArcs.Pop();
            }
            SearchAndExtendMappings(bestArcsCopy, mcGregorHelper);

            //Console.Out.WriteLine("In the iterator Termination");
            //Console.Out.WriteLine("============+++++++++==============");
            //Console.Out.WriteLine("Mapped Atoms before iterator Over: " + mappedAtoms);
            return(0);
        }