Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ogdf::MinSteinerTreeRZLoss< T > Class Template Reference

This class implements the loss-contracting (1.55+epsilon)-approximation algorithm for the Steiner tree problem by Robins and Zelikovsky. More...

#include <ogdf/graphalg/MinSteinerTreeRZLoss.h>

+ Inheritance diagram for ogdf::MinSteinerTreeRZLoss< T >:

Public Types

template<typename TYPE >
using SaveStatic = steiner_tree::SaveStatic< TYPE >
 

Public Member Functions

 MinSteinerTreeRZLoss ()
 
 MinSteinerTreeRZLoss (int v)
 
virtual ~MinSteinerTreeRZLoss ()
 
virtual T call (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. More...
 
void forceAPSP (bool force=true)
 For the 3-restricted case, it is sufficient to compute an SSSP from every terminal instead of doing a full APSP. More...
 
long numberOfComponentLookUps ()
 Returns the number of components lookups during execution time. More...
 
long numberOfContractedComponents ()
 Returns the number of contracted components. More...
 
long numberOfGeneratedComponents ()
 Returns the number of generated components. More...
 
void setMaxComponentSize (int k)
 Sets the maximal number of terminals in a full component. More...
 
- Public Member Functions inherited from ogdf::MinSteinerTreeModule< T >
 MinSteinerTreeModule ()
 
virtual ~MinSteinerTreeModule ()
 

Protected Member Functions

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. More...
 

Private Member Functions

void contractLoss (EdgeWeightedGraphCopy< T > &steinerTree, int compId)
 Contracts the loss of a full component and integrates it into the given terminal-spanning tree. More...
 
double extractMaxComponent (const EdgeWeightedGraphCopy< T > &steinerTree, int &maxCompId, SaveStatic< T > &save)
 Traverses over all full components and finds the one with the highest win-objective. More...
 
void findFull3Components (SubsetEnumerator< node > &terminalSubset, const EdgeWeightedGraphCopy< T > &tree, const SaveStatic< T > &save)
 
void findFullComponents (const EdgeWeightedGraphCopy< T > &tree, const SaveStatic< T > &save)
 Finds all k-restricted full components (except 2-components). More...
 
template<typename TERMINAL_CONTAINER >
T gain (const TERMINAL_CONTAINER &terminals, const EdgeWeightedGraphCopy< T > &steinerTree, const SaveStatic< T > &save)
 Calculates the gain for a full component. More...
 
void generateInitialTerminalSpanningTree (EdgeWeightedGraphCopy< T > &steinerTree)
 Builds a minimum terminal spanning tree (via a MST call on the complete terminal graph) More...
 
bool isValidComponent (const EdgeWeightedGraphCopy< T > &graph)
 
void multiPass (SaveStatic< T > &save, EdgeWeightedGraphCopy< T > &steinerTree, NodeArray< bool > &isNewTerminal)
 Contraction phase of the algorithm. More...
 

Private Attributes

long m_componentsContracted
 Number of contracted components. More...
 
long m_componentsGenerated
 Number of generated components. More...
 
long m_componentsLookUps
 Number of components lookups. More...
 
NodeArray< NodeArray< T > > m_distance
 
steiner_tree::FullComponentWithLossStore< T > * m_fullCompStore
 All generated full components. More...
 
const NodeArray< bool > * m_isTerminal
 Incidence vector for terminal nodes. More...
 
List< node > m_nonterminals
 List of Steiner (non-terminal) nodes. More...
 
const EdgeWeightedGraph< T > * m_originalGraph
 The original edge-weighted graph. More...
 
NodeArray< NodeArray< edge > > m_pred
 
int m_restricted
 Parameter for the number of terminals in a full component. More...
 
bool m_ssspDistances
 True iff we only compute SSSP from terminals instead of APSP for full component construction. More...
 
List< node > m_terminals
 List of terminal nodes (will be copied and sorted) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ogdf::MinSteinerTreeModule< T >
static void allPairShortestPaths (const EdgeWeightedGraph< T > &G, const List< node > &nonterminals, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred)
 Undirected All-pair-shortest-paths (Floyd-Warshall) over non-terminal nodes of G. More...
 
static void allPairShortestPathsDetour (const EdgeWeightedGraph< T > &G, const List< node > &nonterminals, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred)
 
static void allPairShortestPathsStrict (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T > > &distance, NodeArray< NodeArray< edge > > &pred)
 
static void drawSteinerTreeSVG (const EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, const char *filename)
 Writes a SVG that shows only the given Steiner tree. More...
 
static void drawSVG (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, const EdgeWeightedGraphCopy< T > &steinerTree, const char *filename)
 Writes an SVG file of a minimum Steiner tree in the original graph. More...
 
static bool isQuasiBipartite (const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal)
 Checks in O(n + m) time if a given Steiner tree problem instance is quasi-bipartite. More...
 
static bool isSteinerTree (const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const EdgeWeightedGraphCopy< T > &steinerTree)
 Checks in O(n) time if a given tree is acually a Steiner Tree. More...
 
static T pruneAllDanglingSteinerPaths (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
 Prune Steiner nodes with degree 1 and their paths to terminal or branching nodes. More...
 
static T pruneDanglingSteinerPathFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, node start)
 Prune the dangling Steiner path beginning at a given node only. More...
 
static T pruneDanglingSteinerPathsFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal, const List< node > &start)
 Prune dangling Steiner paths beginning at given nodes only. More...
 
