private static int DFS(Node Start) { if (Start.getGoal()) { MessageBox.Show("Stigli smo do cilja, ura!"); return(1); } else { int k = 0; Start.mark(); Start.getButton().Visible = false; Start.getButton().Visible = true; System.Threading.Thread.Sleep(10); Start.getButton().BackColor = Color.Blue; Node[] Neighbours = getUnmarkedNeighbours(Start, false); while (Neighbours[k] != null) { if (!Neighbours[k].isMarked() && !Neighbours[k].isBarrier()) { if (DFS(Neighbours[k]) == 1) { // Neighbours[k].getButton().BackColor = Color.Orange; return(1); } } k++; } return(0); } }
public static void BreadthFirstSearch(Node Start) { if (Start.isBarrier() || Start.getGoal()) { MessageBox.Show("Nemoš tako!"); } else { BFS(Start); } }
public static void Azvezda(Node Start) { if (Start.isBarrier() || Start.getGoal()) { MessageBox.Show("Nemoš tako!"); } else { Astar(Start); } }
public static void DepthFirstSearch(Node Start) { if (Start.isBarrier() || Start.getGoal()) { MessageBox.Show("Nemoš tako!"); } else if (DFS(Start) == 0) { MessageBox.Show("Ne postoji put :/"); } }