210 for(
node v : nodes) {
225 for(
edge e : edges) {
226 node v = e->source();
227 node w = e->target();
238 if(*nextEdge ==
nullptr || value < result) {
264 for(
node v : nodes) {
272 #ifdef OGDF_MINSTEINERTREE_PRIMAL_DUAL_LOGGING 273 std::cout <<
"Goemans primal-dual starting..." << std::endl;
274 std::cout <<
"terminals:";
276 std::cout <<
" " << v;
278 std::cout << std::endl;
280 std::cout <<
"loop starting... " << std::endl;
285 #ifdef OGDF_MINSTEINERTREE_PRIMAL_DUAL_LOGGING 286 std::cout <<
"active component exists" << std::endl;
289 edge minEdge =
nullptr;
293 #ifdef OGDF_MINSTEINERTREE_PRIMAL_DUAL_LOGGING 294 std::cout <<
"minEdge found: " << minEdge <<
", weight is " <<
m_pGraph->weight(minEdge) <<
", adjusted weight is " << minValue << std::endl;
300 if(finalSteinerTree->
copy(v) ==
nullptr) {
303 if(finalSteinerTree->
copy(w) ==
nullptr) {
308 T weight =
m_pGraph->weight(minEdge);
310 finalSteinerTree->
newEdge(minEdge, weight);
320 #ifdef OGDF_MINSTEINERTREE_PRIMAL_DUAL_LOGGING 321 std::cout <<
"calculation finished!" << std::endl;
bool isActive(int component) const
Returns whether the given component is active.
node target() const
Returns the target node of the edge.
void clear()
Removes all elements from the list.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
iterator pushBack(const E &x)
Adds element x at the end of the list.
void init()
Reinitializes the array. Associates the array with no graph.
virtual T call(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)
Calls the Steiner tree algorithm for nontrivial cases but handles trivial cases directly.
Serves as an interface for various methods to compute or approximate minimum Steiner trees on undirec...
Indexed arrays using hashing for element access.
edge newEdge(node u, node v, T weight)
Declaration of ogdf::MinSteinerTreeModule.
Extends the GraphCopy concept to weighted graphs.
virtual T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
Builds a minimum Steiner tree given a weighted graph and a list of terminals.
void del(iterator it)
Removes it from the list.
const EdgeWeightedGraph< T > * m_pGraph
void createEmpty(const Graph &wG)
virtual T call(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree) override
Calls the Steiner tree algorithm for nontrivial cases but handles trivial cases directly.
Doubly linked lists (maintaining the length of the list).
int find(disjoint_sets::CompressionOption< CompressionOptions::PathCompression >, int set)
DisjointSets * m_pComponents
A Union/Find data structure for maintaining disjoint sets.
int getComponent(const node v) const
Finds the biggest set including node v.
Class for the representation of edges.
Class for the representation of nodes.
Container::value_type minValue(const Container &values)
Returns the minimum of an iterable container of given values.
void makeActive(int component)
Marks the specified component as active.
Primal-Dual approximation algorithm for Steiner tree problems.
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prunes nonterminal leaves and their paths to terminal or branching nodes.
int makeSet()
Initializes a singleton set.
const List< node > * m_pTerminals
List< int > m_activeComponents
void init()
Initializes all required datastructes.
HashArray< int, ListIterator< int > > m_activeComponentIterators
int size() const
Returns the number of elements in the list.
Implementation of disjoint sets data structures (union-find functionality).
node source() const
Returns the source node of the edge.
int link(disjoint_sets::LinkOption< LinkOptions::Naive >, int set1, int set2)
The namespace for all OGDF objects.
double getNextEdge(edge *nextEdge)
Idendifies the next edge with a tight-to-be packing constraint.
NodeArray< double > m_priorities
void updatePriorities(double eps)
Must be called after merging any two components.
bool empty() const
Returns true iff the list is empty.
const NodeArray< bool > * m_pIsTerminal
NodeArray< int > m_componentMapping
double getLastLowerBound() const
Returns the lower bound calculated while solving the last problem.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void mergeComponents(const node v, const node w)
Merges two disjoint components.