I am going to implement an algorithm for finding an Eulerian path in an oriented graph and am deciding which algorithm would be the best.
I have found Fleury's algorithm which seems neat but all the examples I have seen consider only non-oriented graphs. Does anyone know if this will work with an oriented graph?
It seems to me that adjacency list can be specified for every single vertex so it should work but I am not 100% sure.
What if there are paralel edges in the graph?
Thanks for any answer!
In a directed graph the inbound and outbound edge must be the same:http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK4/NODE165.HTM
Related
I was recently given the challenge of drawing a house with an x in the middle without lifting my pen, and without retracing any lines. Link to problem
The link above begins to dive into some of the graph theory related to the problem, however there is no mention of how one might go about solving this problem using graph theory algorithms.
What algorithms could be used here, and what would be the correct way to formulate this problem using graph theory language?
Two specific algorithms for constructing an Eulerian path are mentioned in the Wikipedia article on Eulerian paths. These are Fleury's algorithm and Hierholzer's algorithm.
Note that an algorithm that only finds an Euler cycle can also find an Euler trail by augmenting the graph with another edge that joins the 2 vertices that have an odd degree, then rotating the solution so that the added edge is first or last, then removing this edge from the solution found.
I was looking through some text about finding the EMST (Euclidean MST) using Delaunay triangulation technique, but also read somewhere that the EMST can be found through a sweep line algorithm. Since this would easier implementing, I would like to implement this rather than using a existing library.
Can anyone guide me/ direct me to a link to a (possibly free) paper/source that has this algorithm explained?
From this and going by the abstracts, this and this should get you started. They both use sweepline algorithms to obtain MST's
I think the simplest technique for finding Euclidean minimum spanning tree is Delaunay trinangulation, use Bowyer-Watson algorithm. It is very easy to implement, once you have that, you can just use something like Kruskal's algorithm, using the distance as the edge weight.
What is the minimum cost to make an undirected weighted(positive weight) graph disconnected.
i mean i have to find out those edges which removal disconnect the graph and their cost is minimized.
I have following ideas...
1.find out all the bridges of the graph . then the bridge edge of minimum weight wiil be the ans.
2.if there is no bridge that means all the nodes are in a cycle(i'm not sure about it). then i sort the edge according to their weight and the sum of the two minimum edge weight will be the ans.
The graph has no self loop.
Is this algo correct?
This question looks to be the same question answered by the study of "minimum cuts" in graphs. I would recommend the following reading here and here to learn more about why it works from a graph theoretic point of view - the link provides some pseudocode as well.
Regarding your proposed algorithm, finding the bridges in a graph may get tricky.. you would have to inspect both endpoints and their local structure to confirm the existence of a bridge.. using edge contraction perhaps would be simpler to implement.
Please suggest resources to learn how to find a minimal spanning tree in a directed graph using Prim's algorithm, as well as Bellman-Ford algorithm to calculate the shortest path in a directed graph.
Finding an MST from a directed graph is a different problem, for which you cannot simply adapt Prim's. You should instead use Edmond's algorithm.
Bellman Ford already works on directed graphs. No need to alter anything.
The links provided should get you started. Google for additional resources if necessary.
If you'd like some actual code for the algorithms, I recently coded both of these algorithms up.
Prim's algorithm
Bellman-Ford algorithm
The comments at the top of these files contains an analysis of the two algorithms both from a correctness and runtime perspective, and I hope they can shed some light on how they work.
The alsuwaiyel textbook on Google Books is very good and has most of the book available.
I have a very, very large graph, and I want to find the shortest path from one vertex to another. The graph is directed and unweighted.
I have considered using some modification of Dijkstra's algorithm, but I usually use that for weighted undirected graphs.
So then my other thought was to use a DFS, since I can treat all the weights as one.
Any suggestions? a
EDIT: Ok, I meant to say BFS, I'm sorry.
Try a BFS instead.
(Note that Dijkstra's algorithm works perfectly fine for unweighted directed graphs — it just happens that in the unweighted case, doing it smartly is essentially equivalent to a breadth-first search.)
Have you tried using A*?