Skip to main content

weighted_interval_scheduling

Function weighted_interval_scheduling 

Source
pub fn weighted_interval_scheduling(
    intervals: &[(f64, f64, f64)],
) -> (f64, Vec<usize>)
Expand description

The most valuable set of pairwise disjoint intervals.

Weights break the greedy argument completely – one long valuable interval can be worth more than any number of short ones – so this is a table: sort by finish time and, for each interval, either take it and jump to the last compatible one or skip it.

intervals[i] is (start, end, weight). Returns the total and the chosen indices.