Struct evosim::blob::geno_blob_builder::QuadTree
source · pub struct QuadTree<T> {
pub nodes: Vec<Option<T>>,
pub max_depth: u32,
}
Expand description
QuadTree, Helper struct
Fields§
§nodes: Vec<Option<T>>
§max_depth: u32
Implementations§
source§impl<T> QuadTree<T>
impl<T> QuadTree<T>
pub fn new(max_depth: u32) -> Self
pub fn parent(&self, index: usize) -> Option<usize>
pub fn children(&self, index: usize) -> [usize; 4]
pub fn depth(&self, index: usize) -> u32
pub fn is_leaf(&self, index: usize) -> bool
pub fn clean_subtree(&mut self, index: usize)
pub fn clean_subtree_without_self(&mut self, index: usize)
sourcepub fn branch_nodes(&self) -> Vec<usize>
pub fn branch_nodes(&self) -> Vec<usize>
all nodes have at least one none
child, using for mutate to gain limb
sourcepub fn subtree_indices(&self, index: usize) -> Vec<usize>
pub fn subtree_indices(&self, index: usize) -> Vec<usize>
all the not-None indices of the subtree
pub fn child_direction(&self, index: usize) -> Option<usize>
pub fn is_empty(&self, index: usize) -> bool
sourcepub fn tree_edit_distance(&self, other: &QuadTree<T>) -> usize
pub fn tree_edit_distance(&self, other: &QuadTree<T>) -> usize
Calculates the Tree Edit Distance (TED) between two QuadTrees.
The Tree Edit Distance is a measure of the similarity between two trees, defined as the minimum cost sequence of node deletions, insertions, and substitutions that transform one tree into the other. This function uses dynamic programming to efficiently compute the TED between the current tree and another.
Parameters
other
: A reference to the otherQuadTree
with which the edit distance is to be calculated.
Returns
Returns a usize
representing the Tree Edit Distance between the two trees.
Examples
let tree1 = QuadTree::new(...);
let tree2 = QuadTree::new(...);
let distance = tree1.tree_edit_distance(&tree2);
fn _tree_edit_distance( &self, i: usize, j: usize, other: &QuadTree<T>, dp: &mut Vec<Vec<Option<usize>>> ) -> usize
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for QuadTree<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for QuadTree<T>where T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> RefUnwindSafe for QuadTree<T>where T: RefUnwindSafe,
impl<T> Send for QuadTree<T>where T: Send,
impl<T> Sync for QuadTree<T>where T: Sync,
impl<T> Unpin for QuadTree<T>where T: Unpin,
impl<T> UnwindSafe for QuadTree<T>where T: UnwindSafe,
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> Serialize for Twhere
T: Serialize + ?Sized,
impl<T> Serialize for Twhere T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.