/// <summary> /// Gets a string representation of the tree using the specified traversal method and a specified separator. /// </summary> /// <param name="traversalMethod">The traversal method to use.</param> /// <param name="separator">The separator used in the output.</param> /// <returns>The traversed data in the tree as string.</returns> public virtual string ToString(TreeTraversalMethods traversalMethod, string separator) { string results = String.Empty; switch (traversalMethod) { case TreeTraversalMethods.Preorder: results = PreorderTraversal(_root, separator); break; case TreeTraversalMethods.Inorder: results = InorderTraversal(_root, separator); break; case TreeTraversalMethods.Postorder: results = PostorderTraversal(_root, separator); break; } // finally, hack off the last separator if (results.Length == 0) { return(String.Empty); } else { return(results.Substring(0, results.Length - separator.Length)); } }
/// <summary> /// Gets a string representation of the tree using the specified traversal method and a space separator. /// </summary> /// <param name="traversalMethod">The traversal method to use.</param> /// <returns>The traversed data in the tree as string.</returns> public virtual string ToString(TreeTraversalMethods traversalMethod) { return(ToString(traversalMethod, " ")); }
/// <summary> /// Gets a string representation of the tree using the specified traversal method and a space separator. /// </summary> /// <param name="traversalMethod">The traversal method to use.</param> /// <returns>The traversed data in the tree as string.</returns> public virtual string ToString(TreeTraversalMethods traversalMethod) { return ToString(traversalMethod, " "); }
/// <summary> /// Gets a string representation of the tree using the specified traversal method and a specified separator. /// </summary> /// <param name="traversalMethod">The traversal method to use.</param> /// <param name="separator">The separator used in the output.</param> /// <returns>The traversed data in the tree as string.</returns> public virtual string ToString(TreeTraversalMethods traversalMethod, string separator) { string results = String.Empty; switch (traversalMethod) { case TreeTraversalMethods.Preorder: results = PreorderTraversal(_root, separator); break; case TreeTraversalMethods.Inorder: results = InorderTraversal(_root, separator); break; case TreeTraversalMethods.Postorder: results = PostorderTraversal(_root, separator); break; } // finally, hack off the last separator if (results.Length == 0) return String.Empty; else return results.Substring(0, results.Length - separator.Length); }
public IList <IVertex <T> > Traversal(TreeTraversalMethods direction, T root) { throw new NotImplementedException(); }