static T removeCyclesFrom (EdgeWeightedGraphCopy< T > &steinerTree, const NodeArray< bool > &isTerminal)
 Remove remaining cycles from an Steiner "almost" tree. More...
 
static void singleSourceShortestPaths (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &isTerminal, NodeArray< T > &distance, NodeArray< edge > &pred)
 Undirected Single-source-shortest-paths (Dijkstra) over non-terminal nodes of G. More...
 
static void singleSourceShortestPathsDetour (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &isTerminal, NodeArray< T > &distance, NodeArray< edge > &pred)
 
static void singleSourceShortestPathsStrict (const EdgeWeightedGraph< T > &G, node source, const NodeArray< bool > &isTerminal, NodeArray< T > &distance, NodeArray< edge > &pred)
 

Detailed Description

template<typename T>
class ogdf::MinSteinerTreeRZLoss< T >

This class implements the loss-contracting (1.55+epsilon)-approximation algorithm for the Steiner tree problem by Robins and Zelikovsky.

This implementation is based on:

(G. Robins, A. Zelikovsky, Improved Steiner Tree Approximation in Graphs, SODA 2000, pages 770-779, SIAM, 2000)

Definition at line 61 of file MinSteinerTreeRZLoss.h.

Member Typedef Documentation

◆ SaveStatic

template<typename T >
template<typename TYPE >
using ogdf::MinSteinerTreeRZLoss< T >::SaveStatic = steiner_tree::SaveStatic<TYPE>

Definition at line 63 of file MinSteinerTreeRZLoss.h.

Constructor & Destructor Documentation

◆ MinSteinerTreeRZLoss() [1/2]

template<typename T >
ogdf::MinSteinerTreeRZLoss< T >::MinSteinerTreeRZLoss ( )
inline

Definition at line 65 of file MinSteinerTreeRZLoss.h.

◆ MinSteinerTreeRZLoss() [2/2]

template<typename T >
ogdf::MinSteinerTreeRZLoss< T >::MinSteinerTreeRZLoss ( int  v)
inline

Definition at line 71 of file MinSteinerTreeRZLoss.h.

◆ ~MinSteinerTreeRZLoss()

template<typename T >
virtual ogdf::MinSteinerTreeRZLoss< T >::~MinSteinerTreeRZLoss ( )
inlinevirtual

Definition at line 77 of file MinSteinerTreeRZLoss.h.

Member Function Documentation

◆ call()

template<typename T >
virtual T ogdf::MinSteinerTreeRZLoss< T >::call ( const EdgeWeightedGraph< T > &  G,
const List< node > &  terminals,
const NodeArray< bool > &  isTerminal,
EdgeWeightedGraphCopy< T > *&  finalSteinerTree 
)
inlineoverridevirtual

Builds a minimum Steiner tree given a weighted graph and a list of terminals.

Parameters
GThe weighted input graph
terminalsThe list of terminal nodes
isTerminalA bool array of terminals
finalSteinerTreeThe final Steiner tree
Returns
The objective value (sum of edge costs) of the final Steiner tree

