private void ViewPort_Loaded(object sender, RoutedEventArgs e) { width = (int)this.ViewPortContainer.ActualWidth; height = (int)this.ViewPortContainer.ActualHeight; writeableBitmap = BitmapFactory.New(width, height); ViewPort.Source = writeableBitmap; PrintTheMap(); CompositionTarget.Rendering += CompositionTarget_Rendering; MazeState state = new MazeState(); if (ALGORITHM_CHOOSER == 0) { var dfs = new DeepFirstSearcher(state); new Thread(() => dfs.Search()).Start(); } if (ALGORITHM_CHOOSER == 1) { var bfs = new BreadthFirstSearcher(state); new Thread(() => bfs.Search()).Start(); } if (ALGORITHM_CHOOSER == 2) { var ast = new AStarSearcher(state); new Thread(() => ast.Search()).Start(); } }
public void search_breadth_first() { var a = new Vertex <string> { Value = "Cat" }; var b = new Vertex <string> { Value = "Rat" }; var c = new Vertex <string> { Value = "Dog" }; var d = new Vertex <string> { Value = "Dog" }; a.AddEdge(b); b.AddEdge(c); a.AddEdge(d); var graph = new Graph <string>(); graph.AddVertex(a); graph.AddVertex(b); graph.AddVertex(c); graph.AddVertex(d); var bfsSearcher = new BreadthFirstSearcher <string>(); var result = bfsSearcher.Search(graph, a, s => s == "Dog"); result.Should().Be(d); }
public void return_null_if_starting_vertex_not_in_graph() { var a = new Vertex <string> { Value = "Dog" }; var b = new Vertex <string> { Value = "Dog" }; var c = new Vertex <string> { Value = "Dog" }; a.AddEdge(b); b.AddEdge(c); var graph = new Graph <string>(); graph.AddVertex(b); var bfsSearcher = new BreadthFirstSearcher <string>(); var result = bfsSearcher.Search(graph, a, s => s == "Dog"); result.Should().Be(null); }
public bool SearchBreadthFirst(T thing) { if (_root == null) { return(false); } var bfs = new BreadthFirstSearcher <T>(); return(bfs.Search(_root, thing)); }
public void return_starting_vertex_if_meets_criteria() { var a = new Vertex <string> { Value = "Dog" }; var b = new Vertex <string> { Value = "Dog" }; a.AddEdge(b); var graph = new Graph <string>(); graph.AddVertex(a); graph.AddVertex(b); var bfsSearcher = new BreadthFirstSearcher <string>(); var result = bfsSearcher.Search(graph, a, s => s == "Dog"); result.Should().Be(a); }