According to a note for OEIS A052987: "Form the graph with matrix $A=[1,1,1,1;1,0,0,0;1,0,0,0;1,0,0,1]$. Then the sequence $1,1,2,4,\ldots$ with g.f. $(1-x-2x^2)/(1-2x-2x^2+2x^3)$ counts closed walks of length $n$ at the degree $3$ vertex.", if I understand correctly, all closed walks from node $4$ to itself for the graph:
are counted by the generating function:
$$g(x) = \frac{1-x-2x^2}{1-2x-2x^2+2x^3}$$
corresponding to the sequence $1,1,2,4,10,24,60,148,\ldots$ for $n=0,1,2,3,\ldots$
and I can verify the first terms. But how can we prove it? Is there a standard method for deriving that generating fuction? In particular, how can we get the generating function for the number of walks from node $3$ to itself for the following graph:
and in general for a graph of the following form, for a walk from $k$ to itself:



The standard method relies on two facts: (1) The number of length $k$ walks from vertex $i$ to $j$ is given by $(A^k)_{ij}$ (Why? Think in particular about the cases of $k=1$ and $k=2$); and (2) the identity $$\sum_{k\ge0}(A^k)_{ij}z^k =\Bigl(\sum_{k\ge0}A^kz^k\Bigr)_{ij} =\bigl((I-Az)^{-1}\bigr)_{ij},$$ where $I$ denotes the identity matrix of the appropriate size.
For the example you give, we are interested in $\bigl((I-Az)^{-1}\bigr)_{44}$, where $$A=\begin{pmatrix} 1&1&1&1\\ 1&0&0&0\\ 1&0&0&0\\ 1&0&0&1 \end{pmatrix}.$$ Using Cramer's rule to invert the matrix, we are looking for $\operatorname{adj}(I-Az)_{44}/\det(I-Az)$. Since $\det(I-Az)=1-2z-2z^2+2z^3$ and $$\operatorname{adj}(I-Az)_{44}=\det\begin{pmatrix} 1-z&-z&-z\\ -z&1&0\\ -z&0&1 \end{pmatrix} =1-z-2z^2,$$ the result follows.