Research Article

Exploiting Machine Learning to Detect Malicious Nodes in Intelligent Sensor-Based Systems Using Blockchain

Algorithm 5

Dijkstra algorithm.
1 if Source Destination then
2 Cost 0;
3 RouteSource;
4 end
5 if Destination1 then
6 Destination Source;
7 end
8 Adjacencyexchange the node (Adjacency,1,Source);
9 LengthAsize(Adjacency);
10 /Weight is W/
11 for i2 : LengthA do
12 W(1,i)i;
13 W(2,i)Adjacency(1,i);
14 end
15 for i=1:Length Adjacency do
16 Destination(i,1)Graph(1,i);
17 Destination(i,2)i;
18 end
19 while Cost (size(W,1)-1) do
20 CostCost+1;
21 for i=1:size(Distance,1) do
22 Calculate the distance;
23 end
24 DestinationSort the rows and find Destination;
25 Add the Distance of each Route to the Destination;
26 end