Skip to main content

default_weight_fn

Function default_weight_fn 

Source
pub fn default_weight_fn(_from: i64, _to: i64, _edge_data: &Value) -> f64
Expand description

Default weight function that returns 1.0 for all edges.

Use this for unweighted DAGs where edge weights don’t matter. The critical path will be the longest path in terms of hop count.

§Example

use sqlitegraph::{SqliteGraph, algo::critical_path::{critical_path, default_weight_fn}};

let graph = SqliteGraph::open_in_memory()?;
// ... build unweighted DAG ...

let result = critical_path(&graph, &default_weight_fn)?;
println!("Critical path has {} hops", result.distance as i64);