Ways of implementing a greedy algorithm [closed] - algorithm

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.

Related

Best way to implement shortest path algorithm with directed graph [closed]

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.

Shortest path without diagonally moves [closed]

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.

Found an algorithm that returns all nodes [closed]

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 7 years ago.
Improve this question
in directed graph, each edge has a color C(e)ϵ{1,2,…k}
Found an algorithm that returns all nodes that are on circle traversal
Containing at least one edge of each color.
i think it related to SCC algorithm, but i didnt know how to start
any ideas that can help me?
Perform DFS to find cycles, and check each cycle found to see if it contains edges of all the colors.

Finding vertices of a maximum clique in polynomial time [closed]

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!

Graph Theory: Clique concepts [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was trying to solve a basic clique problem but i have stucked at some following points:
what is is the minimum size of the largest clique in any graph with N nodes and M edges
To Find the largest clique in a graph
Please tell me difference between above two statement.
The first is a question about the set of all graphs with N nodes and M edges. The second question appears to be about a particular graph (although it seems to be out of context).
It might be better to ask this on https://math.stackexchange.com/

Resources