Spine of a caterpillar tree (source code)

= Spine of a caterpillar tree

The spine of a <caterpillar tree>, in the pruned-spine convention, is the induced subgraph on its non-leaf vertices. It is obtained by deleting every degree-one vertex once, simultaneously. For a caterpillar it is a path or a single vertex; in the two-vertex case it is empty. A one-vertex tree can be handled as a single-vertex spine.

For a path on five vertices $1-2-3-4-5$, the pruned spine is $2-3-4$. For a star with at least three vertices it is the hub alone. Every other vertex is a leaf attached to this linear backbone, explaining the caterpillar shape.

Some descriptions call an extended path containing all non-leaf vertices a spine as well; such an extension can include endpoint leaves and need not be unique. The pruned convention fixes the canonical core. Repeatedly deleting leaves until only a center remains is a different operation: doing that to an arbitrary tree does not test whether its one-step pruned core was a path.