Skip to main content
. 2023 May 10;23(10):4624. doi: 10.3390/s23104624
Algorithm 1: Indirect Opinion Path Search Algorithm
1: Initialization
2: Input: Opinion set G of nodes, Complete set of nodes V, Target node Vt.
3: Output: All indirect opinion paths Ws reaching the target node Vt.
4: for all element Vs //Consider nodes in set V, excluding Vt, as source nodes Vs
5:  Ws = [];     //Define the path set Ws for Vs.
6:  Opinion_Walk(G,Vs,Vt)  //Recursively search for vehicles that have interactions
7:  if Vs ≠ Vt and G[Vs]! = []
8:   W←Vs;        //Add qualifying nodes to the path W
9:  for node in G[Vs]
10:  if node not in W and len(W) < 3
11:   Opinion_Walk(G,node,Vt);
12:   if len(W) == 3 and Vs == Vt //If an indirect path is found, add it to the path set Ws
13:   Ws←W;       //Add qualifying nodes to the path W
14:   end if
15:  end if
16:  end for
17:  end if
18: end for
19: return Ws
20: END