Let us only be interested in simple undirected graphs.
Find the number of all graphs of $N$ vertices, where exactly one vertex has degree $N - 1$. For example $f(3) = 3, f(4) = 16$.
My idea is: let us know the answer for a fixed vertex number one $V_1$, provided that it is connected to all the others $p_1(N)$, then $f(N) = N * p_1(N)$. So now we should add a new one vertex and count $p_1(N + 1)$. We should connect $V_{N + 1}$ and $V_1$ to hold the task condition, now it's possible to connect new vertex with another N - 1 in different combinations, except only one case, when $V_{N + 1}$ connected with all others, total number is $\sum_{k=0}^{n-2} \binom{n - 1}{k}$. But with the addition of a new vertex, there are cases when some of the vertices $V_2, V_3, ..., V_N$ can now be connected to each other and not included in $p_1(N)$, I don't know how to count such cases.
Are there any other ideas?
P.S. time complexity should be not greater than $O(N^2)$