40namespace steiner_tree {
109 T
cost = std::numeric_limits<T>::max();
122 class SortedNodeListHashFunc;
131 return &
m_map.lookup(key)->info();
137 if (key.
size() == 2) {
138#ifdef OGDF_FULL_COMPONENT_GENERATION_TERMINAL_SSSP_AWARE
154#ifdef OGDF_FULL_COMPONENT_GENERATION_ALWAYS_SAFE
196 subset.forEachMemberAndNonmember(
213 if (split[v].subgraph1 !=
nullptr) {
259 best.add(split[w].subgraph1);
260 best.add(split[w].subgraph2);
272 template<
typename CONTAINER>
292 if (v->index() <
t->index()) {
298 if (!
m_map.member(key)) {
330#ifdef OGDF_FULL_COMPONENT_GENERATION_TERMINAL_SSSP_AWARE
397 && v->degree() > 1) {
407 static const unsigned int c_prime = 0x7fffffff;
417 unsigned int hash = 0;
419 hash = (hash * m_random + v->index()) % c_prime;
Extends the GraphCopy concept to weighted graphs.
Declaration of classes used for hashing.
A class that allows to enumerate k-subsets.
void clear()
Clears the buffer.
void push(E e)
Puts a new element in the buffer.
bool empty() const
Returns true if the buffer is empty, false otherwise.
const Graph & original() const
Returns a reference to the original graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Hashing with chaining and table doubling.
Doubly linked lists (maintaining the length of the list).
int size() const
Returns the number of elements in the list.
iterator pushBack(const E &x)
Adds element x at the end of the list.
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
const_reference front() const
Returns a const reference to the first element.
const_reference back() const
Returns a const reference to the last element.
Dynamic arrays indexed with nodes.
Class for the representation of nodes.
int index() const
Returns the (unique) node index.
Enumerator for k-subsets of a given type.
unsigned int hash(const List< node > &key) const
The actual hash function.
SortedNodeListHashFunc()
Initializes the random number.
A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wag...
const EdgeWeightedGraph< T > & m_G
A reference to the graph instance.
void computePartialSolution(NodeArray< DWMSplit > &split, node v, SubsetEnumerator< node > &subset, const List< node > &terminals)
Computes a partial solution for given terminals and node v.
void makeKey(List< node > &newSubset, node v) const
Makes a list from the current terminal subset including an correctly inserted node v.
void computePartialSolutions(const CONTAINER &nodeContainer)
Computes all partial solutions for given m_terminalSubset.
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.
bool safeIfSumSmaller(const T summand1, const T summand2, const T compareValue) const
Checks overflow-safe if summand1 plus summand2 is less than compareValue.
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 initializeMap()
Initializes the hash array with all node-terminal-pairs.
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.
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 cor...
const List< node > & m_terminals
A reference to the index-sorted list of terminals.
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.
Hashing< List< node >, DWMData, SortedNodeListHashFunc > m_map
A hash array for keys of size > 2.
const DWMData * dataOf(const List< node > &key) const
Returns a pointer to the relevant data of the partial solution given by key.
void call(int restricted)
const NodeArray< NodeArray< T > > & m_distance
A reference to the full distance matrix.
const NodeArray< bool > & m_isTerminal
A reference to the terminal incidence vector.
bool isValidComponent(const EdgeWeightedGraphCopy< T > &graph) const
Checks if a given graph is a valid full component.
const NodeArray< NodeArray< edge > > & m_pred
A reference to the full predecessor matrix.
SubsetEnumerator< node > m_terminalSubset
Handling subsets of terminals.
T costOf(const List< node > &key) const
Returns the cost of the partial solution given by key.
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 r...
bool isAcyclicUndirected(const Graph &G, List< edge > &backedges)
Returns true iff the undirected graph G is acyclic.
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
int randomNumber(int low, int high)
Returns random integer between low and high (including).
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
void updateMin(T &min, const T &newValue)
Stores the minimum of min and newValue in min.
The namespace for all OGDF objects.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
Subgraphs (given by other subgraphs and additional node pairs) and their cost for a partial solution.
void add(const DWMData *other)
Adds other subgraph to ours.
ArrayBuffer< const DWMData * > subgraphs
DWMData(T _cost=std::numeric_limits< T >::max())
DWMData(T _cost, NodePairs _nodepairs)
void invalidate()
Invalidates the data.
bool valid() const
Returns true iff the data is valid.
void add(NodePair nodepair, T c)
Adds a nodepair of cost c.
void clear()
Remove all subgraphs and edges and set cost to zero.
A collection of two subgraphs and their total cost.
void set(const DWMData *s1, const DWMData *s2)
Sets subgraph1 and subgraph2 and computes cost.
const DWMData * subgraph1
const DWMData * subgraph2