Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Full3ComponentGeneratorVoronoi.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
37
38#include <functional>
39#include <limits>
40
41namespace ogdf {
42template<class E>
43class List;
44template<typename T>
45class EdgeWeightedGraph;
46
47namespace steiner_tree {
48
50template<typename T>
52public:
53 void call(const EdgeWeightedGraph<T>& G, const List<node>& terminals,
54 const NodeArray<bool>& isTerminal, const NodeArray<NodeArray<T>>& distance,
55 const NodeArray<NodeArray<edge>>& pred,
56 std::function<void(node, node, node, node, T)> generateFunction) const {
57 Voronoi<T> voronoi(G, G.edgeWeights(), terminals);
58 this->forAllTerminalTriples(terminals, distance,
59 [&](node u, node v, node w, const NodeArray<T>& uDistance,
60 const NodeArray<T>& vDistance, const NodeArray<T>& wDistance) {
61 node center = nullptr;
62 T minCost = std::numeric_limits<T>::max();
63 // look in all Voronoi regions for the best center node
64 for (node x : voronoi.nodesInRegion(u)) {
65 this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
66 }
67 for (node x : voronoi.nodesInRegion(v)) {
68 this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
69 }
70 for (node x : voronoi.nodesInRegion(w)) {
71 this->updateBestCenter(x, center, minCost, uDistance, vDistance, wDistance);
72 }
73 this->checkAndGenerateFunction(u, v, w, center, minCost, pred, isTerminal,
74 generateFunction);
75 });
76 }
77};
78
79}
80}
Definition of ogdf::steiner_tree::Full3ComponentGeneratorModule class template.
Includes declaration of graph class.
Definition of ogdf::Voronoi class template.
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
Computes Voronoi regions in an edge-weighted graph.
Definition Voronoi.h:49
const ArrayBuffer< node > & nodesInRegion(node v) const
Returns the list of nodes in the Voronoi region of node v.
Definition Voronoi.h:93
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
Interface for full 3-component generation including auxiliary functions.
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 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
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
Full 3-component generation using Voronoi regions.
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.