Mehlhorn's approximation algorithm is implemented in this class, which gives a 2-approximation for the Steiner-tree problem. The algorithm's time complexity is O(nlog(n)+e). #include <lemon/steiner.h>
Public Member Functions | |
SteinerTree (const UGraph &graph, const CostMap &cost) | |
Constructor. | |
void | init () |
void | addTerminal (const Node &node) |
Adds a new terminal node. | |
void | start () |
Executes the algorithm. | |
bool | tree (UEdge e) |
Checks if an edge is in the Steiner-tree or not. | |
bool | tree (Node n) |
Checks if the node is in the Steiner-tree or not. | |
bool | steiner (Node n) |
Checks if the node is a Steiner-node. | |
bool | terminal (Node n) |
Checks if the node is a terminal. | |
Value | treeValue () const |
The total cost of the tree. |
SteinerTree | ( | const UGraph & | graph, | |
const CostMap & | cost | |||
) | [inline] |
Constructor
void init | ( | ) | [inline] |
Initializes the internal data structures.
void addTerminal | ( | const Node & | node | ) | [inline] |
Adds a new terminal node to the Steiner-tree problem.
void start | ( | ) | [inline] |
Executes the algorithm.
bool tree | ( | UEdge | e | ) | [inline] |
Checks if an edge is in the Steiner-tree or not.
e | is the edge that will be checked |
true
if e is in the Steiner-tree, false
otherwise bool tree | ( | Node | n | ) | [inline] |
Checks if a node is in the Steiner-tree or not.
n | is the node that will be checked |
true
if n is in the Steiner-tree, false
otherwise bool steiner | ( | Node | n | ) | [inline] |
Checks if the node is a Steiner-node (i.e. a tree node but not terminal).
n | is the node that will be checked |
true
if n is a Steiner-node, false
otherwise bool terminal | ( | Node | n | ) | [inline] |
Checks if the node is a terminal.
n | is the node that will be checked |
true
if n is a terminal, false
otherwise Value treeValue | ( | ) | const [inline] |
The total cost of the constructed tree. The calculated value does not exceed the double of the optimal value.