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

◆ gabriel_graph()

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 161 of file ProximityGraphs.cpp.

162{
163 Eigen::Index n = points.cols();
164 if (n < 2) {
165 return {};
166 }
167
168 EdgeList edges;
169
170 for (Eigen::Index i = 0; i < n; ++i) {
171 for (Eigen::Index j = i + 1; j < n; ++j) {
172 Eigen::VectorXd p = points.col(i);
173 Eigen::VectorXd q = points.col(j);
174
175 double pq_dist_sq = distance_squared(p, q);
176 bool is_gabriel_edge = true;
177
178 for (Eigen::Index k = 0; k < n; ++k) {
179 if (k == i || k == j)
180 continue;
181
182 Eigen::VectorXd r = points.col(k);
183
184 double pr_dist_sq = distance_squared(p, r);
185 double qr_dist_sq = distance_squared(q, r);
186
187 if (pr_dist_sq + qr_dist_sq < pq_dist_sq) {
188 is_gabriel_edge = false;
189 break;
190 }
191 }
192
193 if (is_gabriel_edge) {
194 edges.emplace_back(static_cast<size_t>(i), static_cast<size_t>(j));
195 }
196 }
197 }
198
199 MF_DEBUG(Journal::Component::Kinesis, Journal::Context::Runtime,
200 "gabriel_graph: {} points, generated {} edges",
201 n, edges.size());
202
203 return edges;
204}
#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: