/// Select based on generated calls and relations.
Select based on generated calls and relations.
Select based on generated calls and relations .
pub fn select_with_relation(ctx: &Context, rng: &mut RngType) -> Option<SyscallId> {
    let mut candidates: HashMap<SyscallId, Weight> = HashMap::new();
    let r = ctx.relation().inner.read().unwrap();
    let calls = ctx.calls();
    for sid in calls.iter().map(|c| c.sid()) {
        for candidate in r.influence_of(sid).iter().copied() {
            let entry = candidates.entry(candidate).or_default();
            *entry += 1;
        }
    }
    let candidates: Vec<(SyscallId, Weight)> = candidates.into_iter().collect();
    candidates
        .choose_weighted(rng, |candidate| candidate.1)
        .ok()
        .map(|candidate| candidate.0)
}
pub fn select_with_relation ( ctx : & Context , rng : & mut RngType ) -> Option < SyscallId > { let mut candidates : HashMap < SyscallId , Weight > = HashMap :: new ( ) ; let r = ctx . relation ( ) . inner . read ( ) . unwrap ( ) ; let calls = ctx . calls ( ) ; for sid in calls . iter ( ) . map ( | c | c . sid ( ) ) { for candidate in r . influence_of ( sid ) . iter ( ) . copied ( ) { let entry = candidates . entry ( candidate ) . or_default ( ) ; * entry += 1 ; } } let candidates : Vec < ( SyscallId , Weight ) > = candidates . into_iter ( ) . collect ( ) ; candidates . choose_weighted ( rng , | candidate | candidate . 1 ) . ok ( ) . map ( | candidate | candidate . 0 ) }
Select based on generated calls and relations.
Select based on generated calls and relations .
ctx
&Context
rng
&mut RngType