开发者

How do I find a weighted bipartite graph's minimum edge cover using Mathematica 8?

In graph theory, we use the Hungarian Algorithm to compute a weighted bipartite graph's minimum edge cover (a set of edges that is incident to every vertices, the one with the minimum total weight.)

I find that in new version 8 of Mathematica, there is a whole new package of functions for Graph Theory, (begin with Graph[].) But I've not f开发者_C百科ound any function that do this job. I do find a function called FindEdgeCover[] that can only find a edge cover, not the minimum one.


I did a few experiments and, although not documented, it seems that FindEdgeCover[] does what you want.

Consider for example:

 h[list_] := CompleteGraph[4, EdgeWeight -> list]

 FindEdgeCover[h@Range@6]
 (*
 ->  {1->2,1->3,1->4}
 *)

But

 FindEdgeCover[h@Reverse@Range@6]
 (*
 -> {1->2,3->4}
 *)

of course no warranty ...

Edit

Here you have some code to experiment with by using different weighted adjacency matrices

adj = {{\[Infinity], 1, 1, 1, 1}, {1, \[Infinity], 2, 2, 2}, 
       {1, 2, \[Infinity], 2, 2}, {1, 2, 2, \[Infinity], 2}, 
       {1, 2, 2, 2, \[Infinity]}}
g = WeightedAdjacencyGraph[adj];
g = WeightedAdjacencyGraph[adj, VertexShapeFunction -> "Name", 
  EdgeLabels -> 
   MapThread[
    Rule, {EdgeList@g, AbsoluteOptions[g, EdgeWeight] /. {_ -> x_} -> x}], 
  GraphHighlight -> FindEdgeCover[g]]

How do I find a weighted bipartite graph's minimum edge cover using Mathematica 8?

NB: The code is not good at all, but I couldn't find a way to use EdgeLabels -> “EdgeWeight”. I posted this question to see if someone can do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