Well,

The other day I came across this problem and ramprasad gave a brilliant solution to it.

**Problem : ** Given a connected weighted graph G, find a minimum spanning tree. But wait, before you jump to any conclusion. The weights of the edges are not real numbers, but a quadratic function of time. So given a time interval [t1,t2] find out the minimum spanning tree T. That is T attains the minimum at time tm. . Now, find out the minimum spanning tree and the time instant tm at which it attains that minimum value.

**Solution : ** Well, the first solution that popped up in my mind was a brute force approach. Consider all spanning trees. As the weights of edges are quadratic functions, the weights of spanning trees would also be quadratic functions. Now differentiate these functions to find the minima. Now find out the absolute minimum of all these. But apparently, the number of spanning tree of a graph could be as high as thanks to Kirchoff. So obviously, it does not fit into our perception of “efficient algorithm”.

Ramprasad gave a nice solution which is definitely polynomial time. Not sure whether there are better solutions or not. Note that, prim’s algorithm or kruskal’s algorithm takes into account the order of weights of edge and does not really care about what these actual weights are. So as long as the order of the weights remains unchanged, you can apply one of these algorithm. Given the time interval [t1,t2] it can give rise to infinitely many instances of the weighted graph. As the weight function of edges are quadratic ( parabola ) there are at most many intersection points. That is, parabola corresponding to two edges intersect at atmost 2 points. And these intersection points are the points in time where weight of one edge goes beyond the weight of another edge.

So, sort these intersection points by time co-ordinate. Note, that between two consecutive intersection points, the order of the weights remain unchanged and hence one of the standard algorithm can be applied. So we need to run Prim’s or Kruskal’s algorithm (for each such interval giving rise to algorithm overall. Clearly, a major improvement over the brute force method.

Ramprasad and I are not sure whether this can be improved or not. Please leave a comment if you have some improvements in mind.

### Like this:

Like Loading...

*Related*

Tags: algorithm, graph theory, math, minimum spanning tree, prim's algorithm

This entry was posted on December 7, 2010 at 8:31 am and is filed under algorithm, math. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

## Leave a Reply