Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know there is alot of shortest path Algorithms but i want to ask if there any modifications can be done , to make some Algorithms like a* or Dijkstra chose the shortest path but without the diagonally moves so up and
down and right and left are the allowed moves
The algorithm you probably want is A* (if you want a short path over a large map with some coherent obstacles), though you might just need Dijkstra's (if you must have the mathematically shortest path, or if the map doesn't have any real relation to anything physical). You simply disallow diagonal moves and you might get better results if you use Manhattan distance as your heuristic for A*. For Dijkstra's, the graph has no diagonal links.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
So, I have been doing research about solving the Game Strategy problem of ICPC 2014 (page 7).
This consist in a board game with n boxes, each box have a unique set of paths that goes to another box on the board (can have a path that goes to itself). I think a graph would be a good representation of the game, more specific a directed graph
graphic case representation whit n = 2
I found 2 possible algorithms that should solve the problem:
1.- A YouTube video where it says that i should use the Breadth-first search
2.- Blog commenting the solution of some of the problems of that ICPC year. The author says that DP (dynamic programming) can be used. In Wikipedia's page is explained an algorithm called Dijkstra's algorithm which is used for "the shortest path problem" as the page says.
Is one of these algorithms an better solution for the problem? does one of those have better performance or something like that?
You use Breadth-first search (shortyly BFS) when the graph's edges are without weight (as your case) and Dijkstra's algorithm for weighted graph.
As a side note, remember that Dijkstra doesn't work when you have edges with negative values.
Thinking of complexity, this question might be in your interest: Why use Dijkstra's Algorithm if Breadth First Search (BFS) can do the same thing faster?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
So, I have an assignment that I have to represent both adjacent and incidence matrixes statically and then, use a greedy algorithm to find the shortest path (I guess that it can be lowest cost as well, not sure) that goes through all vertices having 1 as origin.
Here's an image of the graph:
I'm kinda lost on how to do it, could somebody please give me some tips?
Greedy Algorithm:
While (Not at node 1)
{
if already visited current node, fail.
look at all current node's exit costs and choose the lowest as next destination.
go to next location.
}
success.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Lets assume i have a weighted undirected graph with edges and wanted to find the shortest path as well as all possible paths that i could follow from the startpoint to the endpoint with distances, what would be the best way to implement this? Breadth depth search and k paths algorithm seem to offer reasonable solutions, although im not sure which is best
Sorry, can't post this as comments...
If you need all possible paths, you can't do really better than "tree" traversal (BFS or DFS for instance). Note that you'll need to consider each node as many times as it can be reached from the start (the "tree" is much bigger than the original graph - even infinite if you have cycles in your graph, but let's assume you don't).
To get the smallest path, you could look for it in your list in the end; or preferably, you could use a Dijkstra-like order for your tree traversal, so the shortest path will be the first to come up.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a beginner trying to implement the A* search algorithm for practice and I'm wondering what is the best way of going about it. I have created a graph structure (adjacency matrix) and my plan was to apply the A* to an initial and goal vertex. Also creating the heuristic and improving it as I go along. Question is, can this even work? I have had a look at other implementations and they have done it using different data structures.
That depends on how you implemented the adjacency matrix.
One critical point of A* is finding a node's neighbors. If you implement the matrix as a simple dense bit field, where you have a 1 for adjacent nodes and a 0 for non-adjacent ones, then this search is quite inefficient because you have to check every node. Although inefficient, this does not prevent you from implementing A*.
If you have a more involved implementation of the adjacency matrix, e.g. as a sparse matrix, which allows you to query the neighbors directly, this will be better suited for A*.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Say you were given a black box that solves a clique problem in constant time.
You give the black box an undirected graph G with a bound k and it outputs either "Yes" or "No" that the graph G has a clique with at least k vertices.
How would you use this black box to find the vertices of a maximum clique in polynomial time?
As a hint, think about what happens if you choose a node from the graph, delete it, and then check whether there's still a k-clique. The black box will either say that there is or that there isn't. What do you learn if there still is a k-clique? What do you learn if there isn't?
Hope this helps!