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.
Related
I want to know about the algorithms for finding block in graph. Which one works good for directed graph and which one for undirected? Also the performance, complexity of those algorithm.
I am searching the Cheriton-Tarjan algorithm for weighted minimum spanning trees, with O(m*loglogn). But I was not able to find it anywhere. Can someone explain me the algorithm or tell me a link as where to find it?
It's "Tarjan" not "Trajan". That may be a reason why you've had trouble finding it.
Here's pseudocode for the algorithm, taken from here (Graphcs, Algorithms, and Optimization by William Kocay and Donald Kreher):
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
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*?
What I'm looking for is a comprehensive list of graph traversal algorithms, with brief descriptions of their purpose, as a jump off point for researching them. So far I'm aware of:
Dijkstra's - single-source shortest path
Kruskal's - finds a minimum spanning tree
What are some other well-known ones? Please provide a brief description of each algorithm to each of your answers.
the well knowns are :
Depth-first search http://en.wikipedia.org/wiki/Depth-first_search
Breadth-first search http://en.wikipedia.org/wiki/Breadth-first_search
Prim's algorithm http://en.wikipedia.org/wiki/Prim's_algorithm
Kruskal's algorithm http://en.wikipedia.org/wiki/Kruskal's_algorithm
Bellman–Ford algorithm http://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm
Floyd–Warshall algorithm http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm
Reverse-delete algorithm http://en.wikipedia.org/wiki/Reverse-Delete_algorithm
Dijkstra's_algorithm http://en.wikipedia.org/wiki/Dijkstra's_algorithm
network flow
Ford–Fulkerson algorithm http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm
Maximum Flow http://en.wikipedia.org/wiki/Maximum_flow_problem
A few off of the top of my head:
Depth-first and Breadth-first traversals, really just two different ways of touching all of the nodes.
Floyd-Warshall algorithm finds the shortest paths between any pair of points, in (big-theta)(v^3) time.
Prim's algorithm is an alternative to Kruskal's for MST.
There are also algorithms for finding fully connected components, which are groups of nodes where you can get from any member in the component to any other member. This only matters for "directed graphs", where you can traverse an edge only one direction.
Personally, I think the coolest extension of graph theory (not exactly related to your question, but if you're interested in learning more about graphs in general its certainly worth your while) is the concepts of "flow networks": http://en.wikipedia.org/wiki/Flow_network . It is a way of computing about, say, how much electricity can one distribute over houses with a variety of power needs and requirements, and a variety of power stations.
Graph algorithms
http://en.wikipedia.org/wiki/List_of_algorithms#Graph_algorithms
All algorithms in one place
http://en.wikipedia.org/wiki/List_of_algorithms
Dictionary of algorithms and data structures:
Dictionary: http://xlinux.nist.gov/dads/
By area: http://xlinux.nist.gov/dads/termsArea.html
By terms type: http://xlinux.nist.gov/dads/termsType.html
List of all implementations in diff. languages: http://xlinux.nist.gov/dads/termsImpl.html