76 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, startNode);
92 return call(G, terminals, isTerminal, isOriginalTerminal, finalSteinerTree, terminals.
front());
110 const node startNode);
119 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, terminals.
front());
134 int numberOfTerminals,
144 const node startNode)
154 if (!terminalSpanningTree.
copy(u)) {
155 finalSteinerTree->
delNode(finalSteinerTree->copy(u));
171 NodeArray<T> distance(wG, std::numeric_limits<T>::max());
173 NodeArray<T> bestDistance(wG, std::numeric_limits<T>::max());
179 queue.
push(v, distance[v]);
183 int terminalsFound = 1;
184 while (!queue.
empty() && terminalsFound < numberOfTerminals) {
187 isInQueue[v] =
false;
188 bestDistance[v] = distance[v];
190 && distance[v] > 0) {
193 node tmpT = intermediateTerminalSpanningTree.
newNode(v);
194 while (distance[v] > 0) {
196 queue.
push(v, distance[v]);
198 const edge e = predecessor[v];
201 node tmpS = intermediateTerminalSpanningTree.
copy(w);
203 tmpS = intermediateTerminalSpanningTree.
newNode(w);
207 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpS, tmpT, wG.
weight(e));
209 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpT, tmpS, wG.
weight(e));
211 mstWeight += wG.
weight(e);
212 intermediateTerminalSpanningTree.
setEdge(e, tmpE);
220 if (distance[w] > distance[v] + wG.
weight(e)
221 && bestDistance[w] >= distance[w]) {
222 distance[w] = distance[v] + wG.
weight(e);
224 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
Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirec...
edge newEdge(node u, node v, T weight)
Declaration of ogdf::MinSteinerTreeModule.
virtual T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
Computes the actual Steiner tree.
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)
Prunes nonterminal leaves 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.
bool isConnected(const Graph &G)
Returns true iff G is connected.
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)
An extended call method with intermediate and final (original) terminals.
Declaration of doubly linked lists and iterators.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.