public void cheapestFirePathTest() { TravelWorld world = new TravelWorld(); world.AddPlaces(1, 2, 3, 4); world.AddWay(1, 2, 10); world.AddWay(2, 3, 5); world.AddWay(4, 3, 5); world.SetFire(1, 2); world.SetFire(4, 3); var paths = world.findCheapestFirePaths(2).ToArray(); if (paths.Count() != 2) { Assert.Fail(); } var path1 = paths[0]; var path2 = paths[1]; var resPath1 = new TravelPath(); resPath1.Add(1, 10); var resPath2 = new TravelPath(); resPath2.Add(3, 5); resPath2.Add(4, 5); Assert.IsTrue( path1.Equals(resPath1) && path2.Equals(resPath2) || path1.Equals(resPath2) && path2.Equals(resPath1)); }
public void cheapestWaterPathWithFire() { TravelWorld world = new TravelWorld(); world.AddPlaces(1, 2, 3, 4); world.AddWay(1, 2, 10); world.AddWay(2, 3, 1); world.AddWay(4, 3, 1); world.PutWater(1, 4); world.SetFire(2, 3); world.SetFire(4, 3); var paths = world.findCheapestWaterPaths(2); if (paths.Count() != 1) { Assert.Fail(); } var path = paths.First(); var resPath = new TravelPath(); resPath.Add(1, 10); Assert.AreEqual(path, resPath); }
public void ClearPathTest() { TravelWorld world = new TravelWorld(); world.AddPlaces(1, 2, 3, 4, 5); for (int i = 1; i <= 4; i++) { world.AddWay(i, i + 1, 1); } world.AddWay(5, 1, 1); world.SetFire(1, 2); var path = world.ShortestClearPath(1, 3); var resPath = new TravelPath(); resPath.Add(5, 1); resPath.Add(4, 1); resPath.Add(3, 1); Assert.IsTrue(resPath.Equals(path)); }
public void cheapestFirePathTest2() { TravelWorld world = new TravelWorld(); world.AddPlaces(1, 2, 3, 4); world.AddWay(1, 2, 10); world.AddWay(2, 3, 5); world.AddWay(4, 3, 5); world.SetFire(1, 2); var paths = world.findCheapestFirePaths(2).ToArray(); if (paths.Count() != 1) { Assert.Fail(); } var path1 = paths.First(); var resPath1 = new TravelPath(); resPath1.Add(1, 10); Assert.AreEqual(path1, resPath1); }