# Algorithm for Producing Rankings Based on Expert Surveys
## 6 Building an Automated Algorithm  
The full script of the algorithm is presented in the Appendix A at the end of this article. For reasons of personal preferences and practicality, we used the hypertext preprocessor (PHP) programing language, but the algorithm can easily be replicated in other programing languages. Sample dummy data are presented in Table 2 to exemplify the operation of the algorithm. The first column of data represents the identification letter of the unit, the second column is the identification number of the expert, and the third column is the unit's relative ranking within a segment, that is, among the units ranked by that expert. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Unit** & **Expert** & **Ranking** \\ \hline \(Q\) & I & 1 \\ \(P\) & I & 2 \\ \(P\) & II & 1 \\ \(H\) & II & 2 \\ \(P\) & III & 1 \\ \(D\) & III & 2 \\ \(V\) & III & 3 \\ \(D\) & IV & 1 \\ \(Q\) & IV & 2 \\ \(R\) & IV & 3 \\ \(V\) & V & 1 \\ \(R\) & V & 2 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Dummy dataset (for readability, the dummy data in the table are presented in tabular format; for actual processing by the hypertext preprocessor (PHP) algorithm, the data need to be reformatted as comma-separated values). Figure 8: Ranking as a hierarchical link network. Our dummy data include responses from five experts. The algorithm starts by reading data from the file and grouping the units into segments by experts. An array of segments is stored for later use. The segments in our dummy dataset are presented in Table 3.  
Next, the script creates an array of all unique units present in a dataset; that is, it looks through all segments and collects all units into a separate list without repetition. With our dummy dataset, this step results in the following array:  
\[[Q,P,H,D,V,R] \tag{2}\]  
The algorithm works its way through this array and calculates the score of each unit. As discussed above, a unit gains its score from its subordinates (i.e., units ranked directly or indirectly below it). A hierarchical tree of subordinates is built for each unit. For instance, the first unit in our example is \(Q\). It has one direct subordinate in the segment from Expert I (namely \(P\)) and another one in the segment from Expert IV (namely \(R\)). Unit \(P\), in turn, also has its own subordinates in the segments from Experts II and III (\(H\), \(D\) and \(V\)). At this point, the script looks for subordinates of \(H\), \(D\), and \(V\) as well. However, it finds that \(H\) does not have any subordinates in any segment, \(D\) has three subordinates (\(V\), \(Q\), and \(R\)), and \(V\) has one subordinate (\(R\)) that is already included in the tree. Here, the algorithm moves on to the next unit, because all possible branches of the subordinate tree for unit \(Q\) have been built. Figure 9 shows the subordinate trees for all units:  
Units that appear directly below the parent (along the blue axis) are level 0 subordinates, units that appear below direct subordinates (along the green axis) are level 1 subordinates, and the next units (along the orange axis) are level 2 subordinates. Subordinate trees can have many more levels, depending on the scope and complexity of data. Each unit in the tree contributes to the final score of a parent at the top of the tree. Each level 0 subordinate delivers one point to the parent's score, each level 1 subordinate delivers 85% of 1 point (or 1 \(\times\) 0.85), each level 2 subordinate delivers 85% of 0.85 points (or 0.85\({}^{2}\) = 0.7225), and so on. The general rule is that each unit in a subordinate tree contributes 0.85\({}^{\text{L}}\) points to the score of the grandparent (where L is the level of subordination). The precise damping factor one uses can have an impact on the final ranking. A number closer to 100% strengthens the relative scores of units with few level 0 subordinates and many level 1, 2, 3, etc. subordinates; whereas a number closer to 0 boosts the relative scores of units with many level 0 subordinates and fewer at other levels.