# One-Layer vs. Two-Layer SOM in the Context of Outlier Identification: A Simulation Study
## 4 Conservation of Topology
### Image-Based Distance  
This is based on creating an image map for each of the two points \(x_{i},x_{j}\) involved; the dimensions of each image are the same as those of the SOM under study. The distance is a weighted average of the distances between the centroids of all possible pairs of nodes from the two images, the first element in the pair stemming from the \(x_{i}\) image map and the second from the \(x_{j}\) map. The weights of the average depend on the distance between the node in question and the winning node. Two possible weights were contemplated:  
(a) The first would be the product of two factors, a monotonic function of the distance from the winning node to the node in question in the first (\(x_{i}\)) map, and the second likewise for the second (\(x_{j}\)) one;  
(b) The second would be interpreted as the joint probability of the two nodes, which would depend on how the nodes are seen for each image map. This would involve the product of four factors, the first two for the weights of the first (\(x_{i}\)) node from the point of view of both images and the second likewise for the (\(x_{j}\)) node. Here, we applied option (a). The image-based distance, which came from [13], was thus formally defined as follows:  
1. Let \(x_{i},x_{j}\in\mathbb{R}^{n}\) be the sample individuals: 1. \(n_{pq}\in som_{map}\) the \(pq\)-th node in the map: 2. We call \(\varpi_{pq}\in W\subset\mathbb{R}^{n}\) the centroids (projection-representative in the original space); 3. We call the neighborhood of \(N_{pq}\) as \(V(N_{pq})=\{N_{rs}/d_{2}((p,q),(r,s))<=\alpha\}\) with \(p,q,r,s\in\mathbb{N}\); 4. We denote by \(son_{map}=(NxN,W)\), where \(N\subset\mathbb{N},W\subset\mathbb{R}^{n}\) and \(son_{map}(x_{i})=(N_{V(N_{i})}xN_{V(N_{i})},W_{V(N_{i})})\), the projection of the original map onto the neighborhood space for the node assigned to point \(x_{i}\); 5. A map may be considered an image, a pixel matrix where each pixel has been assigned the weight vector of the centroid of each node. We shall now lay out for our problem the modifications on distances used in such cases; 6. Let us define the global distance, which combines the spatial distance with the pixel intensity:\(GD(A,B)=\frac{2}{N^{2}(N^{2}-1)}\sum_{A_{ij}}\sum_{B_{lm}}\delta(A_{ij},B_{lm})\); \(d^{D}((i,j),(l,m))=\frac{|i-|l|+|j-m|}{N}\); \(\delta(A_{ij},B_{lm})=\alpha d^{D}((i,j),(l,m))+\beta GR(a_{ij},b_{lm})\) with \(0\leq\alpha,\beta\leq 1,\ \alpha+\beta=1\); \(GR(a_{ij},b_{lm})=|a_{ij}-b_{lm}|/max(a_{ij},b_{lm})\). This is the definition for black and white images. In our case, we worked in \(W\subset\mathbb{R}^{n}\), so we replaced it with the normalized euclidean distance; \(\eqref{eq:d_ij}\) Once a framework has been established, we specified image distances within the framework. We now considered the \"images\", the submaps of the neighborhood assigned to each point, and we assigned a variable to each image, an \(I\) intensity matrix that contains the values determined by the neighborhood: \(I/I_{ij}(x_{i})=f(N_{ij},N_{nl})\in(0,1)\), where \(N_{nl}=N(x_{i})\); \(f\) may be defined in several ways, but here, we chose: Equation (9) \[f(N_{mk},N_{nl})=\left\{ \begin{array}{l}1\ winner\\ 0.75\ first-level\ neighborhood\\ 0.5\ second-level\\ 0.25\ other\ cases\end{array} \right.\] (9) \(\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{\text{ \text{\  
Let \(G=(V,E)\) be a nondirected graph, where \(V=\{N\in som_{map}\}\) and \(E=\{(N,M),N,M\in som_{map}/N\in V(M),M\in V(N)\}\);
4. We define for each side its weight \(p(e_{(N,M)})=d(N,M)=d(w_{N},w_{M})\);
5. Let us define a path from N to M as a sequence \((e_{1},e_{2},e_{3},...e_{m})\) of sides such that \(e_{i}\) ends where \(e_{i+1}\) begins and \(e_{1},e_{m}\) begins or ends in N, M, respectively;
6. \(\mathcal{C}_{\mathcal{N}\mathcal{M}}\) the set of all paths beginning in N and ending in M;
7. By application of [PERSON]'s algorithm, one can find the minimal path from any node N to any other one, defined as \(C_{NM}=argmin_{c\in C}\{\sum_{e_{i}\in C}p(ei)\}\);
8.