56class EdgeWeightedGraph;
58namespace steiner_tree {
86 node edgeNode =
nullptr;
88 edgeNode = outputTree.
newNode();
89 edge e = sortEdges[i].item();
90 treeEdge[edgeNode] = e;
94 if (externalNodes[u]) {
95 node* uRoot = root[externalNodes[u]];
97 while (root[*uRoot] != uRoot) {
98 *uRoot = *root[*uRoot];
102 outputTree.
newEdge(edgeNode, *uRoot);
103 root[edgeNode] = uRoot;
104 if (externalNodes[v]) {
105 node* vRoot = root[externalNodes[v]];
107 while (root[*vRoot] != vRoot) {
108 *vRoot = *root[*vRoot];
109 vRoot = root[*vRoot];
112 outputTree.
newEdge(edgeNode, *vRoot);
115 externalNodes[v] = edgeNode;
118 externalNodes[u] = edgeNode;
119 if (externalNodes[v]) {
120 node* vRoot = root[externalNodes[v]];
122 while (root[*vRoot] != vRoot) {
123 *vRoot = *root[*vRoot];
124 vRoot = root[*vRoot];
127 outputTree.
newEdge(edgeNode, *vRoot);
128 root[edgeNode] = vRoot;
130 root[edgeNode] =
new node;
132 externalNodes[v] = edgeNode;
135 *root[edgeNode] = edgeNode;
140 for (
node* p : garbage) {
161 if (save0 == save1) {
185 finalSteinerTree =
nullptr;
187#ifdef OGDF_COMMON_ALG_FIND_BEST_TAKAHASHI_ROOT
189 T bestMstWeight = std::numeric_limits<T>::max();
190 for (
node v : terminals) {
192 T tmpMstWeight = mstt.
call(G, terminals, isTerminal, isOriginalTerminal, tmpSteinerTree, v);
193 if (tmpMstWeight < bestMstWeight) {
194 bestMstWeight = tmpMstWeight;
195 delete finalSteinerTree;
196 finalSteinerTree = tmpSteinerTree;
198 delete tmpSteinerTree;
201 return bestMstWeight;
203 return mstt.
call(G, terminals, isTerminal, isOriginalTerminal, finalSteinerTree);
Declaration and implementation of Array class and Array algorithms.
Extends the GraphCopy concept to weighted graphs.
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Declaration of ogdf::MinSteinerTreeModule.
Implementation of the 2(1-1/l)-approximation algorithm for the minimum Steiner tree problem by Matsuy...
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
void quicksort()
Sorts array using Quicksort.
Class for the representation of edges.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
edge newEdge(node u, node v, T weight)
T weight(const edge e) const
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
void delEdge(edge e) override
Removes edge e and clears the list of edges corresponding to e's original edge.
Data type for general directed graphs (adjacency list representation).
int numberOfEdges() const
Returns the number of edges in the graph.
node newNode(int index=-1)
Creates a new node and returns it.
edge newEdge(node v, node w, int index=-1)
Creates a new edge (v,w) and returns it.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Doubly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
static void getTerminals(List< node > &terminals, const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal)
Generates a list (as List<node>) of all terminals.
This class implements the minimum Steiner tree 2-approximation algorithm by Takahashi and Matsuyama w...
virtual T call(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree, const node startNode)
An extended call method with specific start node.
Class for the representation of nodes.
Augments any data elements of type X with keys of type Priority. This class is also its own Comparer.
RegisteredArray for nodes, edges and adjEntries of a graph.
This class represents a triple used by various contraction-based minimum Steiner tree approximations.
Declarations for Comparer objects.
NodeElement * node
The type of nodes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
node buildHeaviestEdgeInComponentTree(const EdgeWeightedGraphCopy< T > &inputTree, NodeArray< node > &externalNodes, NodeArray< edge > &treeEdge, Graph &outputTree)
Given an edge-weighted tree, builds an auxiliary arborescence where each arc of the input tree is a n...
void contractTripleInSteinerTree(const Triple< T > &t, EdgeWeightedGraphCopy< T > &st, edge save0, edge save1, edge save2, edge &ne0, edge &ne1)
Updates the Steiner tree by deleting save edges, removing all direct connections between the terminal...
T obtainFinalSteinerTree(const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, const NodeArray< bool > &isOriginalTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)
The namespace for all OGDF objects.