[−][src]Struct radiate::models::evtree::node::Node
a Node struct to represent a bidirectional binary tree holding pointers to the parent and two children, the left and right child The node also holds an input size which is the expected size of the input vector for the neural network held within the node. The output represetns the postion of the node, meaning that if it is a leaf, it will return the output from a get output function
Fields
parent: *mut Node
left_child: *mut Node
right_child: *mut Node
neural_network: NeuralNetwork
input_size: i32
output: u8
Methods
impl Node
[src]
implement the node
pub fn new(input_size: i32, output_options: &Vec<i32>) -> Self
[src]
create a new node with a given input size and a list of possible output options
From the list of output_options the node will choose an output, from the input_size the node will create a randomly generated neural network.
pub fn as_mut_ptr(self) -> *mut Node
[src]
return a node as a raw mutable pointer to a node this is a safe function however dereferencing the output is not also creating a box and putting it into raw includes a small amount of overhead
pub fn check_left_child(&self, node: &Node) -> bool
[src]
return true if this node is the left child of it's parent, false if not
pub fn check_right_child(&self, node: &Node) -> bool
[src]
return true if this node is the right child of it's parent, false if not
pub fn is_leaf(&self) -> bool
[src]
return true if this node has no children, meaning it has no children. A node that is a leaf is the only node which can return an output.
pub fn has_left_child(&self) -> bool
[src]
return true if this node has a valid left child and is not pointing to a null pointer
pub fn has_right_child(&self) -> bool
[src]
return true if this node has a valid right child and is not pointing to a null pointer
pub fn has_parent(&self) -> bool
[src]
return true if this node has a parent, false if not. If it does not, then this node is the root of the tree.
pub fn height(&self) -> i32
[src]
return the height of this node recursivley
pub fn depth(&self) -> i32
[src]
return the depth of this node, meaning the number of levels down it is from the root of the tree, recrsive.
pub fn size(&self) -> i32
[src]
return the size of the subtree recrusivley.
pub fn copy(&self) -> Node
[src]
Return a thin copy of this node, meaning keep all information besides the family pointers, these are nulled-out in order to avoid dangling or circular references.
pub fn deepcopy(&self) -> *mut Node
[src]
deep copy this node and it's subnodes. Recursivley traverse the tree in order and thin copy the current node, then assign it's surroudning pointers recrusivley.
pub unsafe fn insert_random(
&mut self,
input_size: i32,
output_options: &Vec<i32>
)
[src]
&mut self,
input_size: i32,
output_options: &Vec<i32>
)
Unsafe function.
Randomly insert a random node into the tree. Choose a boolean value randomly and recurse the tree until a null_mut() pointer is found, then insert a new node.
pub fn display(&self, level: i32)
[src]
Recrusively display the node and it's subnodes Useful for visualizing the strucutre of the tree and debugging. Level is the depth of the tree, at the root it should be 0.
Trait Implementations
impl Debug for Node
[src]
implement debut for the node to give a little more information for the node and make it easier to trace through a tree when a tree is displayed
impl Display for Node
[src]
implemented a display function for the node to display a simple representation of the node
impl Drop for Node
[src]
This will recursivley drop all nodes in this node's subree. These are made out of raw pointers so they need to be dropped manually
impl PartialEq<Node> for Node
[src]
impl Send for Node
[src]
impl StructuralPartialEq for Node
[src]
impl Sync for Node
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Type for T
[src]
const METATYPE: MetaType
[src]
type Meta = Concrete
Type of metadata for type.
fn meta(self: *const T) -> <T as Type>::Meta
[src]
fn data(self: *const T) -> *const ()
[src]
fn data_mut(self: *mut T) -> *mut ()
[src]
fn dangling(_t: <T as Type>::Meta) -> NonNull<T>
[src]
fn fatten(thin: *mut (), _t: <T as Type>::Meta) -> *mut T
[src]
fn meta_type(self: *const Self) -> MetaType
[src]
impl<T> Type for T where
T: ?Sized,
[src]
T: ?Sized,
default fn meta(self: *const T) -> <T as Type>::Meta
[src]
default fn data(self: *const T) -> *const ()
[src]
default fn data_mut(self: *mut T) -> *mut ()
[src]
default fn dangling(t: <T as Type>::Meta) -> NonNull<T>
[src]
default fn fatten(thin: *mut (), t: <T as Type>::Meta) -> *mut T
[src]
const METATYPE: MetaType
[src]
type Meta: 'static
fn meta_type(self: *const Self) -> MetaType
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,