|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
49 class EdgeWeightedGraphCopy;
51 namespace steiner_tree {
102 for (
node v : terminals) {
149 m_copy.setWeight(e, value);
164 explicit DWMData(T _cost = std::numeric_limits<T>::max()) :
cost(_cost) { }
178 if (other->
valid()) {
204 T
cost = std::numeric_limits<T>::max();
226 return &
m_map.lookup(key)->info();
237 #ifdef OGDF_FULL_COMPONENT_GENERATION_ALWAYS_SAFE
238 return summand1 + summand2 < compareValue;
240 return summand1 < std::numeric_limits<T>::max() && summand2 < std::numeric_limits<T>::max()
241 && summand1 + summand2 < compareValue;
257 if (!inserted && w->
index() > newNode->
index()) {
266 bool inserted =
false;
276 bool insertedIntoSubset =
false;
277 bool insertedIntoComplement =
false;
282 if (!insertedIntoSubset) {
285 if (!insertedIntoComplement) {
304 makeKey(newSubset, newComplement, subset, v);
313 template<
typename CONTAINER>
346 if (v->
index() < t->index()) {
353 if (!
m_map.member(key)) {
354 T dist = distance[v];
356 for (
node curr = v; pred[curr] !=
nullptr; curr = pred[curr]->opposite(curr)) {
357 edges.
push(pred[curr]);
372 cost =
split[w].cost;
407 m_map.fastInsert(newSubset, best);
427 m_map.fastInsert(newSubset, best);
431 template<
typename CONTAINER>
434 for (
node v : targets) {
439 if (!
m_map.member(newSubset)) {
465 uC =
tree.newNode(uO);
468 vC =
tree.newNode(vO);
470 T dist =
m_G.weight(e);
471 tree.newEdge(e, dist);
543 static const unsigned int c_prime = 0x7fffffff;
553 unsigned int hash = 0;
555 hash = (
hash * m_random + v->index()) % c_prime;
The namespace for all OGDF objects.
void set(const DWMData *s1, const DWMData *s2)
Sets subgraph1 and subgraph2 and computes cost.
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.
Declaration and implementation of ArrayBuffer class.
Includes declaration of graph class.
bool isValidComponent(const EdgeWeightedGraphCopy< T > &tree) const
Checks if a given tree is a valid full component.
Enumerator for k-subsets of a given type.
#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 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.
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.
EdgeArray< edge > m_origOfEdge
A mapping from copied edges to original edges.
Declaration of classes used for hashing.
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.
int index() const
Returns the (unique) node index.
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.
A generator for restricted full components (for Steiner tree approximations) based on the Dreyfus-Wag...
const EdgeWeightedGraph< T > & graph() const
Returns a const reference to the graph.
void begin(int low, int high)
Initializes the SubsetEnumerator to enumerate subsets of cardinalities from low to high.
bool valid() const
Returns true iff the data is valid.
Hashing with chaining and table doubling.
SubsetEnumerator< node > m_terminalSubset
Handling subsets of terminals.
const EdgeWeightedGraph< T > & m_original
A reference to the original graph.
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)
NodeArray< node > m_origOfNode
A mapping from copied nodes to original nodes.
unsigned int hash(const List< node > &key) const
The actual hash function.
AuxiliaryGraph m_auxG
An auxiliary graph to compute partial solutions.
T costOf(const List< node > &key) const
Returns the cost of the partial solution given by key.
AuxiliaryGraph(const EdgeWeightedGraph< T > &orig, const List< node > &terminals)
Constructs a copy of the original graph with an added source node having edges to all other nodes.
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...
ArrayBuffer< const DWMData * > subgraphs
bool safeIfSumSmaller(const T summand1, const T summand2, const T compareValue) const
Checks overflow-safe if summand1 plus summand2 is less than compareValue.
NodeArray< bool > m_isTerminal
True for terminals in the auxiliary graph.
const NodeArray< bool > & terminalArray() const
Returns a const reference to m_isTerminal.
void initializeMap()
Initializes the hash array with all node-terminal-pairs.
node m_source
The source node.
SortedNodeListHashFunc()
Initializes the random number.
void computePartialSolutions(const CONTAINER &targets)
Computes all partial solutions for given m_terminalSubset.
Class for adjacency list elements.
node copy(node v) const
Returns the copied node of the original node v.
const DWMData * subgraph1
Declaration of ogdf::MinSteinerTreeModule.
bool isAcyclicUndirected(const Graph &G, List< edge > &backedges)
Returns true iff the undirected graph G is acyclic.
Necessary because ogdf::EdgeWeightedGraphCopy<T> is rubbish.
void setWeight(edge e, T value)
Sets the weight of a copied edge.
ArrayBuffer< edge > edges
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...
const Graph * graphOf() const
Returns the graph containing this node (debug only).
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.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
edge addNewPath(DWMData &result, node curr, const NodeArray< edge > &pred) const
Adds the shortest path from the source to curr into result.
node source() const
Returns the source node.
void push(E e)
Puts a new element in the buffer.
Subgraphs (given by other subgraphs and additional edges) and their cost for a partial solution.
node source() const
Returns the source node of the edge.
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.
void updateMin(T &min, const T &newValue)
Stores the minimum of min and newValue in min.
FullComponentGeneratorDreyfusWagnerWithoutMatrix(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal)
The constructor.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
void add(edge e, T c)
Adds an edge e of cost c.
const NodeArray< bool > & m_isTerminal
A reference to the terminal incidence vector.
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 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.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
void clear()
Remove all subgraphs and edges and set cost to zero.
EdgeWeightedGraph< T > m_copy
The auxiliary copy.
Declaration of class EdgeWeightedGraph.
Basic declarations, included by all source files.
const DWMData * subgraph2
void invalidate()
Invalidates the data.
const EdgeWeightedGraph< T > & m_G
A reference to the graph instance.
void makeKey(List< node > &newSubset, node v) const
Makes a list from the current terminal subset including an correctly inserted node v.
T weight(edge e) const
Returns the weight of a copied edge.
node opposite(node v) const
Returns the adjacent node different from v.
const List< node > & m_terminals
A reference to the index-sorted list of terminals.
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
DWMData(T _cost=std::numeric_limits< T >::max())
const Graph * graphOf() const
Returns the graph containing this node (debug only).
void next()
Obtains the next subset if possible. The result should be checked using the valid() method.
Hashing< List< node >, DWMData, SortedNodeListHashFunc > m_map
A hash array for keys of size > 2.
edge original(edge e) const
Returns the original edge for the copied edge e.
void call(int restricted)
DWMData(T _cost, ArrayBuffer< edge > _edges)
int size() const
Returns the number of elements in the list.
A collection of two subgraphs and their total cost.
void clear()
Clears the buffer.
void updateAuxGraph(NodeArray< DWMSplit > &split, SubsetEnumerator< node > &subset, T oldCost)
Updates the auxiliary graph.
node target() const
Returns the target node of the edge.
int randomNumber(int low, int high)
Returns random integer between low and high (including).
static uint32_t hash(uint32_t x)
Class for the representation of nodes.
node original(node v) const
Returns the original node for the copied node v.
const DWMData * dataOf(const List< node > &key) const
Returns a pointer to the relevant data of the partial solution given by key.
Declaration of simple graph algorithms.
bool isTree(const Graph &G)
Returns true iff G is a tree, i.e. contains no undirected cycle and is connected.
void add(const DWMData *other)
Adds other subgraph to ours.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
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.
NodeArray< node > m_copyOfNode
A mapping from original nodes to copied nodes.