A leaf of an unrooted tree is a node of vertex degree 1. Note that for a rooted or planted tree, the root vertex is generally not considered a leaf node, whereas all other nodes of degree 1 are.
A function to return the leaves of a tree may be implemented in a future version of the Wolfram Language as LeafVertex[g].
The following tables gives the total numbers of leaves for various classes of graphs on , 2, ... nodes. Note that for rooted and planted trees, the root vertex is generally not counted as a leaf, even if it has vertex degree 1.
graph type | OEIS | leaf count for , 2, ... nodes |
graph | A055540 | 0, 2, 4, 14, 38, 153, 766, 6259, 88064, ... |
labeled graph | A095338 | 0, 2, 12, 96, 1280, 30720, ... |
labeled tree | A055541 | 0, 2, 6, 36, 320, 3750, ... |
planted tree | A003227 | 0, 1, 1, 3, 8, 22, 58, 160, 434, 1204, 3341, 9363, ... |
planted tree including root nodes | A095339 | 0, 2, 2, 5, 12, 31, 78, 208, 549, 1490, 4060, 11205, ... |
rooted tree | A003227 | 0, 1, 1, 3, 8, 22, 58, 160, 434, 1204, 3341, 9363, ... |
rooted tree including degree-1 root nodes | A095337 | 0, 2, 4, 10, 26, 67, 180, 482, 1319, 3627, 10082, 28150, ... |
tree | A003228 | 0, 2, 2, 5, 9, 21, 43, 101, ... |