179 for(
node v : nodes) {
184 for(
edge e : edges) {
194 #ifdef OGDF_DUAL_ASCENT_LOGGING 197 <<
"root terminal is node " <<
m_rootTerminal <<
"." << std::endl;
222 return (
m_rootTerminal != w || rootIsTerminal) && (*m_pIsTerminal)[w];
229 #ifdef OGDF_DUAL_ASCENT_LOGGING 230 cout <<
" searching for active component.." << std::endl;
238 if(!checked[candidate]) {
239 checked[candidate] =
true;
245 #ifdef OGDF_DUAL_ASCENT_LOGGING 246 cout <<
" active component found: component " << result <<
", terminal " << *terminal << std::endl;
253 #ifdef OGDF_DUAL_ASCENT_LOGGING 255 cout <<
" could not find an active component" << std::endl;
270 visited[root] =
true;
277 while(!queue.
empty()) {
293 for(
node v : weakComp) {
312 bool danglingTerminalFound =
false;
313 bool hasTerminal =
false;
315 #ifdef OGDF_DUAL_ASCENT_LOGGING 316 cout <<
" checking whether component of node " << source <<
" is active.. " << std::endl;
317 cout <<
" component has id " << comp << std::endl;
323 visited[source] =
true;
324 #ifdef OGDF_DUAL_ASCENT_LOGGING 325 while(!queue.
empty()) {
327 while(!queue.
empty() && !danglingTerminalFound) {
342 #ifdef OGDF_DUAL_ASCENT_LOGGING 343 if(hasTerminal) { cout <<
" component includes a terminal" << std::endl; }
344 if(danglingTerminalFound) { cout <<
" component has dangling terminal" << std::endl; }
345 if(hasTerminal && !danglingTerminalFound) { cout <<
" component is active!" << std::endl; }
347 return hasTerminal && !danglingTerminalFound;
357 #ifdef OGDF_DUAL_ASCENT_LOGGING 358 cout <<
"MinSteinerTreeDualAscent called." << std::endl;
359 cout <<
"terminals are: ";
361 for(
node v : terminals) {
378 node terminal =
nullptr;
380 #ifdef OGDF_DUAL_ASCENT_LOGGING 381 cout <<
"main loop starting.." << endl;
390 edge minEdge =
nullptr;
392 #ifdef OGDF_DUAL_ASCENT_LOGGING 393 cout <<
" cut edges:";
395 for(
edge e : *cutEdges) {
396 #ifdef OGDF_DUAL_ASCENT_LOGGING 404 #ifdef OGDF_DUAL_ASCENT_LOGGING 405 cout << std::endl <<
" next edge: " << minEdge << std::endl;
410 for(
edge e : *cutEdges) {
425 if(finalSteinerTree->
copy(origEdge) ==
nullptr) { finalSteinerTree->
newEdge(origEdge, cost); }
428 #ifdef OGDF_DUAL_ASCENT_LOGGING 429 cout <<
"removing expendable edges" << std::endl;
434 #ifdef OGDF_DUAL_ASCENT_LOGGING 435 cout <<
"algorithm terminated." << std::endl;
node target() const
Returns the target node of the edge.
edge theEdge() const
Returns the edge associated with this adjacency entry.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
EdgeArray< T > m_edgeSlacks
const List< node > * m_pTerminals
const NodeArray< bool > * m_pIsTerminal
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.
NodeArray< int > m_componentMapping
void init()
Reinitializes the array. Associates the array with no graph.
This class serves as an interface for various methods to compute minimum or approximations of minimum...
Indexed arrays using hashing for element access.
edge newEdge(node u, node v, T weight)
Interface of Minimum Steiner Tree Algorithms.
Dual ascent approximation algorithm for Steiner tree problems.
void createEmpty(const Graph &G)
Associates the graph copy with G, but does not create any nodes or edges.
Extends the GraphCopy concept to weighted graphs.
Dynamic arrays indexed with edges.
List< edge > * computeCutSet(const node v) const
Returns all incoming cut edges of the component of v.
const EdgeWeightedGraph< T > * m_pOrigGraph
bool isActiveComponent(const node v) const
Determines whether a strongly connected component is active (paper says "is root component").
bool isTerminal(const node v, bool rootIsTerminal) const
Returns whether this node is a terminal.
void updateComponents()
Re-establishes all strongly connected components for the Steiner graph.
edge newEdge(edge eOrig)
Creates a new edge (v,w) with original edge eOrig.
T computeSteinerTree(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, EdgeWeightedGraphCopy< T > *&finalSteinerTree)
Creates a minimum Steiner tree given a weighted graph and a list of terminals.
void createEmpty(const Graph &wG)
int numberOfEdges() const
Returns the number of edges in the graph.
virtual void clear() override
Removes all nodes and all edges from the graph.
void init()
Intializes all relevant variables.
int findActiveComponent(node *terminal) const
Searches for the next active component.
Doubly linked lists (maintaining the length of the list).
Class for the representation of edges.
E popFrontRet()
Removes the first element from the list and returns it.
Copies of graphs supporting edge splitting.
Class for the representation of nodes.
EdgeArray< edge > m_origMapping
const Graph & original() const
Returns a reference to the original graph.
static T pruneAllDanglingSteinerPaths(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Prune Steiner nodes with degree 1 and their paths to terminal or branching nodes. ...
static T removeCyclesFrom(EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
Remove remaining cycles from an Steiner "almost" tree.
node source() const
Returns the source node of the edge.
The namespace for all OGDF objects.
int strongComponents(const Graph &G, NodeArray< int > &component)
Computes the strongly connected components of the digraph G.
int numberOfNodes() const
Returns the number of nodes in the graph.
bool empty() const
Returns true iff the list is empty.
Class for adjacency list elements.
int findComponent(const node v) const
Returns the component of node v.
EdgeArray< bool > m_edgeInclusions
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.