45class EdgeWeightedGraph;
114 for (
node v : terminals) {
115 completeTerminalGraph.
newNode(v);
121 calculateCompleteGraph(G, terminals, ssspPred, completeTerminalGraph);
129 reinsertShortestPaths(completeTerminalGraph, ssspPred, mstPred, *finalSteinerTree, G);
142 for (
node u = completeTerminalGraph.
firstNode(); u->succ(); u = u->succ()) {
148 predecessor[e].clear();
149 for (
node t = completeTerminalGraph.
original(v); pi[t]; t = pi[t]->opposite(t)) {
150 predecessor[e].pushBack(pi[t]);
160 for (
node u : completeTerminalGraph.
nodes) {
162 insertPath(ssspPred[mstPred[u]], finalSteinerTree, wG);
170 for (
edge e : ssspPred) {
171 if (e !=
nullptr && finalSteinerTree.
chain(e).
size() == 0) {
172 node edgeSource = e->source();
173 node edgeTarget = e->target();
175 node stSource = finalSteinerTree.
copy(edgeSource);
176 if (stSource ==
nullptr) {
177 stSource = finalSteinerTree.
newNode(edgeSource);
180 node stTarget = finalSteinerTree.
copy(edgeTarget);
181 if (stTarget ==
nullptr) {
182 stTarget = finalSteinerTree.
newNode(edgeTarget);
185 if (e->source() == finalSteinerTree.
original(stSource)) {
187 finalSteinerTree.
setEdge(e, newE);
Extends the GraphCopy concept to weighted graphs.
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Declaration of ogdf::MinSteinerTreeModule.
Dijkstra's single source shortest path algorithm.
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...
Class for the representation of edges.
edge newEdge(node u, node v, T weight)
void setOriginalGraph(const Graph *wG) override
Re-initializes the copy using G (which might be null), but does not create any nodes or edges.
const EdgeArray< T > & edgeWeights() const
T weight(const edge e) const
const EdgeArray< T > & edgeWeights() const
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
const Graph & original() const
Returns a reference to the original graph.
const List< edge > & chain(edge e) const
Returns the list of edges coresponding to edge e.
edge copy(edge e) const override
Returns the first edge in the list of edges corresponding to edge e.
void setEdge(edge eOrig, edge eCopy)
sets eOrig to be the corresponding original edge of eCopy and vice versa
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
node firstNode() const
Returns the first node in the list of all nodes.
Doubly linked lists (maintaining the length of the list).
int size() const
Returns the number of elements in the list.
This class implements the Minimum Steiner Tree 2-approximation algorithm by Kou et al.
virtual ~MinSteinerTreeKou()
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.
Class for the representation of nodes.
node succ() const
Returns the successor in the list of all nodes.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
Declaration of extended graph algorithms.
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.
The namespace for all OGDF objects.