Research Article

An Improved Breadth-First Search Method Based on Information Interaction Applied for Power Network Topology Analysis

Algorithm 2

Pseudocode of improved breadth-first search method based on information interaction. Algorithm name: Algorithm_B.
(1)m = V.size();
(2)for (i = 0; i < m; i++) do
(3)if V[i][0] = = i + 1 && V[i].size() > 1 then
(4)  q = V[i];
(5)  jump = 1;
(6)  while jump < len do
(7)   if q[jump] = V[q[jump] − 1][0] then
(8)    V[q[jump] − 1][0] = q[0];
(9)    if V[q[jump] − 1].size() > 1 then
(10)     for (j = 1; j < V[q[jump] − 1].size(); j++) do
(11)      if V[q[jump] − 1][j] not in q then
(12)       q.push_back(V[q[jump] − 1][j]);
(13)      end if;
(14)     end for;
(15)    end if;
(16)    jump++;
(17)   else if q[0] > V[q[jump] − 1][0] then
(18)    qp = Q[];
(19)    nj = qp.size();
(20)    for (j = 0; j < jump; j++) do
(21)     qp.push_back(q[j]);
(22)     V[q[j] − 1][0] = V[q[jump] − 1][0];
(23)    end for;
(24)    for (j = jump + 1; j < q.size(); j++) do
(25)     if q[j] not in qpthen
(26)      qp.push_back(q[j]);
(27)     end if;
(28)    end for;
(29)    clear Q[];
(30)    jump = jump + nj;
(31)    q = qp;
(32)   else if q[0] < V[q[jump] − 1][0] then
(33)    qp = Q[];
(34)    nj = 0;
(35)    for (j = 0; j < qp.size(); j++) do
(36)     if qp[j] not in G then
(37)      Y.push_back(qp[j]);
(38)      nj++;
(39)     end if;
(40)     V[qp[j] − 1][0] = q[0];
(41)    end for;
(42)    clear Q[];
(43)    jump = Y.size() + 1;
(44)    q = [Y G];
(45)   else if q[0] = = V[q[jump] − 1][0] then
(46)    jump++;
(47)   end if;
(48)  end while;
(49)  Ts = Q.size();
(50)  for (j = 0; j < Ts; j++) do
(51)   if Q[j] is empty then
(52)    Q[j] = q;
(53)    break;
(54)   else if Q[j] is not empty && j = = Ts − 1 then
(55)    Q.push_back(q);
(56)   end if;
(57)  end for;
(58)else if V[i][0] = = i + 1 && V[i].size() = = 1 then
(59)  Z.push_back(i);
(60)end if;
(61)end for;