pub fn increase_space_density(&mut self, id: ID) -> Result<(ID, Vec<ID>, Vec<(ID, ID)>)> {
        if self.space_exists(id) {
            let space = self.spaces[&id].clone();
            let subs = self.dimensions + 1;
            let substates = space.state().subdivide(subs);
            let spaces = substates
                .iter()
                .map(|substate| Space::new(ID::new(), substate.clone()))
                .collect::<Vec<Space<S>>>();
            for s in &spaces {
                let id = s.id();
                self.spaces.insert(id, s.clone());
                self.graph.add_node(id);
                self.space_ids.insert(id);
            }
            for a in &spaces {
                let aid = a.id();
                for b in &spaces {
                    let bid = b.id();
                    if aid != bid {
                        self.graph.add_edge(aid, bid, ());
                    }
                }
            }
            let neighbors = self.graph.neighbors(id).collect::<Vec<ID>>();
            let pairs = neighbors
                .iter()
                .enumerate()
                .map(|(i, n)| {
                    let t = spaces[i].id();
                    self.graph.remove_edge(*n, id);
                    self.graph.add_edge(*n, t, ());
                    (*n, t)
                })
                .collect::<Vec<(ID, ID)>>();
            self.space_ids.remove(&id);
            self.spaces.remove(&id);
            let space_ids = spaces.iter().map(|s| s.id()).collect::<Vec<ID>>();
            Ok((id, space_ids, pairs))
        } else {
            Err(QDFError::SpaceDoesNotExists(id))
        }
    }
/// Increases given space density (subdivide space and rebind it properly to its neighbors),
/// and returns process information (source space id, subdivided space ids, connections pairs)
/// or throws error if space does not exists.
///
/// # Arguments
/// * `id` - space id.
///
/// # Returns
/// `Ok` with tuple of source space id, vector of subdivided space ids and vector of
/// connections pairs or `Err` if space does not exists.
///
/// # Examples
/// ```
/// use quantized_density_fields::QDF;
///
/// let (mut qdf, root) = QDF::new(2, 9);
/// let (_, subs, _) = qdf.increase_space_density(root).unwrap();
/// assert_eq!(subs.len(), 3);
/// ```
Increases given space density (subdivide space and rebind it properly to its neighbors),
and returns process information (source space id, subdivided space ids, connections pairs)
or throws error if space does not exists.
Increases given space density ( subdivide space and rebind it properly to its neighbors ) and returns process information ( source space id subdivided space ids connections pairs ) or throws error if space does not exists .
pub fn increase_space_density(&mut self, id: ID) -> Result<(ID, Vec<ID>, Vec<(ID, ID)>)> {
        if self.space_exists(id) {
            let space = self.spaces[&id].clone();
            let subs = self.dimensions + 1;
            let substates = space.state().subdivide(subs);
            let spaces = substates
                .iter()
                .map(|substate| Space::new(ID::new(), substate.clone()))
                .collect::<Vec<Space<S>>>();
            for s in &spaces {
                let id = s.id();
                self.spaces.insert(id, s.clone());
                self.graph.add_node(id);
                self.space_ids.insert(id);
            }
            for a in &spaces {
                let aid = a.id();
                for b in &spaces {
                    let bid = b.id();
                    if aid != bid {
                        self.graph.add_edge(aid, bid, ());
                    }
                }
            }
            let neighbors = self.graph.neighbors(id).collect::<Vec<ID>>();
            let pairs = neighbors
                .iter()
                .enumerate()
                .map(|(i, n)| {
                    let t = spaces[i].id();
                    self.graph.remove_edge(*n, id);
                    self.graph.add_edge(*n, t, ());
                    (*n, t)
                })
                .collect::<Vec<(ID, ID)>>();
            self.space_ids.remove(&id);
            self.spaces.remove(&id);
            let space_ids = spaces.iter().map(|s| s.id()).collect::<Vec<ID>>();
            Ok((id, space_ids, pairs))
        } else {
            Err(QDFError::SpaceDoesNotExists(id))
        }
    }
pub fn increase_space_density ( & mut self , id : ID ) -> Result < ( ID , Vec < ID > , Vec < ( ID , ID ) > ) > { if self . space_exists ( id ) { let space = self . spaces [ & id ] . clone ( ) ; let subs = self . dimensions + 1 ; let substates = space . state ( ) . subdivide ( subs ) ; let spaces = substates . iter ( ) . map ( | substate | Space :: new ( ID :: new ( ) , substate . clone ( ) ) ) . collect :: < Vec < Space < S > > > ( ) ; for s in & spaces { let id = s . id ( ) ; self . spaces . insert ( id , s . clone ( ) ) ; self . graph . add_node ( id ) ; self . space_ids . insert ( id ) ; } for a in & spaces { let aid = a . id ( ) ; for b in & spaces { let bid = b . id ( ) ; if aid != bid { self . graph . add_edge ( aid , bid , ( ) ) ; } } } let neighbors = self . graph . neighbors ( id ) . collect :: < Vec < ID > > ( ) ; let pairs = neighbors . iter ( ) . enumerate ( ) . map ( | ( i , n ) | { let t = spaces [ i ] . id ( ) ; self . graph . remove_edge ( * n , id ) ; self . graph . add_edge ( * n , t , ( ) ) ; ( * n , t ) } ) . collect :: < Vec < ( ID , ID ) > > ( ) ; self . space_ids . remove ( & id ) ; self . spaces . remove ( & id ) ; let space_ids = spaces . iter ( ) . map ( | s | s . id ( ) ) . collect :: < Vec < ID > > ( ) ; Ok ( ( id , space_ids , pairs ) ) } else { Err ( QDFError :: SpaceDoesNotExists ( id ) ) } }
Increases given space density (subdivide space and rebind it properly to its neighbors),
and returns process information (source space id, subdivided space ids, connections pairs)
or throws error if space does not exists.
Increases given space density ( subdivide space and rebind it properly to its neighbors ) and returns process information ( source space id subdivided space ids connections pairs ) or throws error if space does not exists .
&mut self
id
ID
`Ok` with tuple of source space id, vector of subdivided space ids and vector of
connections pairs or `Err` if space does not exists.
` Ok ` with tuple of source space id vector of subdivided space ids and vector of connections pairs or ` Err ` if space does not exists .
&mut self
id
ID
examples
```
use quantized_density_fields::QDF.


` ` ` use quantized_density_fields :: QDF .