Given a connected undirected graph (in particular as a directed one but with arcs in both ways), my problem is to find a subgraph such that:
- is a directed acyclic graph
- is possibly maximal in the number of arcs
- has an arbitrarly selected root node with only outgoing arc
- is connected and connects all nodes
Is there any algorithm to solve this? I've searched for the Minimum Spanning Tree but is not what I'm looking for since it doesn't necessarily have to be a tree neither to minimize path costs of a weighted graph
One way to make the graph acyclic is to first pick an arbitrary ordering of the vertices (imagine them being lined up left to right). For each pair of vertices $v,w$ that had an edge between them in the original graph, you're really thinking of that as a pair of directed edges: $v \to w$ and $w \to v$. Of these two edges, keep only the one that goes left to right.
This will be acyclic, because any directed path keeps going left, and therefore can't return to where you started. It's also the directed acyclic subgraph with the most arcs: you can't keep both arcs $v \to w$ and $w \to v$, because that would be a cycle of length $2$, so you can keep at most one of the arcs - and this algorithm keeps exactly one. Whichever node you put first will be the root.
Regarding connectivity, there are three options:
For option 3, note that if you have two nodes that are consecutive in the ordering, we can't hope for a path from the right node to the left node, and the only way we can hope for a left-to-right path is if there's an arc between the nodes. So we can only get an ordering of this type if the original undirected graph has a Hamiltonian path: a path that visits every vertex exactly once. (Then, we just take that path as our ordering.)
Unfortunately, finding a Hamiltonian path (or checking that there is one) is a well-known hard computational problem. But it's one you have to solve if you want the connectivity.