As pointed out by classical political economy, a region's productivity level and growth prospects can be largely explained by its degree of division of labor. Thus, the segmentation of individuals and firms in different activities is the main factor in the level of overall productivity and growth. Despite being an old and intuitive idea, just recently there are enough high-resolution data to prove this thesis. Given this idea in mind, let be $I$ the set of economic activities and $R$ the set of regions. Given the number of hours worked in economic activity $i\in I$ at region $r\in R$ and year $t$ as $L_{r,i,t}$, we can define
$$p_{r,i,t} \equiv \frac{L_{r,i,t}}{L_{r,t}}\>\>\>,\>\>\>L_{r,t} \equiv \sum_{i\in I}L_{r,i,t}.$$
Some activities, however, have on average more labor devoted to them. Thus, what matters is not how much labor a region dedicates to an activity, but how much more it dedicates to this activity in relation to the national average. So, we can define the {\it revealed comparative advantage} of a region $r\in R$ on activity $i\in I$ in year $t$ as
$$\mathrm{RCA}_{r,i,t} \equiv \frac{p_{r,i,t}}{\overline{p}_{i,t}} \>\>\>,\>\>\>\overline{p}_{i,t}\equiv\frac{\sum_{r\in R}L_{r,i,t}}{\sum_{r\in R}L_{r,t}}.$$
With this quantify in hand, we can represent the regional division of labor through a bipartite network with adjacency matrix $M_{r,i,t}$, where $M_{r,i,t}$ is equals to $1$ if the region $r$ is a significant producer in activity $i$ in year $t$ ($\mathrm{RCA}_{r,i,t} > 1$) and $0$ otherwise. First, we can define a region's diversity as how many activities it specializes in
$$D_{r,t} \equiv \sum_{i\in I} M_{r,i,t}.$$
Similarly, we define the ubiquity of an activity as the number of regions specializing in it
$$U_{i,t} \equiv \sum_{r\in R} M_{r,i,t}.$$
Although the diversity measure can give us good insights into the productive structure of a region, it only considers how many, not which, activities a region specializes in. Similarly, ubiquity considers only how many, not which, regions are specialized in it. And this is sensitively important for structuralist economics, where {\it what} a region produce matters. For instance, it is common knowledge that it is better to specialize in high-tech industries than in primary goods.
To solve this problem, Hausmann and Hidalgo defined the complexity of each region ($K_{r,t}$) and of each activity ($Q_{i,t}$) as following this intuitive quasi-circular logic: the economic complexity of a region is the average of the complexity of the activities in which it specializes
$$K_{r,t}\equiv\frac{\sum_{i\in}M_{r,i,t}Q_{i,t}}{\sum_{i\in I} M_{r,i,t}}\ =\ \frac{\sum_{i\in}M_{r,i,t}Q_{i,t}}{D_{r,t}},$$
and, reciprocally, the complexity of an activity is the average of the complexity of the regions specialized in it
$$Q_{i,t}\equiv\frac{\sum_{r\in R} M_{r,i,t}K_{r,t}}{\sum_{r\in R} M_{r,i,t}} = \frac{\sum_{r\in R} M_{r,i,t}K_{r,t}}{U_{i,t}}.$$
With some simple manipulation, we finally get
$$K_{r,t} = \sum_{r^\prime \in R}{{\hat{M}}_{r,r^\prime,t}K_{r^\prime,t}}\>\>\> \text{where}\> \> \> {\hat{M}}_{r,r^\prime,t} \equiv \sum_{i\in I}\frac{M_{r,i,t}M_{r^\prime, i,t}}{D_{r,t}U_{i,t}}$$
and
$$Q_{i,t}\ =\ \sum_{j\in I}{{\widetilde{M}}_{i,j,t}Q_{i,t}}\> \> \> \text{where}\> \> \> {\widetilde{M}}_{i,j,t}\ =\ \sum_{r\in R}\frac{M_{r,i,t}M_{r,j,t}}{D_{r,t}U_{i,t}}.$$
Since $K_{r,t}$ and $Q_{i,t}$ are relative metrics, it is defined the Economic Complexity Index ($ECI$) and the Activity Complexity Index ($ACI$) with the normalizations
$${ECI}_{r,t} \equiv \frac{K_{r,t} - \langle {K_t} \rangle}{\text{std}({K}_t)}\>\>\> \text{and} \>\>\> ACI_{i,t} \equiv \frac{Q_{
i,t} - \langle {Q_t} \rangle}{\text{std}({Q}_t)}.$$
There are two methods to solve the equations above. The first one is simply identifying that the region-complexity vector $K$ is the eigenvector of $\hat{M}$ and the activity-complexity vector $Q$ is the eigenvector of $\widetilde{M}$, both associated with the second largest eigenvalue, since it captures the largest amount of variance in the system.
The second one is called method of reflections, where the complexity metrics are the stationary solution of the following coupled dynamic equations
$$K_{r,t}^{n+1} = \frac{\sum_{i\in I}{M_{r,i,t}Q_{i,t}^n}}{D_{r,t}} \>\>\> and \>\>\> Q_{i,t}^{n+1} = \frac{\sum_{r\in R}{M_{r,i,t}K_{r,t}^n}}{U_{i,t}}$$
with initial conditions $K_{r,t}^0 = D_{r,t}$ and $Q_{i,t}^0= U_{i,t}$.
Extending this idea, the Fitness-Complexity algorithm re-weights the reflection method by postulating that the complexity of an activity is lower if it is produced by more countries. Here, the new metrics for fitness of each region ($F_{r,t}$) and the complexity of each activity ($G_{i,t}$) are given by the stationary solution of the following coupled dynamic equations
$${\widetilde{F}}_{r,t}^{n+1}\ =\sum_{i\in I}{M_{r,i,t}G_{i,t}^n}\>\>\>,\>\>\> F_{r,t}^n = \frac{{\widetilde{F}}_{r,t}^{n}}{\langle {\widetilde{F}}_{t}^n\rangle}$$
and
$${\widetilde{G}}_{i,t}^{n+1}\ =\frac{1}{\sum_{r\in R}\frac{M_{r,i,t}}{F_{i,t}^n}}\>\>\>,\>\>\> Q_{i,t}^n = \frac{{\widetilde{Q}}_{i,t}^{n}}{\langle {\widetilde{Q}}_{t}^n\rangle},$$
with initial conditions $F_{r,t}^0 = 1$ for all $r\in R$ and $G_{i,t}^0 = 1$ for all $i \in I$ and $t$. Since these equations are non-linear, it is not possible to directly find their eigenvectors.
Finally, with a similar motivation from the Fitness-Complexity algorithm, we can weigh the number of workers in each region by the difficulty of working in each activity. For this, we define the weighted number of workers $X_{r,t}$ as the stationary solution of the following dynamics equation
$${\widetilde{X}}_{r,t}^{n+1} = \sum_{i\in I}\frac{L_{r,i,t}}{\varphi_{i,t}^n}\>\>\>,\>\>\> \varphi_{i,t}^n = \sum_{r\in R}\frac{L_{r,i,t}}{X_{i,t}^n}\>\>\>,\>\>\> X_{i,t}^n = \frac{{\widetilde{X}}_{r,t}^{n}}{[{\widetilde{X}}_t^{n+1}]},$$
where $[\cdot]$ indicates geometric mean and the initial condition is ${\widetilde{X}}_{r,t}^0= L_{r,t}$. Using this weighted metric, it is defined the $ECI_{r,t}^+$ as
$$ECI_{r,t}^+ \equiv \log{X_{r,t}^{\infty}}- \log{\sum_{i\in I}\frac{L_{r,i,t}}{L_{i,t}}}.$$