|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
46 class EdgeWeightedGraph;
48 class EdgeWeightedGraphCopy;
50 namespace steiner_tree {
79 explicit DWMData(T _cost = std::numeric_limits<T>::max()) :
cost(_cost) { }
119 T
cost = std::numeric_limits<T>::max();
141 return &
m_map.lookup(key)->info();
147 if (key.
size() == 2) {
148 #ifdef OGDF_FULL_COMPONENT_GENERATION_TERMINAL_SSSP_AWARE
164 #ifdef OGDF_FULL_COMPONENT_GENERATION_ALWAYS_SAFE
165 return summand1 + summand2 < compareValue;
167 return summand1 < std::numeric_limits<T>::max() && summand2 < std::numeric_limits<T>::max()
168 && summand1 + summand2 < compareValue;
184 if (!inserted && w->
index() > newNode->
index()) {
193 bool inserted =
false;
203 bool insertedIntoSubset =
false;
204 bool insertedIntoComplement =
false;
209 if (!insertedIntoSubset) {
212 if (!insertedIntoComplement) {
223 if (
split[v].subgraph1 !=
nullptr) {
231 makeKey(newSubset, newComplement, subset, v);
245 if (!
m_map.member(newSubset)) {
246 T oldCost =
costOf(terminals);
248 auto addPair = [&](
node v1,
node v2, T dist) {
250 if (
m_pred[v1][v2] ==
nullptr) {
277 m_map.fastInsert(newSubset, best);
282 template<
typename CONTAINER>
288 for (
node v : nodeContainer) {
302 if (v->
index() < t->index()) {
308 if (!
m_map.member(key)) {
309 if (
m_pred[t][v] ==
nullptr) {
330 node uO = nodepair.source;
331 node vO = nodepair.target;
335 uC =
tree.newNode(uO);
338 vC =
tree.newNode(vO);
340 #ifdef OGDF_FULL_COMPONENT_GENERATION_TERMINAL_SSSP_AWARE
345 tree.newEdge(uC, vC, dist);
417 static const unsigned int c_prime = 0x7fffffff;
427 unsigned int hash = 0;
429 hash = (
hash * m_random + v->index()) % c_prime;
void call(int restricted)
The namespace for all OGDF objects.
Subgraphs (given by other subgraphs and additional node pairs) and their cost for a partial solution.
SortedNodeListHashFunc()
Initializes the random number.
Declaration and implementation of ArrayBuffer class.
T costOf(const List< node > &key) const
Returns the cost of the partial solution given by key.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Includes declaration of graph class.
void makeKey(List< node > &newSubset, node v) const
Makes a list from the current terminal subset including an correctly inserted node v.
Enumerator for k-subsets of a given type.
SubsetEnumerator< node > m_terminalSubset
Handling subsets of terminals.
void invalidate()
Invalidates the data.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
bool empty() const
Returns true if the buffer is empty, false otherwise.
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.
DWMData(T _cost, NodePairs _nodepairs)
void computePartialSolution(NodeArray< DWMSplit > &split, node v, SubsetEnumerator< node > &subset, const List< node > &terminals)
Computes a partial solution for given terminals and node v.
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...
Declaration of classes used for hashing.
int index() const
Returns the (unique) node index.
void begin(int low, int high)
Initializes the SubsetEnumerator to enumerate subsets of cardinalities from low to high.
void set(const DWMData *s1, const DWMData *s2)
Sets subgraph1 and subgraph2 and computes cost.
Hashing with chaining and table doubling.
bool valid() const
Checks if the current subset is valid. If not, the subset is either not initialized or all subsets ha...
std::pair< node, node > split(Graph &G, sync_plan::PipeBij &bij, const EdgeArray< edge > *new_edges=nullptr, const EdgeArray< bool > *reverse_edges=nullptr, node src=nullptr, node tgt=nullptr)
const NodeArray< bool > & m_isTerminal
A reference to the terminal incidence vector.
A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wag...
const DWMData * subgraph1
const NodeArray< NodeArray< T > > & m_distance
A reference to the full distance matrix.
bool valid() const
Returns true iff the data is valid.
DWMData(T _cost=std::numeric_limits< T >::max())
bool isAcyclicUndirected(const Graph &G, List< edge > &backedges)
Returns true iff the undirected graph G is acyclic.
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...
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
int degree() const
Returns the degree of the node (indegree + outdegree).
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
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 EdgeWeightedGraph< T > & m_G
A reference to the graph instance.
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.
const List< node > & m_terminals
A reference to the index-sorted list of terminals.
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.
unsigned int hash(const List< node > &key) const
The actual hash function.
void push(E e)
Puts a new element in the buffer.
bool safeIfSumSmaller(const T summand1, const T summand2, const T compareValue) const
Checks overflow-safe if summand1 plus summand2 is less than compareValue.
void updateMin(T &min, const T &newValue)
Stores the minimum of min and newValue in min.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
void forEachMemberAndNonmember(std::function< void(const T &)> funcIn, std::function< void(const T &)> funcNotIn) const
Calls funcIn for each subset member and funcNotIn for each other element of the set.
void clear()
Remove all subgraphs and edges and set cost to zero.
ArrayBuffer< const DWMData * > subgraphs
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
void add(const DWMData *other)
Adds other subgraph to ours.
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.
Basic declarations, included by all source files.
bool isValidComponent(const EdgeWeightedGraphCopy< T > &graph) const
Checks if a given graph is a valid full component.
void add(NodePair nodepair, T c)
Adds a nodepair of cost c.
void computePartialSolutions(const CONTAINER &nodeContainer)
Computes all partial solutions for given m_terminalSubset.
Declaration of doubly linked lists and iterators.
void next()
Obtains the next subset if possible. The result should be checked using the valid() method.
int size() const
Returns the number of elements in the list.
void clear()
Clears the buffer.
A collection of two subgraphs and their total cost.
int randomNumber(int low, int high)
Returns random integer between low and high (including).
static uint32_t hash(uint32_t x)
const DWMData * subgraph2
const DWMData * dataOf(const List< node > &key) const
Returns a pointer to the relevant data of the partial solution given by key.
Class for the representation of nodes.
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
iterator pushBack(const E &x)
Adds element x at the end of the list.
const Graph & original() const
Returns a reference to the original graph.
int numberOfMembersAndNonmembers() const
Returns the cardinality of the (super-)set. This is the maximum size that can be used for a subset.
A class that allows to enumerate k-subsets.