Since i am new to graph, i am not getting algorithm that can can clearly explain how to find articulation point in graph. Please anyone explain? thanx in advance
A simple algorithm:
For each Node N so:
1. Take it away
2. Count the number of connected components. Either by dfs or bfs.
If that's still one, continue with the loop. If it is two, you have found an articulation point. Mark and continue with the loop.
This will run in quadratic time. Not sure whether there is a better algorithm.
Edit: i found some java source code on this site: http://algs4.cs.princeton.edu/41undirected/Biconnected.java.html
Refer to this explanation. I hope you would find it useful.
http://www.geeksforgeeks.org/articulation-points-or-cut-vertices-in-a-graph/
Related
I'm making a program that implements procedural content generation (PCG) to create maps in a 2d game.
I use the graph data structure as the basis. then the graph will be transformed into a map like in the example image I attached.
with graph specifications as follows:
-vertex can have more than 4 edges
-allowed the formation of cycles in the graph
any suggestions on what method I can use to transform the graph to a 2d map in a grid with space-tight results?
thanks
Uh, that is a tough one. The first problem you will encounter is whether this is even possible for the graph you use. See more below for that specific topic.
Let's say we ignore the fact that your graph could be impossible to map to a grid. I faced the same issue in my Master's Thesis a few years back. (PDF available here; 3.4 World Generation; page 25). I tried to find an algorithm, that could generate my world from a graph structure but ultimately failed. I tried placing one element after the other and implemented some backtracking in case it got stuck. But in the end you're facing a similar complexity to calculating chess moves. At some point you know you messed up, but you don't know how many steps you should go back/reverse, before trying the next one. If you try to solve this by brute force, you're not going to have a good time. And I did not come up with good heuristics to solve it in an adequate time.
My solution: I decided in the end to go with AnswerSet Programming. You're basically not solving the problem with an algorithm, but you find a (more or less) elegant logical representation of your problem and let a logic solver (program specifically made to find a valid solution to your logical problem-representation) do the work. Have a look in my thesis about the details, it was a few years ago and I didn't use one since. I remember however, that this process was not easy and it took me a few days to find a good logical representation of my problem.
Another question to ask: Could you work on the grid directly? Or maybe on a graph structure representing a grid? In the end a grid is nothing else than a graph; every cell is a node and neighbouring connections are the edges. I have quite some experience in the field and would be happy to help you, if you'd like to share what you want to achieve with your generator. I have also a vast collection of resources about procedural generation, maybe you find something helpful there, too.
More on the planarity of a graph: For your graph to be mappable to a plane, it needs to be planar, and checking so is also not trivial. The easiest way - if I'm not mistaken - is to prove the existence of a non-planar sub-graph, e.g. the K5 (the smallest non-planar a complete graph) or K3,3 (the smallest non-planar complete bipartite graph). And even if your graph is planar, it is not necessarily guaranteed that you can put it on your grid.
I'm trying to write a program to find the shortest path in a 3D maze using recursion.
I am able to write the code that finds a random path through the maze but I'm wondering how I can modify my code in order to find the shortest path.
Please note that I want to keep the recursive approach.
Can someone suggest a solution?
Here is a sample 2D maze:
s
XXXX
XX X
XXX
Xe X
One starts from s going to e. X is an obstacle and is the route.
It depends on the algorithm you are implementing. If you want a recursive approach then finding a random path is a good start point (although if the problem is too complex then a bad choice could have huge effects on number of attempts needed for convergence). Afterwards you need to modify the path and for example check whether the new path is shorter than the pervious one; if yes then you continue modifying your parameters in the same direction. Otherwise you have to change your direction.
Exit criterium for the algorithm/ program is normally the difference between the found solution and the ideal solution. So if you know the length of the ideal path (the optimal solution, you need not know the path itself but only its length) in advance then you can define an error margin of 10^-9 for example and once the difference between both solutions is less than this margin your algorithm exits.
In conclusion, this question is a mathematical optimization problem. Optimization is a field which has well-established literature eventhough it is a little bit complex. However if I were you I would search for shortest path algorithms and implement one which is best suited to my application (3D Maze)
This has to be a well researched problem, but I am struggling researching it.
I started here, but I am looking for algorithms to study and implement.
http://en.wikipedia.org/wiki/Graph_isomorphism_problem
For example, if I have two of these DAGs (Directe Acyclic Graphs), I want to mark/delete one of them because it is just a rotation/reflection of the first. Being in the same automorphism group means they can be rotated/reflected to have the exact same adjacency matrix right?
you can use nauty or saucy algorithm to compute this problem.
This links might be helpful to you. :)
Nauty:
http://cs.anu.edu.au/~bdm/nauty/
http://cs.anu.edu.au/~bdm/nauty/
Saucy:
http://vlsicad.eecs.umich.edu/BK/SAUCY/
There is also a list of ready made tools available (especially for command line in linux based OS), in the saucy page.
I am recursively building a graph in java using the graphstream library.. however this graph is so huge so that the recursion is very deep and this ends in stackoverflow. Believe me, even an iteration wouldn't solve my problem.. I will just get a runtime error down the road.
My goal is to use a search algorithm such as Disjktra or A* or whatsoever on the graph in the end.
As I dont have the whole graph, I have been looking in the literature for things such as a shortest path algorithm in a partial maps; use of heuristics I couldn't find much.
I would appreciate it if someone could give me some hints (papers, ideas; an implementation would be a jackpot!!!! :-D) I have looked at algorithms such as PHA* or some others..
I know this post is very old... But I solved it back then using a 1990 Algorithm, from Korf, R. E. (1990) "Real-time heuristic search" Can be found here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.137.1955&rep=rep1&type=pdf
If the graph passed to get.edgelist is directed, does the list of edges as returned by get.edgelist maintain the proper directions? I would think that this is the case but the documentation found here doesn't seem to say anything about it.
Yes, it does. Being one of the igraph authors, I know that this is surely the case. :) We will fix the documentation in the next release.