# 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 Using the Topology Operator
\[c_{3}\frac{\overset{1}{\underset{\Phi}{\rightleftarrow}}c_{5}}{\overset{1}{ \underset{\Phi}{\rightleftarrow}}}=\Phi[3]\ \wedge\ \Phi[5]=[\ 0\ 0\ 0\ 1\ 0\ ] \tag{31}\]  
The result of calculating \(c_{3}\frac{\overset{1}{\underset{\Phi}{\rightleftarrow}}c_{5}}{\overset{1}{ \underset{\Phi}{\rightleftarrow}}}\) in Equation (31) shows that \(c_{3}\) and \(c_{5}\) are not directly connected but they are indirectly connected through intermediate node \(c_{4}\). \[c_{1}\underset{\Phi}{\overset{1}{\underset{\Phi}{\rightleftharpoons}}}c_{3}= \Phi[1]\ \wedge\ \Phi[3]=[\ 1\ 0\ 1\ 0\ 0\ ] \tag{24}\]0  
Now we continue with phase 2: \(\Phi\) paths with 2 nd degree. In this phase, only those connected nodes in first phase are used. In other words, the path segment between \(c_{1}\) and \(c_{5}\) in Equation (26) will be ignored since there is no 1 st degree connectivity between both nodes. Applying 2 nd degree of the above operation works as follows:  
\[c_{1}\underset{\Phi}{\overset{1}{\underset{\Phi}{\rightleftharpoons}}}c_{3}= \Phi[1]\ \wedge\ \Phi[3]=[\ 1\ 0\ 1\ 0\ 0\ ] \tag{24}\]1  
Applying operator \(\overset{n-1}{\underset{\rightleftarrow}}\) in phase 2 gives one of three different possible outputs:  
1. A vector that contains zeros
2. A vector that contains a value one that represents the source and every other value is zero
3. otherwise  
Case 1 means that source and destination are completely disconnected through the path tested by source \(\overset{n-1}{\underset{\rightleftarrow}{\rightleftarrow}}\) destination. Case 2 means that source and destination are directly connected. Results indicate that \(c_{4}\) is reachable from \((c_{1}\underset{\Phi}{\overset{c_{3}}{\rightleftarrow}}c_{3})\) which means that path \((c_{1}\underset{\Phi}{\overset{c_{3}}{\rightleftarrow}}c_{4})\) will be considered in the 3 rd phase. The 2 nd degree path to \(c_{5}\) from \(c_{1}\) is found as follows:  
\[(c_{1}\underset{\Phi}{\overset{2}{\rightleftarrow}}c_{5})= \begin{cases}(c_{1} \underset{\Phi}{\overset{1}{\rightleftarrow}}c_{2})\wedge c_{5}\\ \underset{\Phi}{\overset{1}{\rightleftarrow}}(c_{1}\underset{\Phi}{\overset{ 1}{\rightleftarrow}}c_{3})\wedge c_{5}\\ (c_{1}\underset{\Phi}{\overset{1}{\rightleftarrow}}c_{4})\wedge c_{5}\end{cases}  \tag{43}\]  
\[(c_{1}\underset{\Phi}{\overset{1}{\rightleftarrow}}c_{2})\wedge c_{5}=[\;1\;1 \;0\;0\;0\;]\wedge[\;0\;0\;0\;1\;1\;]=[\;0\;0\;0\;0\;0\;] \tag{44}\]  
This means that path \((c_{1}\underset{\Phi}{\overset{c_{2}}{\rightleftarrow}}c_{5})\) will not be used in the 3 rd phase. \[(c_{1}\underset{\Phi}{\overset{1}{\rightleftarrow}}c_{3})\wedge c_{5}=[\;1\;0 \;1\;0\;0\;]\wedge[\;0\;0\;0\;1\;1\;]=[\;0\;0\;0\;0\;0\;] \tag{45}\]  
This means that path \((c_{1}\underset{\Phi}{\overset{c_{3}}{\rightleftarrow}}c_{5})\) will not be used in the 3 rd phase. \[(c_{1}\underset{\Phi}{\overset{1}{\rightleftarrow}}c_{4})\wedge c_{5}=[\;0\;1 \;1\;0\;0\;]\wedge[\;0\;0\;0\;1\;1\;]=[\;0\;0\;0\;0\;0\;] \tag{46}\]  
This means that path \((c_{1}\underset{\Phi}{\overset{c_{4}}{\rightleftarrow}}c_{5})\) will not be used in the 3 rd phase. This will be repeated for paths that start with \(c_{2},c_{3},c_{4}\) and \(c_{5}\). Only successful paths will continue for phase 3. Note that the maximum number of phases is \(n\), where \(n\) is the number of clouds connected to the topology \(\Phi\). The stopping criterion of the algorithm is the failure to produce any vector that can continue to the next phase.