views:

1240

answers:

6

I have a digraph which is strongly connected (i.e. there is a path from i to j and j to i for each pair of nodes (i, j) in the graph G). I wish to find a strongly connected graph out of this graph such that the sum of all edges is the least.

To put it differently, I need to get rid of edges in such a way that after removing them, the graph will still be strongly connected and of least cost for the sum of edges.

I think it's an NP hard problem. I'm looking for an optimal solution, not approximation, for a small set of data like 20 nodes.

Edit

A more general description: Given a grap G(V,E) find a graph G'(V,E') such that if there exists a path from v1 to v2 in G than there also exists a path between v1 and v2 in G' and sum of each ei in E' is the least possible. so its similar to finding a minimum equivalent graph, only here we want to minimize the sum of edge weights rather than sum of edges.

Edit:

My approach so far: I thought of solving it using TSP with multiple visits, but it is not correct. My goal here is to cover each city but using a minimum cost path. So, it's more like the cover set problem, I guess, but I'm not exactly sure. I'm required to cover each and every city using paths whose total cost is minimum, so visiting already visited paths multiple times does not add to the cost.

A: 

Seems like what you basically want is an optimal solution for traveling-salesman where it is permitted for nodes to be visited more than once.

Edit:

Hmm. Could you solve this by essentially iterating over each node i and then doing a minimum spanning tree of all the edges pointing to that node i, unioned with another minimum spanning tree of all the edges pointing away from that node?

Amber
actually i solved that problem TSPm, but it would not work, in my case i should be allowed to revisit the node as well as the edges multiple times, i will edit the question for more description
Kazoom
A: 

Sounds like you want to use the Dijkstra algorithm

Maurice Perry
Dijkstra does not apply here... at least not in any obvious way.
Igor ostrovsky
Well, you can use Dijkstra to solve TSP, so it *is* a possible solution. It's just a matter of defining the search space of partial solutions, then searching it in least-cost-so-far order. Of course that doesn't mean it's a good solution in this case.
Steve314
+2  A: 

I would try this in a dynamic programming kind of way.

0- put the graph into a list

1- make a list of new subgraphs of each graph in the previous list, where you remove one different edge for each of the new subgraphs

2- remove duplicates from the new list

3- remove all graphs from the new list that are not strongly connected

4- compare the best graph from the new list with the current best, if better, set new current best

5- if the new list is empty, the current best is the solution, otherwise, recurse/loop/goto 1

In Lisp, it could perhaps look like this:

(defun best-subgraph (digraphs &optional (current-best (best digraphs)))
  (let* ((new-list (remove-if-not #'strongly-connected
                                  (remove-duplicates (list-subgraphs-1 digraphs)
                                                     :test #'digraph-equal)))
         (this-best (best (cons current-best new-list))))
    (if (null new-list)
        this-best
        (best-subgraph new-list this-best))))

The definitions of strongly-connected, list-subgraphs-1, digraph-equal, best, and better are left as an exercise for the reader.

Svante
+8  A: 

Your problem is known as minimum spanning strong sub(di)graph (MSSS) or, more generally, minimum cost spanning sub(di)graph and is NP-hard indeed. See also another book: page 501 and page 480.

I'd start with removing all edges that don't satisfy the triangle inequality - you can remove edge a -> c if going a -> b -> c is cheaper. This reminds me of TSP, but don't know if that leads anywhere.

My previous answer was to use the Chu-Liu/Edmonds algorithm which solves Arborescence problem; as Kazoom and ShreevatsaR pointed out, this doesn't help.

sdcvvc
MST for directed spanning tree does not really solve the problem. the directed tree mst finds shortest path only from the root to other node. in my case i need to find a graph which has paths from one node to every other node, may not be the least, but the overall sum of edges of a graph need to be minimum
Kazoom
"the directed tree mst finds shortest path only from the root to other node" - that's what Dijkstra does? According to other reference I linked, the overall sum is minimized, and the resulting graph is strongly connected. Could you clearly state what's wrong? (It's not a literal use of undirected MST algorithm to directed graph)
sdcvvc
@sdcvvc: The resulting graph given by the minimum-arborescence problem is an arborescence, hence not strongly connected. It has paths from the root to all other nodes, but not between all pairs of nodes. For example, it has no edge incoming into the root, or outgoing from the leaves.
ShreevatsaR
Oh, that's right. I misunderstood the definition; sorry.
sdcvvc
To get within a factor of 2 of optimal is easy - pick an arbitrary node and compute a minimum spanning out-tree and in-tree for that node.
Keith Randall
A: 

This problem is equivalent to the problem described here: http://www.facebook.com/careers/puzzles.php?puzzle_id=1

mlbright
A: 

hey...so did anyone find a solution to this problme.... i have been doing this for weeks but to no avail

Zhang feng