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

◆ gabriel_graph()

MAYAFLUX_API EdgeList MayaFlux::Kinesis::gabriel_graph ( const Eigen::MatrixXd &  points)

Compute Gabriel graph.

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

Gabriel property: Edge (p,q) exists iff disk with diameter pq contains no other points. Subset of Delaunay triangulation.

The Gabriel graph is a proximity graph defined by the following rule: Two points p and q are connected if and only if the closed disk having the line segment pq as diameter contains no other points.

Equivalently: |p-r|² + |q-r|² ≥ |p-q|² for all r ∈ P \ {p,q}

Complexity: O(n³) with naive geometric tests

Definition at line 408 of file ProximityGraphs.cpp.

409{
410 const auto n = static_cast<size_t>(points.cols());
411 if (n < 2) {
412 return {};
413 }
414
415 const auto dim = static_cast<size_t>(points.rows());
416 const double* base = points.data();
417
418 const std::vector<double> table = build_distance_table(points);
419 const bool resident = !table.empty();
420
421 std::vector<EdgeList> bins(n);
422
423 std::for_each(std::execution::par_unseq,
424 std::views::iota(size_t { 0 }, n).begin(),
425 std::views::iota(size_t { 0 }, n).end(),
426 [&](size_t i) {
427 const double* row_i = resident ? table.data() + i * n : nullptr;
428 const double* pi = base + i * dim;
429 EdgeList& out = bins[i];
430
431 for (size_t j = i + 1; j < n; ++j) {
432 const double pq_sq = resident
433 ? row_i[j]
434 : dist_sq(pi, base + j * dim, dim);
435
436 const bool rejected = resident
437 ? sum_below(row_i, table.data() + j * n, n, pq_sq)
438 : sum_below_direct(base, dim, n, i, j, pq_sq);
439
440 if (!rejected) {
441 out.emplace_back(i, j);
442 }
443 }
444 });
445
446 EdgeList edges = flatten_bins(bins);
447
448 MF_DEBUG(Journal::Component::Kinesis, Journal::Context::Runtime,
449 "gabriel_graph: {} points, generated {} edges",
450 n, edges.size());
451
452 return edges;
453}
#define MF_DEBUG(comp, ctx,...)
std::vector< glm::vec2 > * points
std::vector< float > * out
std::vector< std::pair< size_t, size_t > > EdgeList

References MayaFlux::Journal::Kinesis, MF_DEBUG, out, points, and MayaFlux::Journal::Runtime.

Referenced by generate_proximity_graph().

+ Here is the caller graph for this function: