In the Steiner tree problem we are given the set of nonterminals, the set of terminals and the metric m. Our goal is to find a minimum cost tree connecting all terminals (it can possibly contain some nonterminal nodes).
This is an implementation of the standard greedy approach. We consider a graph composed only out of the terminal nodes. The distances between terminal nodes are equal to the shortest path distance between these terminals in the original graph. We compute the minimum spanning tree T in this graph and lift the result tree to the original graph. We use a fast implementation of this approach proposed in , which does not build this graph explicitly, but only finds Voronoi regions around terminals.
If the input graph is not connected we return Steiner trees for all connected components. The value returned by the algorithm is a pair containing: the weight of the tree, and the lower bound on the weight of the optimal tree (equal to half of sum of distances in T).
example file is steiner_tree_greedy_example.cpp
Complexity of the algorithm is \(O(|E|*\log(|V|))\) where E is the number of edges and V is the number of vertices.
Memory complexity of the algorithm is \(O(|E|)\).
The algorithm is described in .