public void FindAllTargetsWithDistance() { var search = new AStarSearch <int>( EqualityComparer <int> .Default, FiniteExpander); var targets = new Dictionary <int, float> { { 6, 1.8f }, { 12, 2.8f }, { 24, 3.8f }, { 36, 3.6f }, { 72, 4.6f }, { 108, 4.6f }, { 192, 6.8f } }; var result = search.FindAll(1, node => targets.ContainsKey(node), GrowHeuristic); Assert.AreEqual(targets.Count, result.Count); foreach (var hit in result) { Assert.AreEqual(targets[hit.Target], hit.Cost, 1e-6f); } }
public void FindTargetSetInInfiniteGraph() { var search = new AStarSearch <int>(EqualityComparer <int> .Default, InfiniteExpander); var result = search.FindAll(1, x => x < 30, ShrinkHeuristic, null, 12); var expected = new[] { 1, 2, 4, 8, 16, 3, 6, 12, 24, 9, 18, 27 }; Assert.AreEqual(12, result.Count); foreach (var target in expected) { Assert.IsTrue(result.Any(p => p.Target == target)); } }