I'm trying to find the reasoning behind the following formula to determine the number of fused polygons $N$, which I found in my Organic Chemistry textbook:
$$S-A+1=N$$
where $S$ is the number of edges, and $A$ is the number of vertices.
I verified the above formula for different combinations of polygons, and it worked flawlessly in all cases I considered. The following image shows two of the different configurations I considered and the application of the above formula giving the corresponding number of fused polygons:
It works irrespective of the number of common edges. Is this formula an empirical (just based on observations) or is there any good reason behind it? Further, are there any exceptions to this formula?
Edit:
Example to address the comments below the question:
$30-24+1=7$


If there are holes, then the formula does not hold as I've already commented.
Without holes, the formula holds.
In the following, let us consider fused polygons without holes.
The reason why the formula holds is that if you add a new hexagon to fused polygons, then the following relation $$(\text{the number of the added edges})-(\text{the number of the added vertices})=1$$ holds.
One can prove that the formula holds by induction on the number of polygons.
Proof :
If we consider one hexagon, then $S=A=6$, so $S-A+1=N$ holds.
Suppose that $S_F-A_F+1=N$ holds in the fused polygons $F$.
Case 1 : If you add one hexagon $H$ to $F$ where $H$ and $F$ has exactly one common edge, then in the new polygons $F'$, we have $$N_{F'}=N+1,\quad S_{F'}=S_F+5,\quad A_{F'}=A_F+4$$So, we see that $S_{F'}-A_{F'}+1=N_{F'}$ holds.
Case 2 : If you add one hexagon $H$ to $F$ where $H$ and $F$ has exactly two common edges (note that the two edges have to be adjacent), then in the new polygons $F'$, we have $$N_{F'}=N+1,\quad S_{F'}=S_F+4,\quad A_{F'}=A_F+3$$So, we see that $S_{F'}-A_{F'}+1=N_{F'}$ holds.
Case 3 : If you add one hexagon $H$ to $F$ where $H$ and $F$ has exactly three common edges (note that the three edges have to be adjacent), then in the new polygons $F'$, we have $$N_{F'}=N+1,\quad S_{F'}=S_F+3,\quad A_{F'}=A_F+2$$So, we see that $S_{F'}-A_{F'}+1=N_{F'}$ holds.
Case 4 : If you add one hexagon $H$ to $F$ where $H$ and $F$ has exactly four common edges (note that the four edges have to be adjacent), then in the new polygons $F'$, we have $$N_{F'}=N+1,\quad S_{F'}=S_F+2,\quad A_{F'}=A_F+1$$So, we see that $S_{F'}-A_{F'}+1=N_{F'}$ holds.
Case 5 : If you add one hexagon $H$ to $F$ where $H$ and $F$ has exactly five common edges, then in the new polygons $F'$, we have $$N_{F'}=N+1,\quad S_{F'}=S_F+1,\quad A_{F'}=A_F$$So, we see that $S_{F'}-A_{F'}+1=N_{F'}$ holds.
From the five cases above, the formula holds for $N+1$. $\quad\square$