A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wagner algorithm. More...
#include <ogdf/graphalg/steiner_tree/FullComponentGeneratorDreyfusWagner.h>
Classes | |
| struct | DWMData |
| Subgraphs (given by other subgraphs and additional node pairs) and their cost for a partial solution. More... | |
| struct | DWMSplit |
| A collection of two subgraphs and their total cost. More... | |
| class | SortedNodeListHashFunc |
Public Member Functions | |
| FullComponentGeneratorDreyfusWagner (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const NodeArray< NodeArray< T > > &distance, const NodeArray< NodeArray< edge > > &pred) | |
| The constructor. | |
| void | call (int restricted) |
| T | getSteinerTreeFor (const List< node > &terminals, EdgeWeightedGraphCopy< T > &tree) const |
| Constructs a Steiner tree for the given set of terminals if it is valid, otherwise an empty tree is returned. | |
| bool | isValidComponent (const EdgeWeightedGraphCopy< T > &graph) const |
Checks if a given graph is a valid full component. | |
Private Types | |
| using | NodePairs = ArrayBuffer< NodePair > |
Private Member Functions | |
| void | computePartialSolution (NodeArray< DWMSplit > &split, node v, SubsetEnumerator< node > &subset, const List< node > &terminals) |
Computes a partial solution for given terminals and node v. | |
| template<typename CONTAINER > | |
| void | computePartialSolutions (const CONTAINER &nodeContainer) |
| Computes all partial solutions for given m_terminalSubset. | |
| void | computeSplit (NodeArray< DWMSplit > &split, node v, SubsetEnumerator< node > &subset) const |
Populates split that contains a partial solution for an included nonterminal v in m_G. | |
| T | costOf (const List< node > &key) const |
Returns the cost of the partial solution given by key. | |
| const DWMData * | dataOf (const List< node > &key) const |
Returns a pointer to the relevant data of the partial solution given by key. | |
| T | getSteinerTreeFor (const DWMData &data, EdgeWeightedGraphCopy< T > &tree) const |
Adds edges to construct a Steiner tree from the given data (recursively) if the data is valid. | |
| void | initializeMap () |
| Initializes the hash array with all node-terminal-pairs. | |
| void | makeKey (List< node > &newSubset, List< node > &newComplement, const SubsetEnumerator< node > &subset, node v) const |
Makes a list from subset and its complement, each including an correctly inserted node v. | |
| void | makeKey (List< node > &newSubset, node v) const |
Makes a list from the current terminal subset including an correctly inserted node v. | |
| bool | safeIfSumSmaller (const T summand1, const T summand2, const T compareValue) const |
Checks overflow-safe if summand1 plus summand2 is less than compareValue. | |
Static Private Member Functions | |
| static void | sortedInserter (node w, List< node > &list, bool &inserted, node newNode) |
Is being used as a callback to ogdf::SubsetEnumerator's forEach* methods to get the subset plus a correctly inserted newNode (ie, sorted by index) into list. | |
Private Attributes | |
| const NodeArray< NodeArray< T > > & | m_distance |
| A reference to the full distance matrix. | |
| const EdgeWeightedGraph< T > & | m_G |
| A reference to the graph instance. | |
| const NodeArray< bool > & | m_isTerminal |
| A reference to the terminal incidence vector. | |
| Hashing< List< node >, DWMData, SortedNodeListHashFunc > | m_map |
| A hash array for keys of size > 2. | |
| const NodeArray< NodeArray< edge > > & | m_pred |
| A reference to the full predecessor matrix. | |
| const List< node > & | m_terminals |
| A reference to the index-sorted list of terminals. | |
| SubsetEnumerator< node > | m_terminalSubset |
| Handling subsets of terminals. | |
A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wagner algorithm.
This generator can handle (and exploit) predecessor matrices that use nullptr instead of resembling shortest paths over terminals. (See the terminal-preferring shortest path algorithms in ogdf::MinSteinerTreeModule<T>.)
Definition at line 61 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
Definition at line 69 of file FullComponentGeneratorDreyfusWagner.h.
|
inline |
The constructor.
Definition at line 363 of file FullComponentGeneratorDreyfusWagner.h.
|
inline |
Definition at line 377 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Computes a partial solution for given terminals and node v.
Definition at line 240 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Computes all partial solutions for given m_terminalSubset.
Definition at line 283 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Populates split that contains a partial solution for an included nonterminal v in m_G.
Note that it is not guaranteed that any resulting collection of node pairs represents a tree.
Definition at line 222 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Returns the cost of the partial solution given by key.
Definition at line 145 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Returns a pointer to the relevant data of the partial solution given by key.
Definition at line 138 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Adds edges to construct a Steiner tree from the given data (recursively) if the data is valid.
Definition at line 325 of file FullComponentGeneratorDreyfusWagner.h.
|
inline |
Constructs a Steiner tree for the given set of terminals if it is valid, otherwise an empty tree is returned.
Definition at line 393 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Initializes the hash array with all node-terminal-pairs.
Definition at line 296 of file FullComponentGeneratorDreyfusWagner.h.
|
inline |
Checks if a given graph is a valid full component.
Definition at line 401 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Makes a list from subset and its complement, each including an correctly inserted node v.
Definition at line 201 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Makes a list from the current terminal subset including an correctly inserted node v.
Definition at line 192 of file FullComponentGeneratorDreyfusWagner.h.
|
inlineprivate |
Checks overflow-safe if summand1 plus summand2 is less than compareValue.
Definition at line 163 of file FullComponentGeneratorDreyfusWagner.h.
|
inlinestaticprivate |
Is being used as a callback to ogdf::SubsetEnumerator's forEach* methods to get the subset plus a correctly inserted newNode (ie, sorted by index) into list.
This takes linear time in comparison to copy, insert, sort which takes average case O(n log n) time.
| w | Node argument for the callback |
| list | Resulting list |
| inserted | Whether newNode was inserted; must be initialized to false |
| newNode | New node to be inserted into the list |
Definition at line 183 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A reference to the full distance matrix.
Definition at line 65 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A reference to the graph instance.
Definition at line 62 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A reference to the terminal incidence vector.
Definition at line 64 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A hash array for keys of size > 2.
Definition at line 135 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A reference to the full predecessor matrix.
Definition at line 66 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
A reference to the index-sorted list of terminals.
Definition at line 63 of file FullComponentGeneratorDreyfusWagner.h.
|
private |
Handling subsets of terminals.
Definition at line 67 of file FullComponentGeneratorDreyfusWagner.h.