Reputation: 7377
Does the Boruvka algorithm (http://en.wikipedia.org/wiki/Bor%C5%AFvka's_algorithm) only work for undirected graphs?
For example, if we have a graph structure that looks like:
node 1 -> node 2 (weight 1), node 3 (weight 1), node 4 (weight 1)
node 2 -> node 3 (weight 2)
node 3 -> node 4 (weight 2)
node 4 -> node 2 (weight 2)
Then the minimum spanning tree should include the edges:
1 -> 2
1 -> 3
1 -> 4
However, Boruvka's algorithm will spit out
1 -> 2
2 -> 3
3 -> 4
Because, Boruvka first looks at each individual node and adds the shortest edge outgoing from that node to the MST.
I know in the wikipedia article it says that edge weights have to be distinct but as long as all of the edge weights coming out of node 1 are less than the "outer" edge weights (from nodes 2-4) then it seems like Boruvka's algorithm fails. Is this because it is a directed graph not undirected?
Upvotes: 2
Views: 2216
Reputation: 1507
Minimum spanning tree is defined only on undirected graphs so taking this into account your question doesn't make sense. Probably you are looking for something else, e.g. strongly connected induced subgraph of original graph with the same set of vertices and minimal sum of edge weights. In this case you don't have to get tree, actually tree is also defined as an undirected graph. IMHO algorithm solving this would be computationally harder problem.
Upvotes: 1
Reputation: 6379
The question you should ask yourself is what does "minimum spanning tree" mean for a directed graph ? The algorithm you should use depends on the answer to this question.
Upvotes: 1
Reputation: 183888
Is this because it is a directed graph not undirected?
Yes. For a directed graph, you would have to consider incoming as well as outgoing edges, then the algorithm would work in the same manner. The easiest way to do this is to consider the underlying undirected graph.
Upvotes: 2