In a homework exercise for a QFT course I'm taking, we have been tasked with calculating the integral
$$ Z(g)=\int_{-\infty}^{+\infty} dx\, e^{-\frac{1}{2}x^2 + \frac{g}{3!}x^3} $$
up to order $g^4$ by using Feynman diagrams.
I have followed a method loosely outlined in the book Quantum Field Theory in a Nutshell, 2nd Edition. What I have done is to extend $Z$ to be a function of both $g$ and an auxiliary variable $J$, as follows:
$$ Z(g,J)=\int_{-\infty}^{+\infty} dx\, e^{-\frac{1}{2}x^2 + \frac{g}{N!}x^N + Jx} $$
(here I also used $N$ instead of 3 to make the calculations more generic, which I find makes it easier to track where different factors in the final expression comes from). I then used a trick to express each partial derivative $\partial_g^i J(g,J)$ as $(\partial_J^N/N!)^i J(g,J)$, by realizing that $\partial_g$ and $\partial_J$ have very similar effects on $J(g,J)$. This makes it possible to Taylor expand in $g$ around $g=0$ with no $x^N$ term in the exponent, which leads to a Taylor expansion where each term is a power of $\partial_J$ times a Gaussian integral containing $J$. Solving the integral and further expanding by using the series expansion of $e^x$ eventually leads to the expression
$$ \tag{*}\label{*} Z(g,J)=\sqrt{2\pi}\sum_{V=0}^\infty \sum_{E=0}^\infty \frac{(2E)!}{(N!)^V 2^E V!\,E!\,T!}\, g^V J^T, $$
where $T=2E-NV$, such that $V$, $E$ and $T$ can be interpreted as the number of "internal vertices," "edges," and "terminal points" or "external vertices" (a.k.a. "external edges"), respectively, of a diagram, where each internal vertex connects to exactly $N$ vertices (where self-loops are counted twice) and each external vertex connects to exactly 1 edge (that doesn't self-loop). (For $Z(g)=Z(g,0)$, we are only interested in the terms that are of order $0$ in $J$, i.e., the diagrams that have no external vertices, so that $T=0$, but let's ignore that for now.) I have then come up with the following Feynman rules for the diagrams:
Each internal vertex has a factor $g$,
Each external vertex has a factor $J$,
The symmetry factor for a diagram with adjacency matrix $A$ (including both internal and external vertices) is $$ S=\left|\operatorname{Aut}(A)\right|\,\prod_{i=1}^{V+T}\prod_{j=i}^{V+T}A_{ij}!, $$ where $\operatorname{Aut}(A)$ is the graph automorphism group of the graph with adjacency matrix $A$, and
The value of the diagram is the product of all vertex factors, both internal and external, divided by the diagram's symmetry factor.
Finding all diagrams that have $E$ edges, $V$ internal vertices (which connect to $N$ edges each; self-loops are counted twice) and $T=2E-NV$ external edges (which connect to exactly one edge each, which doesn't self-loop), calculating the value of each diagram and adding them together, should give the value of the corresponding term in the double series in $\eqref{*}$ (neglecting the factor $\sqrt{2\pi}$ before the summation signs).
My question is: Is the formula I have arrived at for calculating the symmetry factor $S$ correct? I derived it by reasoning, but since the derivation was a bit tricky, maybe I have made some mistake along the way. So, does this look correct? How do you calculate the symmetry factor "properly"?