public void TriangleDfsTest() { target = new Searcher(W, H); int[,] expected = new int[,] { { 0, 1, 2, 3}, {10, 8, 6, 4}, {11, 9, 7, 5}, }; int[,] actual = target.Search(0, 0, LatticeType.Triangle, SearchType.DFS); this.areEqual(expected, actual); }
public void TriangleBfsTest() { target = new Searcher(W, H); int[,] expected = new int[,] { { 0, 1, 4, 9}, { 3, 2, 5, 10}, { 8, 7, 6, 11}, }; int[,] actual = target.Search(0, 0, LatticeType.Triangle, SearchType.BFS); this.areEqual(expected, actual); }
public void SquareBfsTest() { target = new Searcher(W, H); int[,] expected = new int[,] { { 0, 1, 3, 6}, { 2, 4, 7, 9}, { 5, 8, 10, 11}, }; int[,] actual = target.Search(0, 0, LatticeType.Square, SearchType.BFS); this.areEqual(expected, actual); }
private void DrawButton_Click(object sender, RoutedEventArgs e) { cvsMain.Children.Clear(); this.WidthMax = (int)cvsMain.RenderSize.Width; this.HeightMax = (int)cvsMain.RenderSize.Height; this.Ox = L; this.Oy = L; LatticeType latticeType; SearchType searchType; try { int h = int.Parse(tbHeight.Text) * L; if (h < this.Oy || this.HeightMax < this.Oy + h) { throw new Exception("Height is out of range"); } this.Height = h; int w = int.Parse(tbWidth.Text) * L; if (w < this.Ox || this.WidthMax < this.Ox + w) { throw new Exception("Width is out of range"); } this.Width = w; var item = cbLatticeType.SelectedItem as ComboBoxItem; switch (item.Content.ToString()) { case "Square": goto default; case "Triangle": latticeType = LatticeType.Triangle; break; default: latticeType = LatticeType.Square; break; } item = cbSearchType.SelectedItem as ComboBoxItem; switch (item.Content.ToString()) { case "DFS": goto default; case "BFS": searchType = SearchType.BFS; break; default: searchType = SearchType.DFS; break; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } this.drawLattice(Ox, Oy, Width/L, Height/L, L, latticeType); var searcher = new Searcher(Width/L, Height/L); int[,] orders = searcher.Search(0, 0, latticeType, searchType); int xOffset = 4, yOffset = 8; for (int j = 0; j < Height/L; j++) { for (int i = 0; i < Width/L; i++) { this.drawText(L*(i+1) - xOffset, L*(j+1) - yOffset, string.Format("{0}", orders[j,i])); } } }
public void XLineBfsTest() { target = new Searcher(W, 1); int[,] expected = new int[,] { { 0, 1, 2, 3} }; int[,] actual = target.Search(0, 0, LatticeType.Triangle, SearchType.BFS); this.areEqual(expected, actual); }
public void YLineDfsTest() { target = new Searcher(1, H); int[,] expected = new int[,] { {0}, {1}, {2} }; int[,] actual = target.Search(0, 0, LatticeType.Square, SearchType.DFS); this.areEqual(expected, actual); }