there are prim and Kruskal algorithms to find mst in polynomial time
I wonder, Are there any algorithms to find MST in a directed acyclic graph in linear time?
The equivalent of an MST in a directed graph is called an optimum branching or minimum-cost arborescence and there are several good algorithms for finding one. The most famous is probably the Chu-Edmonds-Liu algorithm, which can be implemented in time O(mn) in a straightforward way and time O(m + n log n) using more clever data structures.
Hope this helps!
Related
Lets say there is a graph (V,E) that is directed and weighted.
The weights of every edge in the graph are 1 or 2 or 3.
What would be a quick and efficient algo to find the shortest path? Thanks in advance!!
Dijkstra's algorithm would likely still have near-optimal performance, and has the advantage of being fairly simple.
However, for a graph with small integer weights, you can use more complicated versions of the (fibonacci) heap used in Dijkstra that have better asymptotic performance. Specifically, consider this work by Mikkel Thorup which solves single-source shortest path in O(|E| + |V| log log |C|) where E is the set of edges, V is the set of vertices and C is the largest weight. In your case C is constant, which turns the asymptotic complexity into O(|E| + |V|).
Do note that this is mostly of theoretical interest, and is unlikely to give any significant speedup over a simpler algorithm.
There a list of algorithms for the Shortest path problem:
Dijkstra's algorithm
A* search algorithm
...etc
you can find a list in this Wikipedia page about Shortest path problem Algorithms
you can test and play with this online Dijkstra Shortest Path visualization.
a very interesting Pathfinding-Visualizer to see how some algorithms explore the research space to reach the goal is in github Pathfinding-Visualizer , this will give you a general idea on th differences between algorithms visually. Note: Pathfinding doesn't mean the shortest path; it's depend on the used algorithm.
I have a complete weighted graph G(V, E). I want to partition V into two clusters such that maximum intra-cluster edge length gets minimized. What is the fastest algorithm that solves this problem? I believe this can be solved in O(n^2) time where |V|=n. One approach would be making the graph bipartite. I could not figure out the complete algorithm. Can anyone help me to figure out the complete algorithm?
Two-color (depth-first search, O(n) time) a maximum spanning forest (Prim's algorithm, O(n2) time). Proof of correctness left as an exercise.
For the record, for sparser graphs with only m edges, I'm pretty sure there's an O(m)-time algorithm.
My Algorithms class is talking about Prim's Algorithm as a method of finding Minimum Spanning Trees of weighted graphs. Our professor asked us to try to think of an example of a graph that Prim's Algorithm takes N^2 time to solve (N = number of Vertices). No one in the class could think of one off the top of their head, so I'm asking you. I'm pretty sure Prim's Algorithm = O(N^2), so this would be the worst-case scenario for the algorithm.
What's a good example of a graph that takes N^2 time for Prim's Algorithm to solve?
If I understand your question correctly, the example is trivial.
If the graph is complete, there're O(N^2) edges, so just reading the graph is O(N^2).
I am learning the topic of Minimum-Spanning-Tree right now, and I understand the most of it, but I still have some things that I do not understand.
I am dealing with undirected weighted graphs.
First, I know that finding MST costs O(E*log V). Now, I want to optimize it to linear time - O(V+E), when we dealing with planar graphs.
Secondly, I saw an example of n points in the unit-square and I succeed to show that a MST that weights O(sqrt n) is exist. The problem is that I could not find an algorithm to find this MST.
Thanks all,
Or
Boruvka's algorithms runs in O(V) time on planar graphs. For details see
http://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/04GreedyAlgorithmsII.pdf
Also, you can compute the Euclidean MST of n points in the plane in O(n log n) time by computing MST of edges in Delauney triangulation.
I want to detect cycles in an undirected graph such that I can find the minimum spanning tree (in particular I want to use Kruskal algorithm). Since I want to parallelize the code, I was wondering which algorithm is the best, Depth-first search of union-find algorithm?
Thanks for any suggestions.
Of all three MST algorithms only Boruvka's MST algorithm is easily parallelizable whereas the kruskal and prims are sequential greedy algorithms hence there is minimum scope for parallel implementation of them.
Note: It is a research topic to achieve efficient parallel boruvka might find some papers