This is a fairly typical example of the DP-on-tree paradigm. Let me generalize the problem a bit by resolving the specification of the root vertex v and stratifying the calculations of small boundaries in two ways: whether v is inclusive and how many edges the boundary contains.
The base case is simple. There are no edges and, therefore, two subtrees: one includes v, the other excludes v, and both have no boundaries. Otherwise, let e = {v, w} be the edge incident to v. The instance is as follows.
|\ /| | \ e / | |L v-----w R| | / \ | |/ \|
Calculate the recursively stratified counts for L embedded in v and R embedded in w.
Subdirs containing v consist of a subtree in L, which includes v, plus optionally e, and a subtree in R, which includes w. Subtrees that do not include v consist of either a subtree in L that does not include v or a subtree in R (double counting an empty tree). This means that we can get stratified counts by convolving stratified counts for L with stratified counts for R.
Here's how it works in your example. Choose root 1.
e 1---2---3
We choose e, as shown and recursively.
1
The vector for include-1 is [1], since one subtree is {1}, without a border. The vector for exceptions-1 is [1], since one subtree {} also has no boundary.
2
We calculate 2 and 3, as in case 1. The vector for inclusion-2 is [1, 1], since {2, 3} has no boundary edges, and {2} has one. We got this vector by adding the inclusion vector-2 for 2, shifted by one due to the new boundary edge, to make [0, 1], the convolution of the inclusion vector-2 for 2 with the inclusion vector-3 for 3, which is [1 , 0]. The vector for exceptions-2 is [1] + [1, 1] - [1] = [1, 1], where [1, 1] is the sum of the shifted vector of include-3 and the vector of exceptions-3, and the subtraction should compensate double counting {}.
Now, for the original call, to get the vector include-1, add [0, 1], including-1 vector for 1 shifted by one, to convolution [1] with [1, 1], getting [1, 2]. To check: {1, 2, 3} has no boundary, and {1} and {1, 2} have one boundary edge. The vector of exceptions-1 is [1] + [1, 2, 1] - [1] = [1, 2, 1]. To check: {} has no boundary, {2, 3} and {3} have one boundary edge, and {2} has two boundary edges.