예제 #1
0
        bool FMatchRecursive()
        {
            Match           mchCur;
            CandidateFinder cf;

            if (FCompleteMatch())
            {
                return(true);
            }

            cf = new CandidateFinder(this);
            while ((mchCur = cf.NextCandidateMatch()) != null)
            {
                if (FFeasible(mchCur))
                {
                    BacktrackRecord btr = new BacktrackRecord();
                    AddMatchToSolution(mchCur, btr);
                    if (FMatchRecursive())
                    {
                        _fSuccessfulMatch = true;
                        return(true);
                    }
                    btr.Backtrack(this);
                }
            }
            return(false);
        }
        public void TestMatchBacktrack()
        {
            var vfs = VfsTest();
            var btr = new BacktrackRecord();

            btr.SetMatch(0, 1, vfs);
            var grp1 = vfs.VfGraph1.GetGroup(0);
            var grp2 = vfs.VfGraph2.GetGroup(1);

            Assert.IsTrue((((int)grp1 & (int)Group.ContainedInMapping)) != 0);
            Assert.IsTrue((((int)grp2 & (int)Group.ContainedInMapping)) != 0);
            Assert.AreEqual(Group.ContainedInMapping, vfs.VfGraph1.GetGroup(0));
            Assert.AreEqual(Group.ContainedInMapping, vfs.VfGraph2.GetGroup(1));
            btr.Backtrack(vfs);
            grp1 = vfs.VfGraph1.GetGroup(0);
            grp2 = vfs.VfGraph2.GetGroup(1);

            Assert.IsFalse((((int)grp1 & (int)Group.ContainedInMapping)) != 0);
            Assert.IsFalse((((int)grp2 & (int)Group.ContainedInMapping)) != 0);
            Assert.AreEqual(Group.Disconnected, vfs.VfGraph1.GetGroup(0));
            Assert.AreEqual(Group.Disconnected, vfs.VfGraph2.GetGroup(1));
        }
예제 #3
0
            public void TestMatchBacktrack()
            {
                VfState         vfs = VfsTest();
                BacktrackRecord btr = new BacktrackRecord();

                btr.SetMatch(0, 1, vfs);
                Groups grp1 = vfs.Vfgr1.GetGroup(0);
                Groups grp2 = vfs.Vfgr2.GetGroup(1);

                Assert.IsTrue((((int)grp1 & (int)Groups.ContainedInMapping)) != 0);
                Assert.IsTrue((((int)grp2 & (int)Groups.ContainedInMapping)) != 0);
                Assert.AreEqual(Groups.ContainedInMapping, vfs.Vfgr1.GetGroup(0));
                Assert.AreEqual(Groups.ContainedInMapping, vfs.Vfgr2.GetGroup(1));
                btr.Backtrack(vfs);
                grp1 = vfs.Vfgr1.GetGroup(0);
                grp2 = vfs.Vfgr2.GetGroup(1);

                Assert.IsFalse((((int)grp1 & (int)Groups.ContainedInMapping)) != 0);
                Assert.IsFalse((((int)grp2 & (int)Groups.ContainedInMapping)) != 0);
                Assert.AreEqual(Groups.Disconnected, vfs.Vfgr1.GetGroup(0));
                Assert.AreEqual(Groups.Disconnected, vfs.Vfgr2.GetGroup(1));
            }