# Replicating File Segments between Multi-Cloud Nodes in a Smart City: A Machine Learning Approach
## 5 Using Machine Learning for Partial Replication and Selecting the Candidate Node
### Example of Topology Formulation  
As shown in Figure 2, edge servers are used to provide content and services closer to the user, while cloud servers are used to store and manage data and applications in a remote location. Edge servers are typically located at the edge of the network, while cloud servers are located in a centralised data center. Edge servers are used to reduce latency and improve performance, while cloud servers are used to provide scalability and cost savings. Edge nodes can serve as intermediate nodes between two or more clouds in communication. In a distributed cloud architecture, there may be multiple cloud nodes that are geographically distributed across different regions or even countries. In such a scenario, it may be inefficient to transmit data directly between the clouds, especially if the data need to travel long distances or cross international borders. In this case, edge nodes can be used as intermediate nodes between the clouds. An edge node located near the source cloud can receive the data and process them locally, before transmitting them to another edge node located near the destination cloud. This approach can help to reduce the overall latency and bandwidth requirements of the communication. In addition, edge nodes can also perform other functions such as caching frequently accessed data, filtering or preprocessing data before they are transmitted to the cloud and providing additional security measures such as encryption and access control [50; 51]. To demonstrate the idea, consider the topology shown in Figure 2 which shows a system \(\mathbb{S}\) with three clouds and eight edges. Figure 2 demonstrates the problem to be solved, where users are trying to access some file segments on the cloud and because of the constraints that are discussed and defined in Section 2, the cost of accessing those files is high. The system shown in Figure 2 is described as follows:  
From Equations (9) and (10), we can see that \(\Phi\) for the system shown in Figure 2 is:  
\[\Phi= \begin{bmatrix}1&1&0\\ 1&1&1\\ 0&1&1\end{bmatrix}  \tag{16}\]  
Equation (16) shows that \(c_{1}\) and \(c_{2}\) are directly connected, and \(c_{2}\) and \(c_{3}\) are also directly connected. Topology matrices can be seen as reachability matrices, which means that it tells which node is reachable from another. The matrix represents the reachability of clouds from other clouds and since any cloud is reachable from itself, the diagonal is always 1. Since the graph is actually bi-directional one can see that the matrix is a symmetric matrix. From Equations (11) and (12) we can see that \(\Omega\) for the system shown in Figure 2 is:  
\[\Omega= \begin{bmatrix}1&0&0&0&0&0&1\\ 0&1&1&1&0&0&0\\ 0&1&1&1&0&0&0\\ 0&1&1&1&1&0&0\\ 0&0&0&1&1&0&0\\ 0&0&0&0&0&1&1\\ 1&0&0&0&0&1&1\end{bmatrix}  \tag{17}\]  
Equation (17) shows that \(e_{1}\) is directly connected with \(e_{7}\). Furthermore, \(e_{2}\) is directly connected with both \(e_{3}\) and \(e_{4}\). \(e_{3}\) is directly connected with both \(e_{2}\) and \(e_{4}\). \(e_{4}\) is directly connected with \(e_{2},e_{3}\) and \(e_{5}\). \(e_{5}\) is directly connected with \(e_{4}\). \(e_{6}\) is directly connected with \(e_{7}\). Finally, \(e_{7}\) is directly connected with both \(e_{1}\) and \(e_{6}\). \[\mathbb{C}=\{c_{1},c_{2},c_{3}\} \tag{18}\]  
\[\mathbb{E}=\{e_{1},e_{2},e_{3},e_{4},e_{5},e_{6},e_{7},e_{8}\} \tag{19}\]  
The matrix represents the reachability of edge servers from edge servers and, since any edge server is reachable by itself, the diagonal is always 1. Since the graph is actually bi-directional one can see that the matrix is a symmetric matrix. From Equations (13) and (14) we can see that \(\Psi\) for the system shown in Figure 2 is:  
\[\Psi= \begin{bmatrix}1&1&1&1&1&0&0\\ 1&0&0&1&1&1&1\\ 0&0&0&1&1&1&0\end{bmatrix}  \tag{20}\]  
Equation (20) shows that \(c_{1}\) is connected with \(e_{1},e_{2},e_{3},e_{4}\) and \(e_{5}\). \(c_{2}\) is connected with \(e_{1},e_{4},e_{5},e_{6}\) and \(e_{7}\).