MayaFlux 0.5.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 410 of file ProximityGraphs.cpp.

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

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

Referenced by generate_proximity_graph().

+ Here is the caller graph for this function: