Skip to main content

umap_compute_weights

Function umap_compute_weights 

Source
pub fn umap_compute_weights(
    graph: &Graph,
    distances: Option<&[f64]>,
) -> IgraphResult<Vec<f64>>
Expand description

Compute UMAP weights from edge distances.

For each vertex, finds rho (minimum distance) and sigma (scale factor), then converts distances to exponentially decaying weights. Symmetrizes via fuzzy union: W = W1 + W2 - W1 * W2.

§Arguments

  • graph — input graph (may be directed for kNN graphs).
  • distances — per-edge distances. If None, all edges get weight 1.

Returns a weight vector of length ecount.

§Examples

use rust_igraph::{Graph, umap_compute_weights};

let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
let w = umap_compute_weights(&g, Some(&[1.0, 2.0])).unwrap();
assert_eq!(w.len(), 2);
assert!(w.iter().all(|&v| v >= 0.0 && v <= 1.0));