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

◆ apply_edges()

void MayaFlux::Kinesis::Stochastic::Weights::apply_edges ( std::span< const std::pair< size_t, size_t > >  edges,
double  weight = 1.0,
bool  symmetric = true,
bool  normalize = true 
)
inlinenoexcept

Write an adjacency edge list into this table.

Parameters
edgesIndex pairs, the same shape Kinesis::EdgeList is (Spatial::ProximityGraphs' sequential_chain(), k_nearest_neighbors(), minimum_spanning_tree(), and so on all return one)
weightValue written at each edge
symmetricWhen true (the default), also writes the reverse direction for every edge, matching an undirected graph. Some EdgeList producers (k_nearest_neighbors, nearest_neighbor_graph) are already directed; pass false for those.
normalizeWhen true (the default), every row touched by an edge is normalized afterward, so the result is directly usable as a transition table.
Note
An index outside this table's bounds is skipped rather than trusted, since edges typically comes from an external computation over a possibly different point count.

Definition at line 224 of file Weights.hpp.

226 {
227 for (const auto& [a, b] : edges) {
228 if (a < m_rows && b < m_cols) {
229 (*this)(a, b) = weight;
230 }
231 if (symmetric && b < m_rows && a < m_cols) {
232 (*this)(b, a) = weight;
233 }
234 }
235 if (normalize) {
236 for (size_t i = 0; i < m_rows; ++i) {
237 normalize_row(i);
238 }
239 }
240 }
size_t a
double weight
size_t b
void normalize_row(size_t row) noexcept
Scale a row so its cells sum to one.
Definition Weights.hpp:174

References a, b, m_cols, m_rows, normalize_row(), and weight.

+ Here is the call graph for this function: