MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ relative_neighborhood_graph()

EdgeList MayaFlux::Kinesis::relative_neighborhood_graph ( const Eigen::MatrixXd &  points)

Compute relative neighborhood graph.

Parameters
pointsDxN matrix where each column is a point
Returns
Edge list of RNG edges

RNG property: Edge (p,q) exists iff lune(p,q) contains no points. Lune is intersection of two circles centered at p and q, each with radius |p-q|.

Equivalently: max(|p-r|, |q-r|) ≥ |p-q| for all r ∈ P \ {p,q}

The RNG is a subset of Gabriel graph and Delaunay triangulation.

Complexity: O(n³) with geometric tests

Definition at line 242 of file ProximityGraphs.cpp.

243{
244 Eigen::Index n = points.cols();
245 if (n < 2) {
246 return {};
247 }
248
249 EdgeList edges;
250
251 for (Eigen::Index i = 0; i < n; ++i) {
252 for (Eigen::Index j = i + 1; j < n; ++j) {
253 Eigen::VectorXd p = points.col(i);
254 Eigen::VectorXd q = points.col(j);
255
256 double pq_dist = distance(p, q);
257 bool is_rng_edge = true;
258
259 for (Eigen::Index k = 0; k < n; ++k) {
260 if (k == i || k == j)
261 continue;
262
263 Eigen::VectorXd r = points.col(k);
264
265 double pr_dist = distance(p, r);
266 double qr_dist = distance(q, r);
267
268 double max_dist = std::max(pr_dist, qr_dist);
269
270 if (max_dist < pq_dist) {
271 is_rng_edge = false;
272 break;
273 }
274 }
275
276 if (is_rng_edge) {
277 edges.emplace_back(static_cast<size_t>(i), static_cast<size_t>(j));
278 }
279 }
280 }
281
282 MF_DEBUG(Journal::Component::Kinesis, Journal::Context::Runtime,
283 "relative_neighborhood_graph: {} points, generated {} edges",
284 n, edges.size());
285
286 return edges;
287}
#define MF_DEBUG(comp, ctx,...)
double q

References MayaFlux::Journal::Kinesis, MF_DEBUG, q, and MayaFlux::Journal::Runtime.

Referenced by generate_proximity_graph().

+ Here is the caller graph for this function: