For the number of paths with exactly $n$ hops from one node to another in a $k$ node fully connected graph, we get the following recurrence:
$$g_n=(k-2)g_{n-1}+(k-1)g_{n-2}$$
With $g_1=1$, $g_0=0$ and $g_m=0 \;\; \forall \;\; m<0$.
Is there a way to get a closed form for this recurrence? For $k=3$, this yields the Jacobsthal numbers.
For future reference, this recurrence represents the number of paths from one node to another in a $k$ node fully connected undirected graph and has the solution:
$$g(n) = \frac{(k-1)^n-(-1)^n}{(k)}$$
My attempt:
Let's try to construct the generating function.
$$B(x)=\sum\limits_{n=0}^\infty g_n x^n$$
We get:
$$B(x) = \sum\limits_{n=0}^\infty ((k-2)g_{n-1}+(k-1)g_{n-2})x^n$$
$$=>B(x) = (k-2)x\sum\limits_{n=0}^\infty g_{n-1}x^{n-1}+(k-1)x^2\sum\limits_{n=0}^\infty g_{n-2}x^{n-2}$$ $$=(k-2)x B(x)+(k-1)x^2 B(x)$$
But this just makes $B(x)$ cancel out and we don't get an expression for it.