Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

Full3ComponentGeneratorVoronoi.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/graphalg/Voronoi.h>
36 
37 namespace ogdf {
38 namespace steiner_tree {
39 
41 template<typename T>
43 {
44 public:
45  void call(const EdgeWeightedGraph<T> &G,
46  const List<node> &terminals,
47  const NodeArray<bool> &isTerminal,
48  const NodeArray<NodeArray<T>> &distance,
49  const NodeArray<NodeArray<edge>> &pred,
50  std::function<void(node, node, node, node, T)> generateFunction) const
51  {
52  Voronoi<T> voronoi(G, G.edgeWeights(), terminals);
53  this->forAllTerminalTriples(terminals, distance,
54  [&](node u, node v, node w, const NodeArray<T> &uDistance, const NodeArray<T> &vDistance, const NodeArray<T> &wDistance) {
55  node center = nullptr;
56  T minCost = std::numeric_limits<T>::max();
57  // look in all Voronoi regions for the best center node
58  for (node x : voronoi.nodesInRegion(u)) {
59  this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
60  }
61  for (node x : voronoi.nodesInRegion(v)) {
62  this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
63  }
64  for (node x : voronoi.nodesInRegion(w)) {
65  this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
66  }
67  this->checkAndGenerateFunction(u, v, w, center, minCost, pred, isTerminal, generateFunction);
68  });
69  }
70 };
71 
72 }
73 }
Interface for full 3-component generation including auxiliary functions.
Full 3-component generation using Voronoi regions.
const EdgeArray< T > & edgeWeights() const
void checkAndGenerateFunction(node u, node v, node w, node center, T minCost, const NodeArray< NodeArray< edge >> &pred, const NodeArray< bool > &isTerminal, std::function< void(node, node, node, node, T)> generateFunction) const
Definition of ogdf::steiner_tree::Full3ComponentGeneratorModule class template.
void updateBestCenter(node x, node &center, T &minCost, const NodeArray< T > &dist1, const NodeArray< T > &dist2, const NodeArray< T > &dist3) const
Update center node if it is the best so far.
void forAllTerminalTriples(const List< node > &terminals, const NodeArray< NodeArray< T >> &distance, std::function< void(node, node, node, const NodeArray< T > &, const NodeArray< T > &, const NodeArray< T > &)> func) const
Computes Voronoi regions in an edge-weighted graph.
Definition: Voronoi.h:45
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Class for the representation of nodes.
Definition: Graph_d.h:169
void call(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, const NodeArray< NodeArray< T >> &distance, const NodeArray< NodeArray< edge >> &pred, std::function< void(node, node, node, node, T)> generateFunction) const
Generate full components and call generateFunction for each full component.
The namespace for all OGDF objects.
Definition of ogdf::Voronoi class template.