pub trait Node {
type Value;
// Required methods
fn value(&self) -> &Self::Value;
fn value_mut(&mut self) -> &mut Self::Value;
fn node_type(&self) -> NodeType;
fn arity(&self) -> Arity;
}Expand description
Node is a trait that abstracts out common information and behavior needed within the GraphNode and TreeNode implementations. Both these nodes handle their connections differently, but they share this common interface. Within this crate, we also handle these data structures a little differently than they would usually be defined, so we leave the core implementation up to the struct, and allow this trait to supply the ‘radiate’ interface for working with nodes.
Required Associated Types§
Required Methods§
Sourcefn node_type(&self) -> NodeType
fn node_type(&self) -> NodeType
Get the NodeType of the node. As previously mentioned, if the NodeType is not supplied
during creation, this value is determined by the node’s relationship to the rest of
the structure holding it. IE, a GraphNode with 0 incoming connections is likely an Input,
while a TreeNode with 0 children is likely a Leaf.
Sourcefn arity(&self) -> Arity
fn arity(&self) -> Arity
Get the arity of the node, which is the number of incoming connections it can have. In a genetic programming sense, this is the number of allowed inputs for a node. In a Graph, this is the number of allowed incoming connections while for a Tree, this is the number of children it is allowed to have.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".