o_O:
Your vertices function is printing the number of arguments you gave it: The @_ variable is the list of arguments passed to your subroutine. Since you pass it $root, you'll always get 1 for the result.
You either need to expand the tree into the list of vertices and pass that list to the vertices subroutine, or have the vertices subroutine traverse the tree and keep count.
You haven't shown the code for the XX_order subroutines, but based on the rest of your code, you could simply replace the print statement with an increment to get the vertex count.
Show a bit more of your code and we can give you a little more help.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: program that counts all the vertices in a given tree
by roboticus
in thread program that counts all the vertices in a given tree
by o_0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |