graph-algorithm

What to use for flow free-like game random level creation?

旧街凉风 提交于 2019-11-28 15:55:00
I need some advice. I'm developing a game similar to Flow Free wherein the gameboard is composed of a grid and colored dots, and the user has to connect the same colored dots together without overlapping other lines, and using up ALL the free spaces in the board. My question is about level-creation. I wish to make the levels generated randomly (and should at least be able to solve itself so that it can give players hints) and I am in a stump as to what algorithm to use. Any suggestions? Note: image shows the objective of Flow Free, and it is the same objective of what I am developing. Thanks

Best algorithm to determine if an undirected graph is a tree

徘徊边缘 提交于 2019-11-28 12:26:26
What is the time complexity of the Best algorithm to determine if an undirected graph is a tree?? can we say Big-oh(n) , with n vertices?? Yes, it is O(n). With a depth-first search in a directed graph has 3 types of non-tree edges - cross, back and forward. For an undirected case, the only kind of non-tree edge is a back edge. So, you just need to search for back edges. In short, choose a starting vertex. Traverse and keep checking if the edge encountered is a back edge. If you find n-1 tree edges without finding back-edges and then, run out of edges, you're gold. (Just to clarify - a back

How to generate a maze with more than one successful path?

时光毁灭记忆、已成空白 提交于 2019-11-28 11:46:13
Which algorithm can be used to generate a maze with more than one successful path and if algorithm is modified version of some well known algorithm then explain or add a link . I am using 2D array A to store configuration of maze . Assume if the size of maze is n * n then more than one path should be there from A[0][0] to A[n-1][n-1] . This algorithms should be able to generate mazes with distinct loop-free paths from start to goal: Starting with an empty maze (or a solid block of rock), with just the start and the goal... Subdivide the maze into three sets: Start (intially holding just the

How to find the shortest simple path in a Tree in a linear time?

人走茶凉 提交于 2019-11-28 09:22:29
Here is a problem from Algorithms book by Vazirani The input to this problem is a tree T with integer weights on the edges. The weights may be negative, zero, or positive. Give a linear time algorithm to find the shortest simple path in T. The length of a path is the sum of the weights of the edges in the path. A path is simple if no vertex is repeated. Note that the endpoints of the path are unconstrained. HINT: This is very similar to the problem of finding the largest independent set in a tree. How can I solve this problem in linear time? Here is my algorithm but I'm wonder if it is linear

Efficiently find all connected induced subgraphs

被刻印的时光 ゝ 提交于 2019-11-28 09:19:52
Is there an efficient(*) algorithm to find all the connected (induced) subgraphs of a connected undirected vertex-labelled graph? (*) I appreciate that, in the general case, any such algorithm may have O(2^n) complexity because, for a clique (Kn), there are 2^n connected subgraphs. However, the graphs I'm typically dealing with will have far fewer connected subgraphs, so I'm looking for a way to generate them without having to consider all 2^n subgraphs and throw away those that aren't connected (as in the solution to this question ). An algorithm that has running time that's linear in the

How can I use the A star algorithm to find the first 100 shortest paths?

拜拜、爱过 提交于 2019-11-28 05:49:54
问题 How can I use the A star algorithm to find the first 100 shortest paths? 回答1: The problem of finding k'th shortest path is NP-Hard, so any modification to A-Star that will do what you are after - will be exponential in the size of the input. Proof: (Note: I will show on simple paths) Assume you had a polynomial algorithm that runs in polynomial time and returns the length of k the shortest path let the algorithm be A(G,k) The maximal number of paths is n! , and by applying binary search on

Explanation of Algorithm for finding articulation points or cut vertices of a graph

谁都会走 提交于 2019-11-28 04:32:18
I have searched the net and could not find any explanation of a DFS algorithm for finding all articulation vertices of a graph. There is not even a wiki page. From reading around, I got to know the basic facts from here. PDF There is a variable at each node which is actually looking at back edges and finding the closest and upmost node towards the root node. After processing all edges it would be found. But I do not understand how to find this down & up variable at each node during the execution of DFS. What is this variable doing exactly? Please explain the algorithm. Thanks. Ashish Negi

Why does Dijkstra's algorithm use decrease-key?

巧了我就是萌 提交于 2019-11-28 02:48:16
Dijkstra's algorithm was taught to me was as follows while pqueue is not empty: distance, node = pqueue.delete_min() if node has been visited: continue else: mark node as visited if node == target: break for each neighbor of node: pqueue.insert(distance + distance_to_neighbor, neighbor) But I've been doing some reading regarding the algorithm, and a lot of versions I see use decrease-key as opposed to insert. Why is this, and what are the differences between the two approaches? The reason for using decrease-key rather than reinserting nodes is to keep the number of nodes in the priority queue

OpenGL ES 2.0 Vertex Transformation Algorithms

前提是你 提交于 2019-11-27 22:20:44
问题 I'm developing an image warping iOS app with OpenGL ES 2.0. I have a good grasp on the setup, the pipeline, etc., and am now moving along to the math. Since my experience with image warping is nil, I'm reaching out for some algorithm suggestions. Currently, I'm setting the initial vertices at points in a grid type fashion, which equally divide the image into squares. Then, I place an additional vertex in the middle of each of those squares. When I draw the indices, each square contains four

Eppstein's algorithm and Yen's algorithm for k shortest paths

旧街凉风 提交于 2019-11-27 21:45:39
问题 I'm trying to understand exactly how these algorithms work, but I have been unable to find a simple explanation. I would greatly appreciate it if someone could provide or point me to a description of these algorithms that is easier to understand than the description in the original papers. Thanks. 回答1: First of all let me provide you with the links to the papers you were talking about. Eppstein's paper: D. Eppstein, “Finding the k shortest paths,” SIAM J. Comput., vol. 28, no. 2, pp.652–673,