Based on this idea,
FigureREF  displays the pseudocode of the algorithm for measuring the boundary node proximities.
The first input is the data structure for the connectivity of the nodes in the network. The second
input is \(walknum\) , which is the number of random walkers
that are started from each boundary node before convergence is tested. The third input, \(stepnum\) , is the number of steps/node traversals taken by each random walker.
The vector \(visitCounts\)  holds the number of visits by random walkers which are made to each node in the network
throughout the algorithm. As a variation this vector could be made into a sparse matrix where each row is the
contribution of an i.i.d. walker, so that more information from the walks can be found.
The function call here, \(\text{connected\_components}(G)\) , is to the breadth-first-search algorithm which
produces a list of the elements in \(G\)  which are connected to each other.
Using the identifiers of connected graph membership, a list of the connected
components is produced, \(\mathbf {G}\) . In the loop of the elements of \(\mathbf {G}\) , \(g\)  is a connected network.
Here the function call \(\text{community}(g)\) , is to the community detection algorithm of choice (in this work the Louvain algorithm is used). This
returns the community membership labels \(\mathbf {C}\)  for the networks and modularity index \(Q\) . If the modularity index is not larger than
a certain threshold of choice, then it is considered that \(g\)  has no evident community structure and therefore no boundary nodes and the loop continues to the next connected graph component \(g\) .
The boundary edges, \(\mathbf {W}\) , can be extracted by including only edges which connect different community labels.
We obtain the adjacency matrices for each community label by including only the nodes in each community label in a separate adjacency matrix.
For each unique \(node\)  in the list of \(\mathbf {W}\) 
the algorithm then proceeds through the standard method of a set of random walks on the adjacency matrix. After
the completion of \(walknum\)  number of walks, the trajectories are tested for convergence using the potential scale reduction factor (PSRF) of
[1]}. If the set of trajectories have not converged, more walkers are computed until the required amount of
convergence is achieved. Upon convergence, the values counts of visits to each node by the walkers is normalized to remove the
effects of more walks due to lack of convergence.
The results are scaled according to the
relative size of the community in relation to the whole graph because of the impact it may have on the large scale of the information flow, so that the nodes in larger communities deliver a larger impact than small ones.
