Method for Counting the Number of "Unique" Vertices in a Grid? I'm trying to find a mathematical formula that will return the number of vertices for an $m x n$ grid of elements. The tricky part is that any grid element is allowed to span multiple rows or columns.
Let's define the bottom left corner of a grid element as it's position and say that the origin [x=0,y=0] of any grid is the bottom left corner, where +x is to the right and +y is up. 
Here are some examples to help one visualize the problem: 

The description grids 1, 2, and 3 are:


*

*2x2 Grid - comprised of (2) 1x1 elements at positions [0,0] and [0,1] (1) 2x1 element at position [1,0]

*2x3 Grid - comprised of (4) 1x1 elements at positions [0,1] [1,1] [2,1] [0,2] and (1) 1x2 element at position [0,0]

*2x4 Grid - comprised of (3) 1x1 elements at positions [0,0] [2,1] [3,1], (1) 1x2 element at position [0,1], and (1) 1x3 element at position [1,0]


If for an $mxn$ grid we know the total number of grid elements ($cnt$) and for each grid element we know it's position ($[x , y]$) and size ($l$ x $w]$), is there a formula that we may derive to calculate the number of unique vertices in said grid? 
*** Note that unique vertices are shown as blue dots in the aforementioned  Example Image
Thank you
01/16/2015 EDIT: I came up with a new example (4.) that is missing a grid element, it is desired for the formula to be able to calculate the number of unique vertices for an incomplete grid as well 
 A: I think from your input you can simply calculate the position of each of the four vertex. It is going to be:
[x,y] , [x+l,y] , [x,y+w] , [x+l,y+w]
Then you sort this list of 4*cnt elements and remove duplicates and count the cardinality. I don't think you can have a closed formula because the domain of your function depends on how many grids you have:
vertex =  $f(g_1,g_2,....,g_{cnt})$
where $g \in N^4$ (4 dimension arrays of natural numbers) 
A: If you know the number of vertices where $4$ rectangles meet then here's a formula.
e.g. in Example 1 there are none, in Example 2 there is one vertex (2,1) and in example 3 there are none.
Let $r$ be the number of rectangles and $s$ be the number of vertices where $4$ rectangles meet, then the number of unique vertices is
$$2\cdot (r+1)-s$$
This gives $2\cdot 4-0=8$, $2\cdot 6-1=11$ and $2\cdot 6-0=12$ correctly.
EDIT:
I assumed that the region is rectangular. To make this formula work for more complicated shapes it becomes more complicated. Define:


*

*$s_1 = $ number of vertices that have $1$ corner of a rectangle.

*$s_2 = $ number of vertices that have $2$ corners of a rectangle.

*$s_3 = $ number of vertices that have $3$ corners of a rectangle.

*$s_4 = $ number of vertices that have $4$ corners of a rectangle.


Anyhow, the formula for unique vertices is
$$\begin{align}
v&=s_1+s_2+s_3+s_4\\
&=4r-s_2-2s_3-3s_4 \\
&=2r+\frac{s_1-s_3}{2}-s_4 \\
&=\frac{4r+2s_1+s_2-s_4}{3} \\
&=r+\frac{3s_1+2s_2+s_3}{4}
\end{align}$$
Previously I chose to give you the middle equation with $s_1=4, s_3=0$, but we can't make these assumptions if the region isn't necessarily rectangular.
e.g. This works for the new example $4$ with $r=2,s_1=6,s_2=1,s_3=0,s_4=0,v=7$.
A: Let $f$ be the number of "elements", $v$ be the number of interior full nodes, and $h$ be the number of half nodes. Then counting right angles we obtain
$$4f=4v+2h+4\ ,$$
which is essentially Euler's formula in this situation. Now one can refine this by taking the size of the "elements" into account, and counting the "null nodes" as well.
