Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirected graphs with edge costs. More...
#include <ogdf/graphalg/MinSteinerTreeModule.h>
Public Member Functions | |
virtual | ~MinSteinerTreeModule () |
Do nothing on destruction. | |
virtual T | call (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) |
Calls the Steiner tree algorithm for nontrivial cases but handles trivial cases directly. | |
Static Public Member Functions | |
static void | getNonterminals (ArrayBuffer< node > &nonterminals, const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal) |
Generates a list (as ArrayBuffer<node>) of all nonterminals. | |
static void | getTerminals (List< node > &terminals, const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal) |
Generates a list (as List<node>) of all terminals. | |
static bool | isQuasiBipartite (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal) |
Checks in O(n + m) time if a given Steiner tree problem instance is quasi-bipartite. | |
static bool | isSteinerTree (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const EdgeWeightedGraphCopy< T > &steinerTree) |
Checks in O(n) time if a given tree is acually a Steiner Tree. | |
static void | sortTerminals (List< node > &terminals) |
Sort terminals by index. | |
Auxiliary post-processing functions | |
static T | pruneAllDanglingSteinerPaths (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal) |
Prunes nonterminal leaves and their paths to terminal or branching nodes. | |
static T | pruneDanglingSteinerPathFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, node start) |
Prunes the dangling Steiner path beginning at a given nonterminal leaf only. | |
static T | pruneDanglingSteinerPathsFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, const List< node > &start) |
Prunes dangling Steiner paths beginning at given nonterminal leaves only. | |
static T | removeCyclesFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal) |
Remove remaining cycles from a Steiner "almost" tree. | |
Special SSSP and APSP algorithms used in component-based approximation algorithms | |
static void | singleSourceShortestPathsPreferringTerminals (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &isTerminal, NodeArray< T > &distance, NodeArray< edge > &pred) |
Modified single-source-shortest-paths (Dijkstra) with heuristic to prefer paths over terminals. | |
static void | singleSourceShortestPathsStandard (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &, NodeArray< T > &distance, NodeArray< edge > &pred) |
Standard single-source-shortest-paths algoritm (Dijkstra) | |
static void | singleSourceShortestPaths (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &isTerminal, NodeArray< T > &distance, NodeArray< edge > &pred) |
The default single-source-shortest-paths algorithm. | |
static void | allTerminalShortestPathsStandard (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Runs singleSourceShortestPathsStandard from all terminals. | |
static void | allTerminalShortestPathsPreferringTerminals (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Runs singleSourceShortestPathsPreferringTerminals from all terminals. | |
static void | allTerminalShortestPaths (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred, std::function< void(const EdgeWeightedGraph< T > &, node, const NodeArray< bool > &, NodeArray< T > &, NodeArray< edge > &)> ssspFunc=singleSourceShortestPaths) |
Runs a given (or the default) single-source-shortest-paths function from all terminals. | |
static void | allNodeShortestPathsStandard (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Runs singleSourceShortestPathsStandard from all nodes. | |
static void | allNodeShortestPathsPreferringTerminals (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Runs singleSourceShortestPathsPreferringTerminals from all nodes. | |
static void | allNodeShortestPaths (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred, std::function< void(const EdgeWeightedGraph< T > &, node, const NodeArray< bool > &, NodeArray< T > &, NodeArray< edge > &)> ssspFunc=singleSourceShortestPaths) |
Runs a given (or the default) single-source-shortest-paths function from all nodes. | |
static void | allPairShortestPathsPreferringTerminals (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Modified all-pair-shortest-paths algorithm (Floyd-Warshall) with heuristic to prefer paths over terminals. | |
static void | allPairShortestPathsStandard (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Standard all-pair-shortest-paths algorithm (Floyd-Warshall) | |
static void | allPairShortestPaths (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
The default all-pair-shortest-paths algorithm. | |
Drawings for debugging | |
static void | drawSVG (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, const EdgeWeightedGraphCopy< T > &steinerTree, const char *filename) |
Writes an SVG file of a minimum Steiner tree in the original graph. | |
static void | drawSVG (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, const char *filename) |
Writes an SVG file of the instance graph. | |
static void | drawSteinerTreeSVG (const EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, const char *filename) |
Writes a SVG that shows only the given Steiner tree. | |
Protected Member Functions | |
virtual T | computeSteinerTree (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)=0 |
Computes the actual Steiner tree. | |
Static Private Member Functions | |
template<typename NODELIST > | |
static void | allNodesByListShortestPaths (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const NODELIST &nodes, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred, std::function< void(const EdgeWeightedGraph< T > &, node, const NodeArray< bool > &, NodeArray< T > &, NodeArray< edge > &)> ssspFunc) |
Runs a given (or the default) single-source-shortest-paths function from all nodes . | |
static void | apspInit (const EdgeWeightedGraph< T > &G, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred) |
Common initialization routine for APSP algorithms. | |
static void | apspInnerLoop (node v, const EdgeWeightedGraph< T > &G, NodeArray< NodeArray< T > > &distance, std::function< void(node, node, T)> func) |
The inner loop for APSP algorithm to avoid code duplication. | |
static void | ssspInit (const EdgeWeightedGraph< T > &G, node source, PrioritizedMapQueue< node, T > &queue, NodeArray< T > &distance, NodeArray< edge > &pred) |
Common initialization routine for SSSP algorithms. | |
Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirected graphs with edge costs.
Furthermore it supplies some auxiliary methods.
T | The type of the edge costs of the Steiner tree instance |
Definition at line 59 of file MinSteinerTreeModule.h.
|
inlinevirtual |
Do nothing on destruction.
Definition at line 62 of file MinSteinerTreeModule.h.
|
inlinestaticprivate |
Runs a given (or the default) single-source-shortest-paths function from all nodes
.
Definition at line 371 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs a given (or the default) single-source-shortest-paths function from all nodes.
Definition at line 201 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs singleSourceShortestPathsPreferringTerminals from all nodes.
Definition at line 193 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs singleSourceShortestPathsStandard from all nodes.
Definition at line 185 of file MinSteinerTreeModule.h.
|
inlinestatic |
The default all-pair-shortest-paths algorithm.
Definition at line 229 of file MinSteinerTreeModule.h.
|
static |
Modified all-pair-shortest-paths algorithm (Floyd-Warshall) with heuristic to prefer paths over terminals.
G | Input graph |
isTerminal | Incidence vector indicating terminal nodes |
distance | Distance matrix result |
pred | Resulting shortest path such that pred [s][t] contains last edge of an s-t-path |
Definition at line 589 of file MinSteinerTreeModule.h.
|
static |
Standard all-pair-shortest-paths algorithm (Floyd-Warshall)
Definition at line 634 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs a given (or the default) single-source-shortest-paths function from all terminals.
Definition at line 175 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs singleSourceShortestPathsPreferringTerminals from all terminals.
Definition at line 167 of file MinSteinerTreeModule.h.
|
inlinestatic |
Runs singleSourceShortestPathsStandard from all terminals.
Definition at line 159 of file MinSteinerTreeModule.h.
|
staticprivate |
Common initialization routine for APSP algorithms.
Definition at line 618 of file MinSteinerTreeModule.h.
|
inlinestaticprivate |
The inner loop for APSP algorithm to avoid code duplication.
Definition at line 355 of file MinSteinerTreeModule.h.
|
virtual |
Calls the Steiner tree algorithm for nontrivial cases but handles trivial cases directly.
G | The weighted input graph |
terminals | The list of terminal nodes |
isTerminal | A bool array of terminals |
finalSteinerTree | The final Steiner tree |
Reimplemented in ogdf::MinSteinerTreePrimalDual< T >, and ogdf::MinSteinerTreeZelikovsky< T >.
Definition at line 386 of file MinSteinerTreeModule.h.
|
protectedpure virtual |
Computes the actual Steiner tree.
Implemented in ogdf::MinSteinerTreeDualAscent< T >, ogdf::MinSteinerTreeDirectedCut< T >, ogdf::MinSteinerTreeGoemans139< T >, ogdf::MinSteinerTreeKou< T >, ogdf::MinSteinerTreeMehlhorn< T >, ogdf::MinSteinerTreePrimalDual< T >, ogdf::MinSteinerTreeRZLoss< T >, ogdf::MinSteinerTreeShore< T >, ogdf::MinSteinerTreeTakahashi< T >, and ogdf::MinSteinerTreeZelikovsky< T >.
|
static |
Writes a SVG that shows only the given Steiner tree.
steinerTree | The Steiner tree to be drawn |
isTerminal | Incidence vector indicating terminal nodes |
filename | The name of the output file |
Definition at line 653 of file MinSteinerTreeModule.h.
|
inlinestatic |
Writes an SVG file of the instance graph.
G | The weighted graph instance |
isTerminal | Incidence vector indicating terminal nodes |
filename | The name of the output file |
Definition at line 260 of file MinSteinerTreeModule.h.
|
static |
Writes an SVG file of a minimum Steiner tree in the original graph.
G | The original weighted graph |
isTerminal | Incidence vector indicating terminal nodes |
steinerTree | The Steiner tree of the given graph |
filename | The name of the output file |
Definition at line 693 of file MinSteinerTreeModule.h.
|
inlinestatic |
Generates a list (as ArrayBuffer<node>) of all nonterminals.
nonterminals | The returned list (nonterminals are appended) |
G | The weighted input graph |
isTerminal | A bool array of terminals |
Definition at line 328 of file MinSteinerTreeModule.h.
|
inlinestatic |
Generates a list (as List<node>) of all terminals.
terminals | The returned list (terminals are appended) |
G | The weighted input graph |
isTerminal | A bool array of terminals |
Definition at line 307 of file MinSteinerTreeModule.h.
|
static |
Checks in O(n + m) time if a given Steiner tree problem instance is quasi-bipartite.
G | The original graph |
isTerminal | A bool array of terminals |
Definition at line 447 of file MinSteinerTreeModule.h.
|
static |
Checks in O(n) time if a given tree is acually a Steiner Tree.
G | The original graph |
terminals | The list of terminal nodes |
isTerminal | A bool array of terminals |
steinerTree | The Steiner tree to be checked |
Definition at line 420 of file MinSteinerTreeModule.h.
|
static |
Prunes nonterminal leaves and their paths to terminal or branching nodes.
steinerTree | The given Steiner tree |
isTerminal | Incidence vector indicating terminal nodes |
Definition at line 488 of file MinSteinerTreeModule.h.
|
static |
Prunes the dangling Steiner path beginning at a given nonterminal leaf only.
steinerTree | The given Steiner tree |
isTerminal | Incidence vector indicating terminals |
start | A nonterminal leaf to start pruning at |
Definition at line 462 of file MinSteinerTreeModule.h.
|
static |
Prunes dangling Steiner paths beginning at given nonterminal leaves only.
Definition at line 478 of file MinSteinerTreeModule.h.
|
static |
Remove remaining cycles from a Steiner "almost" tree.
Definition at line 501 of file MinSteinerTreeModule.h.
|
inlinestatic |
The default single-source-shortest-paths algorithm.
Definition at line 149 of file MinSteinerTreeModule.h.
|
static |
Modified single-source-shortest-paths (Dijkstra) with heuristic to prefer paths over terminals.
A shortest path over a terminal will mark the nodes that come after that terminal as unreachable by setting the predecessor to nullptr
. Nevertheless, the distance will be set correctly.
G | Input graph |
source | Start terminal |
isTerminal | Incidence vector indicating terminal nodes |
distance | Distance matrix result |
pred | Resulting shortest path such that pred [s][t] contains last edge of an s-t-path |
Definition at line 543 of file MinSteinerTreeModule.h.
|
inlinestatic |
Standard single-source-shortest-paths algoritm (Dijkstra)
Definition at line 141 of file MinSteinerTreeModule.h.
|
inlinestatic |
Sort terminals by index.
Definition at line 317 of file MinSteinerTreeModule.h.
|
staticprivate |
Common initialization routine for SSSP algorithms.
Definition at line 530 of file MinSteinerTreeModule.h.