use structops::soft_shortest_path::{soft_shortest_path_edge_marginals, Edge};
fn main() {
let edges = [
Edge {
from: 0,
to: 1,
cost: 1.0,
},
Edge {
from: 1,
to: 3,
cost: 1.0,
},
Edge {
from: 0,
to: 2,
cost: 3.0,
},
Edge {
from: 2,
to: 3,
cost: 3.0,
},
];
let gamma = 0.5;
let (value, p) = soft_shortest_path_edge_marginals(4, &edges, gamma).unwrap();
println!("soft shortest-path value = {value}");
for (k, pe) in p.iter().enumerate() {
let e = edges[k];
println!(
"edge {} ({}->{}, cost={}): marginal p(e in path) = {}",
k, e.from, e.to, e.cost, pe
);
}
}