public void Setup() { graph = new Graph(new int[,] { { 0, 0, 0 }, { 0, 0, 1 }, // Obstacle still part of adjacencyList { 0, 0, 0 } }); node = graph.nodes[graph.nodes.Length / 2]; }
public void Setup() { grid = new int[,] { { 1, 1, 0, 1, 0 }, { 0, 1, 0, 1, 1 }, { 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 1, 1, 1, 0, 0 } }; graph = new Graph(grid); }
public void UpdateGraphOnDragStop() { Graph graph = new Graph(new int[,] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }); Graph expectedGraph = new Graph(new int[,] { { 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 0 }, { 0, 1, 1, 1, 0 }, { 0, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0 } }); // User Drag and Drop Event CollectionAssert.AreEqual(expectedGraph.nodes, graph.nodes); }
public void UpdateGraphObstacles() { Graph graph = new Graph(new int[,] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }); Graph expectedGraph = new Graph(new int[,] { { 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 0 }, { 0, 1, 1, 1, 0 }, { 0, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0 } }); Search search = new Search(graph); search.Start(graph.nodes[0], graph.nodes[12]); while (!search.finished) { search.Step(); } // User Drag and Drop Event Assert.AreEqual<Graph>(graph.Update(), expectedGraph); CollectionAssert.AreEqual(expectedGraph.nodes, graph.nodes); // If assertion passes without re-instantiating, graph is passed as reference (which is preferred) //search = new Search(graph); // Verify that center node is now unreachable search.Start(graph.nodes[0], graph.nodes[12]); while(!search.finished) { search.Step(); } Assert.AreEqual(0, search.path.Count); }
public Search(Graph g) { graph = g; }
public void Setup() { int[,] nodes = new int[,] { { 1, 1, 0, 1, 0 }, { 0, 1, 0, 1, 1 }, { 1, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 1, 1, 1, 0, 0 } }; graph = new Graph(nodes); search = new Search(graph); }