Reimplemented from ogdf::MinSteinerTreeModule< T >.

Definition at line 79 of file MinSteinerTreeRZLoss.h.

◆ computeSteinerTree()

template<typename T >
T ogdf::MinSteinerTreeRZLoss< T >::computeSteinerTree ( const EdgeWeightedGraph< T > &  G,
const List< node > &  terminals,
const NodeArray< bool > &  isTerminal,
EdgeWeightedGraphCopy< T > *&  finalSteinerTree 
)
overrideprotectedvirtual

Builds a minimum Steiner tree given a weighted graph and a list of terminals.

See also
MinSteinerTreeModule::call
Parameters
GThe weighted input graph
terminalsThe list of terminal nodes
isTerminalA bool array of terminals
finalSteinerTreeThe final Steiner tree
Returns
The objective value (sum of edge costs) of the final Steiner tree

Implements ogdf::MinSteinerTreeModule< T >.

Definition at line 220 of file MinSteinerTreeRZLoss.h.

◆ contractLoss()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::contractLoss ( EdgeWeightedGraphCopy< T > &  steinerTree,
int  compId 
)
private

Contracts the loss of a full component and integrates it into the given terminal-spanning tree.

Parameters
steinerTreeThe Steiner tree into which the full component is integrated
compIdThe full component to be contracted and inserted

Definition at line 465 of file MinSteinerTreeRZLoss.h.

◆ extractMaxComponent()

template<typename T >
double ogdf::MinSteinerTreeRZLoss< T >::extractMaxComponent ( const EdgeWeightedGraphCopy< T > &  steinerTree,
int &  maxCompId,
SaveStatic< T > &  save 
)
private

Traverses over all full components and finds the one with the highest win-objective.

Parameters
steinerTreeCurrent Steiner tree
maxCompIdThe index of the full component with highest win-objective
saveData structure for calculating save values
Returns
the win-objective of the returned full component

Definition at line 412 of file MinSteinerTreeRZLoss.h.

◆ findFull3Components()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::findFull3Components ( SubsetEnumerator< node > &  terminalSubset,
const EdgeWeightedGraphCopy< T > &  tree,
const SaveStatic< T > &  save 
)
private

Definition at line 302 of file MinSteinerTreeRZLoss.h.

◆ findFullComponents()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::findFullComponents ( const EdgeWeightedGraphCopy< T > &  tree,
const SaveStatic< T > &  save 
)
private

Finds all k-restricted full components (except 2-components).

Parameters
treeCurrent minimal terminal spanning tree
saveData structure for calculating save edges

Definition at line 355 of file MinSteinerTreeRZLoss.h.

◆ forceAPSP()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::forceAPSP ( bool  force = true)
inline

For the 3-restricted case, it is sufficient to compute an SSSP from every terminal instead of doing a full APSP.

In case a full APSP is faster, use this method.

Parameters
forceTrue to force APSP instead of SSSP.

Definition at line 101 of file MinSteinerTreeRZLoss.h.

◆ gain()

template<typename T >
template<typename TERMINAL_CONTAINER >
T ogdf::MinSteinerTreeRZLoss< T >::gain ( const TERMINAL_CONTAINER &  terminals,
const EdgeWeightedGraphCopy< T > &  steinerTree,
const SaveStatic< T > &  save 
)
private

Calculates the gain for a full component.

  • *
    Parameters
    terminalsThe terminals of the full component
    steinerTreeCurrent Steiner tree
    saveData structure for calculating save values
    Returns
    the gain (cost of save edges) of the returned full component

Definition at line 443 of file MinSteinerTreeRZLoss.h.

◆ generateInitialTerminalSpanningTree()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::generateInitialTerminalSpanningTree ( EdgeWeightedGraphCopy< T > &  steinerTree)
private

Builds a minimum terminal spanning tree (via a MST call on the complete terminal graph)

Parameters
steinerTreeThe resulting minimum terminal spanning tree

Definition at line 279 of file MinSteinerTreeRZLoss.h.

◆ isValidComponent()

template<typename T >
bool ogdf::MinSteinerTreeRZLoss< T >::isValidComponent ( const EdgeWeightedGraphCopy< T > &  graph)
inlineprivate

Definition at line 137 of file MinSteinerTreeRZLoss.h.

