Your groups of tiles can be considered as graphs, where vertices represent tiles and two vertices are connected by edge if and only if their corresponding tiles touch each other side by side. So, in terms of graph theory, the problem you are trying to solve is known as CISE (Connected Induced Subgraphs Enumerating). You can find a number of papers, describing algorithms to solve this problem - I'll excerpt here some results from this paper.
We consider undirected simple graphs $G = (V,E)$. Some notations:
* For any vertex $v \in V$, the open neighborhood of $v$ is defined as $N(v) = {u \space | \space {u, v} \in E}$ and the closed neighborhood of $v$ is defined as $N[v] = N(v) \cup {v}$.
* For any vertex set $W \subseteq V$ the open neighborhood of $W$ is defined as $N(W) = \bigcup_{v∈W} N(v) \setminus W$ and the closed neighborhood of $W$ is defined as $N[W] = N(W) \cup W$.
* The graph $G[W]$, induced by a vertex set $W \subseteq V$, consists of all edges from $E$ with both ends in the $W$, so $G[W] = (W, {{u,v} \in E \space | \space u,v \in W})$.
The following recursive function will list all the connected induced subgraphs of the graph $G$, starting from some vertex. Both arguments $P$ and $X$ of this function are vertex sets. 433
The function call Enumerate({v}, N(v)) will list all the connected induced subgraphs, starting from some vertex $v \in V$. All these subgraphs will contain this vertex. Operations + and - denote set operations union and minus on vertex sets.
Enumerate(P, X)
output P
while vertex set X is not empty
u = any vertex from X
remove u from X
X' = X + (N(u) - N[P])
Enumerate(P + {u}, X')
In order to list all the subgraphs, not including this vertex $v \in V$, it should be removed from the graph $G$, and then the above recursive function should be called with another starting vertex.
I've implemented this algorithm and tested it on your example:
+---+---+---+
| A | B | C |
+---+---+---+
| D | E |
+---+---+
Graph representation of this configuration is below:
The Enumerate('A', N('A')) function call was able to find more subgraphs, than you mentioned in your question - new ones are marked by asterisk:
A
A B
A B C
A B C D *
A B C D E
A B C E
A B D *
A B D E
A B E
A D
A D E
As far as I understand your primary goal is to find subgraphs, satisfying some condition (sum of vertex weights = constant $M$). You can modify the function above to include checking this condition instead of simply printing $P$, for example:
if sum of vertex weights over P is equal to M
output P
return
Here you need to return from the function after the output because the vertex set $P$ expands with each recursive call, so the sum can only grow and become greater than this constant $M$ further on.
ADDITION. My C++ testing code is here. 835