[][src]Struct radiate::models::evtree::node::Node

pub struct Node {
    pub parent: *mut Node,
    pub left_child: *mut Node,
    pub right_child: *mut Node,
    pub neural_network: NeuralNetwork,
    pub input_size: i32,
    pub output: u8,

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


parent: *mut Nodeleft_child: *mut Noderight_child: *mut Nodeneural_network: NeuralNetworkinput_size: i32output: u8


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>

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

impl RefUnwindSafe for Node

impl Unpin for Node

impl UnwindSafe for Node

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Type for T[src]

type Meta = Concrete

Type of metadata for type.

impl<T> Type for T where
    T: ?Sized

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,