public void BFSTest1() { Graph SomeGraph = new Graph(); int[] correctBFS = { 1, 2, 3, 4 }; int[] correctBFS2 = { 1, 3, 2, 4 }; int[] tryBFS = new int[4]; SomeGraph.AddNode(1); SomeGraph.AddNode(2); SomeGraph.AddNode(3); SomeGraph.AddNode(4); SomeGraph.AddEdge(1, 2); SomeGraph.AddEdge(1, 3); SomeGraph.AddEdge(3, 4); int i = 0; foreach (int n in GraphAlgorithms.BFS(SomeGraph, 1)) { tryBFS[i] = n; i += 1; } try { CollectionAssert.AreEqual(correctBFS, tryBFS); } catch { CollectionAssert.AreEqual(correctBFS2, tryBFS); } }
private static void CheckDistanceCards(List <City> cityList, Player player) { foreach (AbstrDestCard card in player.GetDestinationCards()) // check if the player made a new network { City a, b; card.getCities(out a, out b); if (GraphAlgorithms.BFS(cityList.Count, player, a, b)) { player.addPoints(card.getPoints()); player.GetDestinationCards().Remove(card); break; } } Console.WriteLine(player.ToString()); }