Пример #1
0
        public void FindAllTargetsWithPredecessor()
        {
            var bfs = new BreadthFirstSearch <int>(EqualityComparer <int> .Default, x => new[] { x * 2, x * 3 });

            var result = bfs.FindAll2(1, node => node.Predecessor?.Item == 64, null, 1);

            Assert.IsTrue(result.Count == 1 || result.Count == 2);
            Assert.IsTrue(result.All(x => x.Target == 128 || x.Target == 192));
        }
Пример #2
0
        public void FindAllTargetsWithDistance()
        {
            var bfs = new BreadthFirstSearch <int>(
                EqualityComparer <int> .Default,
                (int x) => (x > 100) ? Enumerable.Empty <int>() : new[] { x * 2, x * 3 });

            var result = bfs.FindAll2(1, node => node.Distance > 4);

            Assert.AreEqual(13, result.Count);
        }