80 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, startNode);
89 return call(G, terminals, isTerminal, isOriginalTerminal, finalSteinerTree, terminals.
front());
111 const node startNode);
128 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, terminals.
front());
143 int numberOfTerminals,
153 const node startNode)
161 if (!terminalSpanningTree.
copy(u)) {
162 finalSteinerTree->
delNode(finalSteinerTree->copy(u));
180 NodeArray<T> bestDistance(wG, numeric_limits<T>::max());
186 queue.
push(v, distance[v]);
190 int terminalsFound = 1;
191 while (!queue.
empty() && terminalsFound < numberOfTerminals) {
194 isInQueue[v] =
false;
195 bestDistance[v] = distance[v];
197 && distance[v] > 0) {
200 node tmpT = intermediateTerminalSpanningTree.
newNode(v);
201 while (distance[v] > 0) {
203 queue.
push(v, distance[v]);
205 const edge e = predecessor[v];
208 node tmpS = intermediateTerminalSpanningTree.
copy(w);
210 tmpS = intermediateTerminalSpanningTree.
newNode(w);
214 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpS, tmpT, wG.
weight(e));
216 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpT, tmpS, wG.
weight(e));
218 mstWeight += wG.
weight(e);
219 intermediateTerminalSpanningTree.
setEdge(e, tmpE);
227 if (distance[w] > distance[v] + wG.
weight(e)
228 && bestDistance[w] >= distance[w]) {
229 distance[w] = distance[v] + wG.
weight(e);
231 queue.
push(w, distance[w]);
node target() const
Returns the target node of the edge.
void pop()
Removes the topmost element from the queue.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
void push(const E &element, const P &priority)
Adds a new element to the queue.
void setEdge(edge eOrig, edge eCopy)
sets eOrig to be the corresponding original edge of eCopy and vice versa
This class serves as an interface for various methods to compute minimum or approximations of minimum...
edge newEdge(node u, node v, T weight)
Interface of Minimum Steiner Tree Algorithms.
virtual T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
Builds a minimum Steiner tree given a weighted graph and a list of terminals.
Extends the GraphCopy concept to weighted graphs.
T makeMinimumSpanningTree(Graph &G, const EdgeArray< T > &weight)
Reduce a graph to its minimum spanning tree (MST) using Kruskal's algorithm.
Prioritized queue interface wrapper for heaps.
virtual ~MinSteinerTreeTakahashi()
T weight(const edge e) const
void createEmpty(const Graph &wG)
const E & topElement() const
Returns the topmost element in the queue.
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.
T terminalDijkstra(const EdgeWeightedGraph< T > &wG, EdgeWeightedGraphCopy< T > &intermediateTerminalSpanningTree, const node s, int numberOfTerminals, const NodeArray< bool > &isTerminal)
Modified Dijkstra algorithm to solve the Minimum Steiner Tree problem.
const_reference front() const
Returns a const reference to the first element.
Doubly linked lists (maintaining the length of the list).
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
Class for the representation of edges.
MinSteinerTreeTakahashi()
Class for the representation of nodes.
node opposite(node v) const
Returns the adjacent node different from v.
This class implements the minimum Steiner tree 2-approximation algorithm by Takahashi and Matsuyama w...
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prune Steiner nodes with degree 1 and their paths to terminal or branching nodes. ...
bool empty() const
Checks whether the queue is empty.
int size() const
Returns the number of elements in the list.
The namespace for all OGDF objects.
Declaration of extended graph algorithms.
virtual void delNode(node v) override
Removes node v and all its adjacent edges cleaning-up their corresponding lists of original edges...
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Class for adjacency list elements.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
virtual T call(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const NodeArray< bool > &isOriginalTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)
Declaration of doubly linked lists and iterators.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.