◆ multiPass()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::multiPass ( SaveStatic< T > &  save,
EdgeWeightedGraphCopy< T > &  steinerTree,
NodeArray< bool > &  isNewTerminal 
)
private

Contraction phase of the algorithm.

Parameters
savesave data structure
steinerTreethe terminal-spanning tree to be modified
isNewTerminaltrue for nodes to be interpreted as terminals

Definition at line 386 of file MinSteinerTreeRZLoss.h.

◆ numberOfComponentLookUps()

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::numberOfComponentLookUps ( )
inline

Returns the number of components lookups during execution time.

Definition at line 117 of file MinSteinerTreeRZLoss.h.

◆ numberOfContractedComponents()

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::numberOfContractedComponents ( )
inline

Returns the number of contracted components.

Definition at line 112 of file MinSteinerTreeRZLoss.h.

◆ numberOfGeneratedComponents()

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::numberOfGeneratedComponents ( )
inline

Returns the number of generated components.

Definition at line 107 of file MinSteinerTreeRZLoss.h.

◆ setMaxComponentSize()

template<typename T >
void ogdf::MinSteinerTreeRZLoss< T >::setMaxComponentSize ( int  k)
inline

Sets the maximal number of terminals in a full component.

Parameters
kthe maximal number of terminals in a full component

Definition at line 91 of file MinSteinerTreeRZLoss.h.

Member Data Documentation

◆ m_componentsContracted

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::m_componentsContracted
private

Number of contracted components.

Definition at line 215 of file MinSteinerTreeRZLoss.h.

◆ m_componentsGenerated

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::m_componentsGenerated
private

Number of generated components.

Definition at line 214 of file MinSteinerTreeRZLoss.h.

◆ m_componentsLookUps

template<typename T >
long ogdf::MinSteinerTreeRZLoss< T >::m_componentsLookUps
private

Number of components lookups.

Definition at line 216 of file MinSteinerTreeRZLoss.h.

◆ m_distance

template<typename T >
NodeArray< NodeArray<T> > ogdf::MinSteinerTreeRZLoss< T >::m_distance
private

Definition at line 211 of file MinSteinerTreeRZLoss.h.

◆ m_fullCompStore

template<typename T >
steiner_tree::FullComponentWithLossStore<T>* ogdf::MinSteinerTreeRZLoss< T >::m_fullCompStore
private

All generated full components.

Definition at line 209 of file MinSteinerTreeRZLoss.h.

◆ m_isTerminal

template<typename T >
const NodeArray<bool>* ogdf::MinSteinerTreeRZLoss< T >::m_isTerminal
private

Incidence vector for terminal nodes.

Definition at line 205 of file MinSteinerTreeRZLoss.h.

◆ m_nonterminals

template<typename T >
List<node> ogdf::MinSteinerTreeRZLoss< T >::m_nonterminals
private

List of Steiner (non-terminal) nodes.

Definition at line 207 of file MinSteinerTreeRZLoss.h.

◆ m_originalGraph

template<typename T >
const EdgeWeightedGraph<T>* ogdf::MinSteinerTreeRZLoss< T >::m_originalGraph
private

The original edge-weighted graph.

Definition at line 204 of file MinSteinerTreeRZLoss.h.

◆ m_pred

template<typename T >
NodeArray< NodeArray<edge> > ogdf::MinSteinerTreeRZLoss< T >::m_pred
private

Definition at line 212 of file MinSteinerTreeRZLoss.h.

◆ m_restricted

template<typename T >
int ogdf::MinSteinerTreeRZLoss< T >::m_restricted
private

Parameter for the number of terminals in a full component.

Definition at line 208 of file MinSteinerTreeRZLoss.h.

◆ m_ssspDistances

template<typename T >
bool ogdf::MinSteinerTreeRZLoss< T >::m_ssspDistances
private

True iff we only compute SSSP from terminals instead of APSP for full component construction.

Definition at line 210 of file MinSteinerTreeRZLoss.h.

◆ m_terminals

template<typename T >
List<node> ogdf::MinSteinerTreeRZLoss< T >::m_terminals
private

List of terminal nodes (will be copied and sorted)

Definition at line 206 of file MinSteinerTreeRZLoss.h.


The documentation for this class was generated from the following file: