42 namespace steiner_tree {
71 node edgeNode =
nullptr;
73 edgeNode = outputTree.
newNode();
74 edge e = sortEdges[i].item();
75 treeEdge[edgeNode] = e;
79 if (externalNodes[u]) {
80 node *uRoot = root[externalNodes[u]];
82 while (root[*uRoot] != uRoot) {
83 *uRoot = *root[*uRoot];
87 outputTree.
newEdge(edgeNode, *uRoot);
88 root[edgeNode] = uRoot;
89 if (externalNodes[v]) {
90 node *vRoot = root[externalNodes[v]];
92 while (root[*vRoot] != vRoot) {
93 *vRoot = *root[*vRoot];
97 outputTree.
newEdge(edgeNode, *vRoot);
100 externalNodes[v] = edgeNode;
103 externalNodes[u] = edgeNode;
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);
113 root[edgeNode] = vRoot;
115 root[edgeNode] =
new node;
117 externalNodes[v] = edgeNode;
120 *root[edgeNode] = edgeNode;
125 for(
node *p : garbage) {
144 template <
typename T>
147 if (save0 == save1) {
158 template <
typename T>
172 finalSteinerTree =
nullptr;
174 #ifdef OGDF_COMMON_ALG_FIND_BEST_TAKAHASHI_ROOT 176 T bestMstWeight = std::numeric_limits<T>::max();
177 for (
node v : terminals) {
179 T tmpMstWeight = mstt.
call(G, terminals, isTerminal, isOriginalTerminal, tmpSteinerTree, v);
180 if (tmpMstWeight < bestMstWeight) {
181 bestMstWeight = tmpMstWeight;
182 delete finalSteinerTree;
183 finalSteinerTree = tmpSteinerTree;
185 delete tmpSteinerTree;
188 return bestMstWeight;
190 return mstt.
call(G, terminals, isTerminal, isOriginalTerminal, finalSteinerTree);
node target() const
Returns the target node of the edge.
The parameterized class Array implements dynamic arrays of type E.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
iterator pushBack(const E &x)
Adds element x at the end of the list.
Data type for general directed graphs (adjacency list representation).
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...
edge newEdge(node u, node v, T weight)
Implementation of the 2(1-1/l)-approximation algorithm for the minimum Steiner tree problem by Matsuy...
Extends the GraphCopy concept to weighted graphs.
Augments any data elements of type X with keys of type Priority. This class is also its own Comparer...
virtual void delEdge(edge e) override
Removes edge e and clears the list of edges corresponding to e's original edge.
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
int numberOfEdges() const
Returns the number of edges in the graph.
Dynamic arrays indexed with nodes.
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.
Doubly linked lists (maintaining the length of the list).
edge newEdge(node v, node w)
Creates a new edge (v,w) and returns it.
Class for the representation of edges.
NodeElement * node
The type of nodes.
Class for the representation of nodes.
T obtainFinalSteinerTree(const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, const NodeArray< bool > &isOriginalTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)
This class implements the minimum Steiner tree 2-approximation algorithm by Takahashi and Matsuyama w...
void quicksort()
Sorts array using Quicksort.
node source() const
Returns the source node of the edge.
The namespace for all OGDF objects.
node newNode()
Creates a new node and returns it.
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...
This class represents a triple used by various contraction-based minimum Steiner tree approximations...
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
T weight(const edge e) const
static void getTerminals(List< node > &terminals, const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal)
Generates a list (as List<node>) of all terminals.