A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wagner algorithm that does not need a precomputed all-pair-shortest-paths matrix because single-source-shortest-path are used within. More...
#include <ogdf/graphalg/steiner_tree/FullComponentGeneratorDreyfusWagnerWithoutMatrix.h>
Classes | |
class | AuxiliaryGraph |
Necessary because ogdf::EdgeWeightedGraphCopy<T> is rubbish. More... | |
struct | DWMData |
Subgraphs (given by other subgraphs and additional edges) 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 | |
FullComponentGeneratorDreyfusWagnerWithoutMatrix (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal) | |
The constructor. More... | |
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. More... | |
bool | isValidComponent (const EdgeWeightedGraphCopy< T > &tree) const |
Checks if a given tree is a valid full component. More... | |
Private Member Functions | |
edge | addNewPath (DWMData &result, node curr, const NodeArray< edge > &pred) const |
Adds the shortest path from the source to curr into result . More... | |
template<typename CONTAINER > | |
void | computePartialSolutions (const CONTAINER &targets) |
Computes all partial solutions for given m_terminalSubset. More... | |
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. More... | |
T | costOf (const List< node > &key) const |
Returns the cost of the partial solution given by key . More... | |
const DWMData * | dataOf (const List< node > &key) const |
Returns a pointer to the relevant data of the partial solution given by key . More... | |
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. More... | |
void | initializeMap () |
Initializes the hash array with all node-terminal-pairs. More... | |
template<typename CONTAINER > | |
void | insertBestSubtrees (const CONTAINER &targets, const NodeArray< DWMSplit > &split, const NodeArray< edge > &pred, const NodeArray< T > &distance, const List< node > &terminals) |
Inserts the best subtrees into the hash map. More... | |
void | insertInvalidBestSubtree (node v, const NodeArray< T > &distance, const List< node > &newSubset) |
Inserts the invalid best subtree (based on the SSSP computation) into the hash map. More... | |
void | insertValidBestSubtree (node v, const NodeArray< DWMSplit > &split, const NodeArray< edge > &pred, const List< node > &newSubset, const List< node > &terminals) |
Inserts the valid best subtree (based on the SSSP computation) into the hash map. More... | |
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 . More... | |
void | makeKey (List< node > &newSubset, node v) const |
Makes a list from the current terminal subset including an correctly inserted node v . More... | |
bool | safeIfSumSmaller (const T summand1, const T summand2, const T compareValue) const |
Checks overflow-safe if summand1 plus summand2 is less than compareValue . More... | |
void | updateAuxGraph (NodeArray< DWMSplit > &split, SubsetEnumerator< node > &subset, T oldCost) |
Updates the auxiliary graph. More... | |
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 . More... | |
Private Attributes | |
AuxiliaryGraph | m_auxG |
An auxiliary graph to compute partial solutions. More... | |
const EdgeWeightedGraph< T > & | m_G |
A reference to the graph instance. More... | |
const NodeArray< bool > & | m_isTerminal |
A reference to the terminal incidence vector. More... | |
Hashing< List< node >, DWMData, SortedNodeListHashFunc > | m_map |
A hash array for keys of size > 2. More... | |
const List< node > & | m_terminals |
A reference to the index-sorted list of terminals. More... | |
SubsetEnumerator< node > | m_terminalSubset |
Handling subsets of terminals. More... | |
A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wagner algorithm that does not need a precomputed all-pair-shortest-paths matrix because single-source-shortest-path are used within.
See also R. E. Erickson, C. L. Monma, A. F. Veinott: Send-and-split method for minimum-concave-cost network flows. Math. Oper. Res. 12 (1987) 634-664.
Definition at line 65 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inline |
The constructor.
Definition at line 491 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Adds the shortest path from the source to curr
into result
.
Definition at line 380 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inline |
Definition at line 501 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Computes all partial solutions for given m_terminalSubset.
Definition at line 314 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.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 edges represents a tree.
Definition at line 295 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Returns the cost of the partial solution given by key
.
Definition at line 230 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Returns a pointer to the relevant data of the partial solution given by key
.
Definition at line 223 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Adds edges to construct a Steiner tree
from the given data
(recursively) if the data
is valid.
Definition at line 452 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.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 518 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Initializes the hash array with all node-terminal-pairs.
Definition at line 336 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Inserts the best subtrees into the hash map.
Definition at line 432 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Inserts the invalid best subtree (based on the SSSP computation) into the hash map.
Definition at line 402 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Inserts the valid best subtree (based on the SSSP computation) into the hash map.
Definition at line 411 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inline |
Checks if a given tree
is a valid full component.
Definition at line 526 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Makes a list from subset
and its complement, each including an correctly inserted node v
.
Definition at line 274 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Makes a list from the current terminal subset including an correctly inserted node v
.
Definition at line 265 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Checks overflow-safe if summand1
plus summand2
is less than compareValue
.
Definition at line 236 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.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 256 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
inlineprivate |
Updates the auxiliary graph.
Definition at line 366 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
An auxiliary graph to compute partial solutions.
Definition at line 153 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
A reference to the graph instance.
Definition at line 66 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
A reference to the terminal incidence vector.
Definition at line 68 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
A hash array for keys of size > 2.
Definition at line 217 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
A reference to the index-sorted list of terminals.
Definition at line 67 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.
|
private |
Handling subsets of terminals.
Definition at line 154 of file FullComponentGeneratorDreyfusWagnerWithoutMatrix.h.