Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
MinSteinerTreeKou.h
Go to the documentation of this file.
1
34#pragma once
35
36#include <ogdf/basic/List.h>
40
41namespace ogdf {
42
53template<typename T>
103
104template<typename T>
132
133template<typename T>
135 const List<node>& terminals, EdgeArray<List<edge>>& predecessor,
137 Dijkstra<T> sssp;
138 for (node u = completeTerminalGraph.firstNode(); u->succ(); u = u->succ()) {
141 sssp.call(wG, wG.edgeWeights(), completeTerminalGraph.original(u), pi, d);
142 for (node v = u->succ(); v; v = v->succ()) {
143 edge e = completeTerminalGraph.newEdge(u, v, d[completeTerminalGraph.original(v)]);
144 predecessor[e].clear();
145 for (node t = completeTerminalGraph.original(v); pi[t]; t = pi[t]->opposite(t)) {
146 predecessor[e].pushBack(pi[t]);
147 }
148 }
149 }
150}
151
152template<typename T>
162
163template<typename T>
166 for (edge e : ssspPred) {
167 if (e != nullptr && finalSteinerTree.chain(e).size() == 0) {
168 node edgeSource = e->source();
169 node edgeTarget = e->target();
170
172 if (stSource == nullptr) {
174 }
175
177 if (stTarget == nullptr) {
179 }
180
181 if (e->source() == finalSteinerTree.original(stSource)) {
182 edge newE = finalSteinerTree.newEdge(stSource, stTarget, wG.weight(e));
183 finalSteinerTree.setEdge(e, newE);
184 }
185 }
186 }
187}
188
189}
Extends the GraphCopy concept to weighted graphs.
Declaration of doubly linked lists and iterators.
Declaration of ogdf::MinSteinerTreeModule.
Dijkstra's single source shortest path algorithm.
Definition Dijkstra.h:53
void call(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false, node target=nullptr, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
Definition Dijkstra.h:246
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
This class implements the Minimum Steiner Tree 2-approximation algorithm by Kou et al.
void calculateCompleteGraph(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, EdgeArray< List< edge > > &predecessor, EdgeWeightedGraphCopy< T > &completeTerminalGraph)
Builds a complete terminal graph.
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.
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...
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.
Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirec...
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prunes nonterminal leaves and their paths to terminal or branching nodes.
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
node succ() const
Returns the successor in the list of all nodes.
Definition Graph_d.h:229
Implementation of Dijkstra's single source shortest path algorithm.
T makeMinimumSpanningTree(Graph &G, const EdgeArray< T > &weight)
Reduce a graph to its minimum spanning tree (MST) using Kruskal's algorithm.
T computeMinST(const Graph &G, const EdgeArray< T > &weight, EdgeArray< bool > &isInTree)
Computes a minimum spanning tree using Prim's algorithm.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.