public void TestWithoutRelevant() { // G is // 0-1-2 3-4-5 var g = new PathConstraintUtils.SimpleGraph { NodeCount = 6, Neighbours = new [] { new [] { 1 }, new [] { 0, 2 }, new [] { 1 }, new [] { 4 }, new [] { 3, 5 }, new [] { 4 }, } }; var walkable = new bool[6]; for (var i = 0; i < 6; i++) { walkable[i] = true; } var art = PathConstraintUtils.GetArticulationPoints(g, walkable); Assert.AreEqual(false, art[0]); Assert.AreEqual(true, art[1]); Assert.AreEqual(false, art[2]); Assert.AreEqual(false, art[3]); Assert.AreEqual(true, art[4]); Assert.AreEqual(false, art[5]); }
public void TestWithRelevant2() { var g = new PathConstraintUtils.SimpleGraph { NodeCount = 4, Neighbours = new[] { new [] { 1 }, new [] { 0, 2 }, new [] { 1, 3 }, new [] { 2 }, } }; var walkable = new bool[4]; for (var i = 0; i < 4; i++) { walkable[i] = true; } var relevant = new bool[4]; relevant[0] = true; relevant[3] = true; var art = PathConstraintUtils.GetArticulationPoints(g, walkable, relevant).IsArticulation; Assert.AreEqual(false, art[0]); Assert.AreEqual(true, art[1]); Assert.AreEqual(true, art[2]); Assert.AreEqual(false, art[3]); }
public Resolution Check(WavePropagator wp) { var wave = wp.Wave; var indices = wp.Indices; // Initialize couldBePath and mustBePath based on wave possibilities var couldBePath = new bool[indices]; var mustBePath = new bool[indices]; for (int i = 0; i < indices; i++) { var couldBe = false; var mustBe = true; for (int p = 0; p < wp.PatternCount; p++) { if (wave.Get(i, p)) { if (PathPatterns.Contains(p)) { couldBe = true; } if (!PathPatterns.Contains(p)) { mustBe = false; } } } couldBePath[i] = couldBe; mustBePath[i] = mustBe; } // Select relevant cells, i.e. those that must be connected. bool[] relevant; if (EndPoints == null) { relevant = mustBePath; } else { relevant = new bool[indices]; if (EndPoints.Length == 0) { return(Resolution.Undecided); } foreach (var endPoint in EndPoints) { var index = wp.Topology.GetIndex(endPoint.X, endPoint.Y, endPoint.Z); relevant[index] = true; } } var walkable = couldBePath; var isArticulation = PathConstraintUtils.GetArticulationPoints(wp.Topology, walkable, relevant); if (isArticulation == null) { return(Resolution.Contradiction); } // All articulation points must be paths, // So ban any other possibilities for (var i = 0; i < indices; i++) { if (!isArticulation[i]) { continue; } for (int p = 0; p < wp.PatternCount; p++) { if (!PathPatterns.Contains(p) && wave.Get(i, p)) { wp.InternalBan(i, p); } } } return(Resolution.Undecided); }