112 for (
node v : terminals) {
113 completeTerminalGraph.
newNode(v);
139 for (
node u = completeTerminalGraph.
firstNode(); u->succ(); u = u->succ()) {
145 predecessor[e].clear();
146 for (
node t = completeTerminalGraph.
original(v); pi[t]; t = pi[t]->opposite(t)) {
147 predecessor[e].pushBack(pi[t]);
160 for(
node u : completeTerminalGraph.
nodes) {
162 insertPath(ssspPred[mstPred[u]], finalSteinerTree, wG);
170 for (
edge e : ssspPred)
172 if (e !=
nullptr && finalSteinerTree.
chain(e).
size() == 0)
174 node edgeSource = e->source();
175 node edgeTarget = e->target();
177 node stSource = finalSteinerTree.
copy(edgeSource);
178 if (stSource ==
nullptr) {
179 stSource = finalSteinerTree.
newNode(edgeSource);
182 node stTarget = finalSteinerTree.
copy(edgeTarget);
183 if (stTarget ==
nullptr) {
184 stTarget = finalSteinerTree.
newNode(edgeTarget);
187 if (e->source() == finalSteinerTree.
original(stSource)) {
189 finalSteinerTree.
setEdge(e, newE);
void reinsertShortestPaths(const EdgeWeightedGraphCopy< T > &completeTerminalGraph, const EdgeArray< List< edge > > &ssspPred, const NodeArray< edge > &mstPred, EdgeWeightedGraphCopy< T > &finalSteinerTree, const EdgeWeightedGraph< T > &wG)
Swaps an edge in the complete terminal graph with the corresponding shortest path in the original gra...
node copy(node v) const
Returns the node in the graph copy corresponding to v.
Dijkstra's single source shortest path algorithm.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
T computeMinST(const Graph &G, const EdgeArray< T > &weight, EdgeArray< bool > &isInTree)
Computes a minimum spanning tree using Prim's algorithm.
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...
void calculateCompleteGraph(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, EdgeArray< List< edge > > &predecessor, EdgeWeightedGraphCopy< T > &completeTerminalGraph)
Builds a complete terminal graph.
void call(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false)
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
edge newEdge(node u, node v, T weight)
Interface of Minimum Steiner Tree Algorithms.
const EdgeArray< T > & edgeWeights() const
node firstNode() const
Returns the first node in the list of all nodes.
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.
Dynamic arrays indexed with edges.
node succ() const
Returns the successor in the list of all nodes.
T weight(const edge e) const
void createEmpty(const Graph &wG)
Implementation of Dijkstra's single source shortest path algorithm.
const EdgeArray< T > & edgeWeights() const
Doubly linked lists (maintaining the length of the list).
const List< edge > & chain(edge e) const
Returns the list of edges coresponding to edge e.
This class implements the Minimum Steiner Tree 2-approximation algorithm by Kou et al...
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.
Class for the representation of edges.
Class for the representation of nodes.
const Graph & original() const
Returns a reference to the original graph.
void insertPath(const List< edge > &ssspPred, EdgeWeightedGraphCopy< T > &finalSteinerTree, const EdgeWeightedGraph< T > &wG)
Inserts a shortest path corresponding to an edge in the complete terminal graph.
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prune Steiner nodes with degree 1 and their paths to terminal or branching nodes. ...
int size() const
Returns the number of elements in the list.
virtual ~MinSteinerTreeKou()
The namespace for all OGDF objects.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Declaration of doubly linked lists and iterators.