Accord.Genetic.GPTreeNode.ToString C# (CSharp) Method

ToString() public method

Get string representation of the node.

String representation of the node lists all node's children and then the node itself. Such node's string representations equals to its reverse polish notation.

For example, if nodes value is '+' and its children are '3' and '5', then nodes string representation is "3 5 +".

public ToString ( ) : string
return string
        public override string ToString( )
        {
            StringBuilder sb = new StringBuilder( );

            if ( Children != null )
            {
                // walk through all nodes
                foreach ( GPTreeNode node in Children )
                {
                    sb.Append( node.ToString( ) );
                }
            }

            // add gene value
            sb.Append( Gene.ToString( ) );
            sb.Append( " " );

            return sb.ToString( );
        }

Usage Example

コード例 #1
0
 /// <summary>
 /// Get string representation of the chromosome by providing its expression in
 /// reverse polish notation (postfix notation).
 /// </summary>
 ///
 /// <returns>Returns string representation of the genetic tree.</returns>
 ///
 /// <remarks><para>The method returns string representation of the tree's root node
 /// (see <see cref="GPTreeNode.ToString"/>).</para></remarks>
 ///
 public override string ToString()
 {
     return(root.ToString());
 }