|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
47 class EdgeWeightedGraph;
49 namespace steiner_tree {
85 if ((*it).cut.size() < (*bestIt).cut.size()) {
121 if (cutAdjIt != td.
cut.end()) {
122 td.
cut.del(cutAdjIt);
132 if (!(*it).inCut[w]) {
141 for (
auto ref : (*it).references) {
156 node v = adj->theNode();
157 node w = adj->twinNode();
173 T cost = std::numeric_limits<T>::max();
210 for (
edge e : graph.edges) {
214 for (
node t : terminals) {
284 for (
node v : graph.nodes) {
287 for (
edge e : graph.edges) {
292 orig[uv] = orig[vu] = e;
299 sssp.
call(network, weights,
copy[root], pred, distance,
true);
302 lbNodes.
init(graph, alg.
get());
303 lbEdges.
init(graph, alg.
get());
307 for (
node v : graph.nodes) {
308 lbNodes[v] += distance[
copy[v]];
312 lbArcs[a] += distance[a->
source()] + weights[a];
320 for (
node t : terminals) {
325 sssp.
call(network, weights, nonRootTerminals, pred, distance,
true);
328 for (
node v : graph.nodes) {
329 lbNodes[v] += distance[
copy[v]];
333 lbArcs[a] += distance[a->
source()];
348 for (
node root : terminals) {
365 compute(graph, terminals, terminals.front(), lbNodes, lbEdges);
367 lbNodes.
init(graph, 0);
368 lbEdges.
init(graph, 0);
370 for (
node root : terminals) {
373 compute(graph, terminals, root, nodes, edges);
374 for (
node v : graph.nodes) {
377 for (
edge e : graph.edges) {
const EdgeWeightedGraph< T > & m_graph
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The namespace for all OGDF objects.
Declaration and implementation of ArrayBuffer class.
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
void compute(const EdgeWeightedGraph< T > &graph, const List< node > &terminals, node root, NodeArray< T > &lbNodes, EdgeArray< T > &lbEdges)
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
T weight(const edge e) const
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ListIterator< ListIterator< TerminalData > > it
void reverseAllEdges()
Reverses all edges in the graph.
void compute()
Computes the lower bound.
void update(TerminalData &td, T delta)
Updates reduced costs and cut data.
T findCheapestCutArcCost(const TerminalData &td) const
Finds the cheapest arc in cut and returns its cost.
AdjEntryArray< ListIterator< adjEntry > > cutIterators
bool isConnected(const Graph &G)
Returns true iff G is connected.
adjEntry twin() const
Returns the corresponding adjacency element associated with the same edge.
TerminalData(const EdgeWeightedGraph< T > &graph, node t)
AdjEntryArray< T > m_reducedCost
Implementation of a dual-ascent-based lower bound heuristic for Steiner tree problems.
LowerBoundDualAscent(const EdgeWeightedGraph< T > &graph, const List< node > &terminals, double eps=1e-6)
Initializes the algorithm (and takes the first terminal as root)
Class for adjacency list elements.
Dijkstra's single source shortest path algorithm.
T compute(const EdgeWeightedGraph< T > &graph, const List< node > &terminals, node root)
void removeTerminalData(ListIterator< TerminalData > it)
static void copy(const T &from, T &to)
List< TerminalData > m_terminals
Decralation of GraphElement and GraphList classes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
void call(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false, node target=nullptr, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
void push(E e)
Puts a new element in the buffer.
ListIterator< TerminalData > chooseTerminal()
Finds the terminal with the smallest cut arc set (of the last iteration)
node source() const
Returns the source node of the edge.
void updateMin(T &min, const T &newValue)
Stores the minimum of min and newValue in min.
T call(const EdgeWeightedGraph< T > &graph, const List< node > &terminals)
Calls the algorithm and returns the lower bound.
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
NodeArray< List< ListIterator< TerminalData > > > m_inTerminalCut
Mapping of nodes to the cuts they are in.
Data type for general directed graphs (adjacency list representation).
T reducedCost(adjEntry adj) const
Returns the reduced cost of the arc given by adj.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
std::enable_if< std::is_integral< T >::value, bool >::type leq(const T &x, const T &y) const
Compare if x is LEQ than y for integral types.
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
void call(const EdgeWeightedGraph< T > &graph, const List< node > &terminals, NodeArray< T > &lbNodes, EdgeArray< T > &lbEdges)
Compute the lower bounds under the assumption nodes or edges are included in the solution.
std::enable_if< std::is_integral< T >::value, bool >::type equal(const T &x, const T &y) const
Compare if x is EQUAL to y for integral types.
void extendCut(adjEntry adj)
Assumes that the reduced cost of arc adj is zeroed and hence updates (in relevant cuts) the set of ar...
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
void updateMax(T &max, const T &newValue)
Stores the maximum of max and newValue in max.
Basic declarations, included by all source files.
node newNode(int index=-1)
Creates a new node and returns it.
ArrayBuffer< TerminalDataReference > references
Class for the representation of edges.
Implementation of Dijkstra's single source shortest path algorithm.
Declaration of doubly linked lists and iterators.
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
std::enable_if< std::is_integral< T >::value, bool >::type geq(const T &x, const T &y) const
Compare if x is GEQ to y for integral types.
Computes lower bounds for minimum Steiner tree instances.
T get() const
Returns the lower bound.
Encapsulates a pointer to a list element.
void setRepetitions(int num)
Sets the number of repeated calls to the lower bound algorithm (runs with different roots)
bool addNode(ListIterator< TerminalData > &it, node t)
Adds a node to the cut and add neighbors recursively.
node target() const
Returns the target node of the edge.
edge newEdge(node v, node w, int index=-1)
Creates a new edge (v,w) and returns it.
bool addNodeChecked(ListIterator< TerminalData > &it, node w)
Class for the representation of nodes.
LowerBoundDualAscent(const EdgeWeightedGraph< T > &graph, const List< node > &terminals, node root, double eps=1e-6)
Initializes the algorithm.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.