Is there an algorithm to find maximum weight spanning DAG that is weakly connected in a directed graph where every cut has sets that are weakly connected (There is at least one directed path from one set to another)? Or it is a NP hard problem? The previous question on this topic did not specify https://mathoverflow.net/questions/31864/algorithms-for-maximum-weighted-spanning-connected-dag-directed-acyclic-graph weak or strong connectivity, so I wanted to be more precise.
2 Answers
Hope thisn't too late. It is easy to fail both Kruskal and Prim for the case mentioned. Consider a 2 node graph: A --> B (weight 10), B --> A (weight 6), B --> A (weight 6) (yes: two edges from B to A; nothing in the graph defn precludes that !). Kruskal would first pick the A --> B edge and gets stuck. Prim would pick one of the edges from B to A and then gets stuck. The max. weighted acyclic subgraph is one that contains both the edges from B to A. It is a subgraph and it is acyclic !
Best Ravi

- 51
- 1
- 2
-
Does weakly connected graph has connections from one vertex to other in both directions? – andigor Apr 02 '15 at 19:40
-
By "gets stuck", do you mean run in an infinite loop, or not able to progress because no edges meet the choosing criterion? These sort of vague statements in response to technical questions annoy the heck outta me. – Abhijit Sarkar Dec 21 '18 at 04:45
Your weak connectivity condition just seems to be that the underlying undirected graph is connected. This is easy enough; you can use Kruskal or Prim or whatever your favourite minimum spanning tree algorithm is.
Minimum-weight strongly connected subgraph is NP-complete; observe that any such subgraph has at least |V| edges and that it has exactly |V| edges if and only if it is a Hamiltonian cycle.
You may want to pick a vertex to be the "root" and ask for there to be a path from every vertex to the root in your subgraph. This is the "minimum sppaning arbourescence" problem. As @matejpavouk pointed out, there is a quadratic algorithm for this due to Chu, Liu, and Edmonds.

- 13,915
- 3
- 28
- 57
-
I can find an example with four vertices where Krusal or Prim fails to find the maximum weighted subgraph without directed cycles. "Your weak connectivity condition just seems to be that the underlying undirected graph is connected." IT just means that there is at least one directed edge between two sets of any cut. There is a difference between directed and undirected graph algorithms on this point, so Kruskal and Prim fail. – vkaul11 Dec 27 '12 at 22:59
-
"There is at least one directed edge between two sets of any cut" means that, if I choose a set S of vertices that is neither empty nor all of the vertices, then there is an edge between S and V - S, right? That's exactly "connectivity of the underlying graph" and Kruskal/Prim work there. If you want an edge from S to V - S and an edge from V - S to S, that's strong connectivity and your problem is NP-complete. If you mean something else, please make that explicit (and preferably give an example of why what you want isn't the same as connectivity of the underlying graph.) – tmyklebu Dec 27 '12 at 23:55