fn group_cowedges(
        ctx: &ContextHandle,
        cowedge_ids: &[AtomId],
    ) -> Result<Vec<Vec<AtomId>>, AcesError> {
        if cowedge_ids.len() < 2 {
            if cowedge_ids.is_empty() {
                Err(AcesErrorKind::IncoherencyLeak.with_context(ctx))
            } else {
                Ok(vec![cowedge_ids.to_vec()])
            }
        } else {
            let mut cotip_map: BTreeMap<DotId, Vec<AtomId>> = BTreeMap::new();

            for &cowedge_id in cowedge_ids.iter() {
                let context = ctx.lock().unwrap();
                let cowedge = context.get_wedge(cowedge_id).ok_or_else(|| {
                    AcesErrorKind::WedgeMissingForId(cowedge_id).with_context(ctx)
                })?;
                let cotip_id = cowedge.get_tip_id();

                match cotip_map.entry(cotip_id) {
                    btree_map::Entry::Vacant(entry) => {
                        entry.insert(vec![cowedge_id]);
                    }
                    btree_map::Entry::Occupied(mut entry) => {
                        let sids = entry.get_mut();

                        if let Err(pos) = sids.binary_search(&cowedge_id) {
                            sids.insert(pos, cowedge_id);
                        } else {
                            warn!(
                                "Multiple occurrences of {} in cowedge array",
                                cowedge.format_locked(&context)?
                            );
                        }
                    }
                }
            }

            Ok(cotip_map.into_iter().map(|(_, v)| v).collect())
        }
    }
/// Given a flat list of co-wedges, groups them by their tip dots
/// (i.e. by the arms of the considered wedge), and returns a
/// vector of vectors of [`AtomId`]s.
///
/// The result, if interpreted in terms of SAT encoding, is a
/// conjunction of exclusive choices of co-wedges.
// FIXME define `struct Cowedges`, grouped on demand
Given a flat list of co-wedges, groups them by their tip dots
, and returns a
vector of vectors of [`AtomId`]s.

The result, if interpreted in terms of SAT encoding, is a
conjunction of exclusive choices of co-wedges.
FIXME define `struct Cowedges`, grouped on demand
Given a flat list of co - wedges groups them by their tip dots and returns a vector of vectors of [ ` AtomId ` ] s . The result if interpreted in terms of SAT encoding is a conjunction of exclusive choices of co - wedges . FIXME define ` struct Cowedges ` grouped on demand
fn group_cowedges(
        ctx: &ContextHandle,
        cowedge_ids: &[AtomId],
    ) -> Result<Vec<Vec<AtomId>>, AcesError> {
        if cowedge_ids.len() < 2 {
            if cowedge_ids.is_empty() {
                Err(AcesErrorKind::IncoherencyLeak.with_context(ctx))
            } else {
                Ok(vec![cowedge_ids.to_vec()])
            }
        } else {
            let mut cotip_map: BTreeMap<DotId, Vec<AtomId>> = BTreeMap::new();
            for &cowedge_id in cowedge_ids.iter() {
                let context = ctx.lock().unwrap();
                let cowedge = context.get_wedge(cowedge_id).ok_or_else(|| {
                    AcesErrorKind::WedgeMissingForId(cowedge_id).with_context(ctx)
                })?;
                let cotip_id = cowedge.get_tip_id();
                match cotip_map.entry(cotip_id) {
                    btree_map::Entry::Vacant(entry) => {
                        entry.insert(vec![cowedge_id]);
                    }
                    btree_map::Entry::Occupied(mut entry) => {
                        let sids = entry.get_mut();
                        if let Err(pos) = sids.binary_search(&cowedge_id) {
                            sids.insert(pos, cowedge_id);
                        } else {
                            warn!(
                                "Multiple occurrences of {} in cowedge array",
                                cowedge.format_locked(&context)?
                            );
                        }
                    }
                }
            }
            Ok(cotip_map.into_iter().map(|(_, v)| v).collect())
        }
    }
fn group_cowedges ( ctx : & ContextHandle , cowedge_ids : & [ AtomId ] , ) -> Result < Vec < Vec < AtomId > > , AcesError > { if cowedge_ids . len ( ) < 2 { if cowedge_ids . is_empty ( ) { Err ( AcesErrorKind :: IncoherencyLeak . with_context ( ctx ) ) } else { Ok ( vec ! [ cowedge_ids to_vec ( ) ] ) } } else { let mut cotip_map : BTreeMap < DotId , Vec < AtomId > > = BTreeMap :: new ( ) ; for & cowedge_id in cowedge_ids . iter ( ) { let context = ctx . lock ( ) . unwrap ( ) ; let cowedge = context . get_wedge ( cowedge_id ) . ok_or_else ( | | { AcesErrorKind :: WedgeMissingForId ( cowedge_id ) . with_context ( ctx ) } ) ? ; let cotip_id = cowedge . get_tip_id ( ) ; match cotip_map . entry ( cotip_id ) { btree_map :: Entry :: Vacant ( entry ) => { entry . insert ( vec ! [ cowedge_id ] ) ; } btree_map :: Entry :: Occupied ( mut entry ) => { let sids = entry . get_mut ( ) ; if let Err ( pos ) = sids . binary_search ( & cowedge_id ) { sids . insert ( pos , cowedge_id ) ; } else { warn ! ( " " cowedge format_locked ( context ) ) ; } } } } Ok ( cotip_map . into_iter ( ) . map ( | ( _ , v ) | v ) . collect ( ) ) } }
Given a flat list of co-wedges, groups them by their tip dots
(i.e.
Given a flat list of co - wedges groups them by their tip dots ( i . e .
ctx
&ContextHandle
cowedge_ids
&[AtomId]
ctx
&ContextHandle
cowedge_ids
&[AtomId]