|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
49 class EdgeWeightedGraph;
81 const node startNode) {
82 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, startNode);
95 return call(G, terminals, isTerminal, isOriginalTerminal, finalSteinerTree,
116 return call(G, terminals, isTerminal, isTerminal, finalSteinerTree, terminals.front());
141 terminalDijkstra(G, terminalSpanningTree, startNode, terminals.
size(), isTerminal);
144 for (
node u : G.nodes) {
145 if (!terminalSpanningTree.
copy(u)) {
146 finalSteinerTree->
delNode(finalSteinerTree->
copy(u));
162 NodeArray<T> distance(wG, std::numeric_limits<T>::max());
164 NodeArray<T> bestDistance(wG, std::numeric_limits<T>::max());
169 for (
node v : wG.nodes) {
170 queue.
push(v, distance[v]);
174 int terminalsFound = 1;
175 while (!queue.
empty() && terminalsFound < numberOfTerminals) {
178 isInQueue[v] =
false;
179 bestDistance[v] = distance[v];
180 if (isTerminal[v] && distance[v] > 0) {
183 node tmpT = intermediateTerminalSpanningTree.
newNode(v);
184 while (distance[v] > 0) {
186 queue.
push(v, distance[v]);
188 const edge e = predecessor[v];
191 node tmpS = intermediateTerminalSpanningTree.
copy(w);
193 tmpS = intermediateTerminalSpanningTree.
newNode(w);
197 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpS, tmpT, wG.
weight(e));
199 tmpE = intermediateTerminalSpanningTree.
newEdge(tmpT, tmpS, wG.
weight(e));
201 mstWeight += wG.
weight(e);
202 intermediateTerminalSpanningTree.
setEdge(e, tmpE);
210 if (distance[w] > distance[v] + wG.
weight(e) && bestDistance[w] >= distance[w]) {
211 distance[w] = distance[v] + wG.
weight(e);
213 queue.
push(w, distance[w]);
The namespace for all OGDF objects.
Includes declaration of graph class.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void pop()
Removes the topmost element from 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 weight(const edge e) const
Priority queue interface wrapping various heaps.
void push(const E &element, const P &priority)
Adds a new element to the queue.
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.
edge newEdge(node u, node v, T weight)
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.
bool isConnected(const Graph &G)
Returns true iff G is connected.
Class for adjacency list elements.
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.
edge theEdge() const
Returns the edge associated with this adjacency entry.
bool empty() const
Checks whether the queue is empty.
Decralation of GraphElement and GraphList classes.
Prioritized queue interface wrapper for heaps.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prunes nonterminal leaves and their paths to terminal or branching nodes.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
MinSteinerTreeTakahashi()
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.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
void delNode(node v) override
Removes node v.
const E & topElement() const
Returns the topmost element in the queue.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
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
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
This class implements the minimum Steiner tree 2-approximation algorithm by Takahashi and Matsuyama w...
Basic declarations, included by all source files.
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 opposite(node v) const
Returns the adjacent node different from v.
Class for the representation of edges.
virtual T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
Computes the actual Steiner tree.
Declaration of doubly linked lists and iterators.
int size() const
Returns the number of elements in the list.
node target() const
Returns the target node of the edge.
virtual ~MinSteinerTreeTakahashi()
Class for the representation of nodes.
Declaration of simple graph algorithms.