|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
45 class EdgeWeightedGraph;
114 for (
node v : terminals) {
115 completeTerminalGraph.
newNode(v);
121 calculateCompleteGraph(G, terminals, ssspPred, completeTerminalGraph);
129 reinsertShortestPaths(completeTerminalGraph, ssspPred, mstPred, *finalSteinerTree, G);
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);
The namespace for all OGDF objects.
Includes declaration of graph class.
T weight(const edge e) const
virtual ~MinSteinerTreeKou()
void setOriginalGraph(const Graph *wG) override
Associates the graph copy with G, but does not create any nodes or edges.
Declaration of extended graph algorithms.
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...
T computeMinST(const Graph &G, const EdgeArray< T > &weight, EdgeArray< bool > &isInTree)
Computes a minimum spanning tree using Prim's algorithm.
edge newEdge(node u, node v, T weight)
Extends the GraphCopy concept to weighted graphs.
Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirec...
Declaration of ogdf::MinSteinerTreeModule.
Dijkstra's single source shortest path algorithm.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prunes nonterminal leaves and their paths to terminal or branching nodes.
const List< edge > & chain(edge e) const
Returns the list of edges coresponding to edge e.
const EdgeArray< T > & edgeWeights() const
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...
node firstNode() const
Returns the first node in the list of all nodes.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
constexpr double pi
The constant .
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
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.
const EdgeArray< T > & edgeWeights() const
T makeMinimumSpanningTree(Graph &G, const EdgeArray< T > &weight)
Reduce a graph to its minimum spanning tree (MST) using Kruskal's algorithm.
node succ() const
Returns the successor in the list of all nodes.
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.
Class for the representation of edges.
Implementation of Dijkstra's single source shortest path algorithm.
Declaration of doubly linked lists and iterators.
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.
Class for the representation of nodes.
void calculateCompleteGraph(const EdgeWeightedGraph< T > &wG, const List< node > &terminals, EdgeArray< List< edge >> &predecessor, EdgeWeightedGraphCopy< T > &completeTerminalGraph)
Builds a complete terminal graph.
const Graph & original() const
Returns a reference to the original graph.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.