## 3 Proposed Methodology
### Hybrid Algorithm for Finding the Highest Stable Least Delay Path or Highest Stable Shortest Path
However, as seen in Line 3, it follows from logic that the sum of the stable shortest distance or stable least delay from the destination node to the destination node itself is zero. Next, a loop begins to iterate \(N\) times, whose purpose is to add the nearest vertex to paths leading to destination \(S\) from each source node. At the beginning of that loop, local variables \"neaVer\" and \"sho\" are initialized to large. \"neaVer\" is a variable used to track the nearest stable shortest distance or stable least delay vertex included in the \"added\" array for the last time. \"sho\" stores the total stable shortest distance or total stable least delay from the vertex finally added to the \"added\" array to the destination node. At the end of the for loop in Lines 6 and 7, the nearest stable vertex that has not yet been added to the path is found. In Line 8, the nearest stable vertex is added to the \"added\" array by setting the corresponding index to a true value. Next, another loop begins in Line 9, whose purpose is to iterate through all links from the finally added nearest stable vertex to all other nodes. Using the composed knowledge on normalized network contention (\(\mathcal{C}\)), the mode of the routing algorithm is decided by comparing the contention against a contention threshold (\(\mathcal{C}_{th}\)), as given in the piecewise function in Equation (36):  
\[Routing\ mode=\left\{ \begin{array}{l}Highest\ stable\ shortest\ path\ routing;\ if\ \mathcal{C}>=\mathcal{C}_{th}\\ Highest\ stable\ least\ delay\ routing;\ if\ \mathcal{C}<\mathcal{C}_{th}\end{array} \right. \tag{36}\]  
The algorithm creates a local variable known as \"EdDisDel\", which stores the highest stable least distance or link delay to the nearest vertex from the \(j\)th node. As evident from Lines 10 and 11 of Figure 1, if normalized network contention (\(\mathcal{C}\)) is greater than or equal to the contention threshold (\(\mathcal{C}_{th}\)), \"EdDisDel\" will store the highest stable least distance. Note that, in distance mode, in order to compute the highest stable least distance metric, we get obtain ratio of distance with link lifetime plus one (to prevent the metric from reaching infinity at zero link lifetimes). Thus, low link lifetimes will result in a higher value for the metric, and vice versa. In particular, we first inspect the link lifetimes (\(T[\mathit{nearVer}][j][0]\) and \(T[\mathit{neaVer}][j][1]\)) and select the channel having the higher link lifetime in computing the highest stable least distance metric, as evident from Line 11. When the contention is lower than the threshold, delay mode will be selected. Then in delay mode, \"EdDisDel\" will store the highest stable minimum delay to the nearest vertex from the \(j\)th node in the \(k\)th communication channel, where \"EdDisDel\" is selected by considering the combined effect of link delay and lifetime, as evident from Line 13. For example, consider the links between two RSUs, where there is each a wireless link and a wired link. Then, using the delay matrix (\(D[\mathit{neaVer}][j][k]\)) and link lifetime matrix (\(T[\mathit{neaVer}][j][k]\)), the link having the combined effect of least delay and highest stability (the combined effect is computed by obtaining the ratio of \(D\) and \(T\)) out of wireless and wired communication channels will be chosen as \"EdDisDel\" for further processing, as evident from Line 13 in Figure 1.  
The if-condition in Line 14 checks whether the edge distance or delay (\"EdDisDel\") is greater than zero, the nearest vertex (\"neaVer\") is equal to the source index (\(j\)), or the sum of the distances or delays from the nearest stable vertex (\"sho\") plus edge distance or delay is less than or equal to the current stable shortest distances or stable least delays from the \(j\)th node (\"shoStaDisDel[j]\"). Note that, when the nearest vertex is equal to \(j\), the above if-condition is satisfied, even though \"EdDisDel\" is equal to zero in that scenario.