# Inferring Urban Social Networks from Publicly Available Data
## 2 Materials and Methods
### Friendship Edges
We can rewrite (2) as  
\[\Pr[u,v]=\frac{\mu\cdot N}{2}\cdot\frac{M(g_{u},g_{v})}{M}\cdot\frac{a(u,v)}{ A(g_{u},g_{v})}\approx\frac{\mu\cdot N}{2\cdot M\cdot(D)\cdot\langle f\rangle }\cdot s_{g_{u},g_{v}}\cdot a(u,v), \tag{3}\]  
where \(\langle D\rangle\) and \(\langle f\rangle\) denote the mean value of the fitness score \(f_{u}\) and of the distance function \(D(u,v)\), respectively. The approximation in (3) is obtained under the assumption that \(A(i,j)\approx m_{i,j}\cdot\langle a(u,v)\rangle=m_{i,j}\cdot\langle D\rangle \cdot\langle f\rangle^{2}\) for all \(i,j\), which is accurate if all age groups are large enough. **Edge density and social mixing:** The expected value of \(E_{F,i,j}\) in our networks is  
\[\mathbb{E}[|E_{F,i,j}|]=\sum_{u\in V_{i}\
eq v\setminus f}\Pr[u,v]=\frac{\mu \cdot N}{2}\cdot\frac{M(i,j)}{M}\cdot\frac{\sum_{u\in V_{i},v\in V_{j}}a(u,v)}{ A(i,j)}=\frac{\mu\cdot N}{2}\cdot\frac{M(i,j)}{M} \tag{4}\]for all \(i\leq j\). The expected number of edges in the entire friendship graph is, thus,  
\[\mathbf{E}[|E_{F}|]=\sum_{i\leq j}\mathbf{E}[|E_{F,i,j}|]=\frac{\mu\cdot N}{2} \cdot\frac{\sum_{i\leq j}M(i,j)}{M}=\frac{\mu\cdot N}{2}. \tag{5}\]  
This shows that, thanks to the normalization by \(A(g_{u},g_{v})\), the age-based social mixing is respected, up to a scaling factor. In particular, the dependence of \(\Pr[u,v]\) upon \(d(u,v)\) does not affect the (expected) density of the friendship graph, which is entirely controlled by \(\mu\). By tuning \(D(u,v)\), we may adjust only the physical length distribution of the edges--arguably, in order to penalize _long_ edges. **Expected degree:** Thanks to the relation \(\sum_{u}\deg_{F}(u)=2\cdot|E_{F}|\), it is easy to verify that the expected friendship degree of a random \(u\in V\) is exactly \(\mu\). To guarantee that \(\Pr[u,v]\leq 1\) for all \(u,v\), the choice of \(\mu\) is subject to the condition  
\[\mu\leq\frac{2\cdot M}{N}\cdot\min_{u,v}\biggl{\{}\frac{A(g_{u},g_{v})}{M(g_{ u},g_{v})\cdot a(u,v)}\biggr{\}}\approx\frac{2\cdot M\cdot\langle D\rangle \cdot\langle f\rangle^{2}}{N\cdot\max_{u,v}\bigl{\{}g_{u},g_{v}\cdot a(u,v) \bigr{\}}}, \tag{6}\]  
where the approximation is obtained, again, assuming that \(A(i,j)\approx m_{i,j}\cdot\langle D\rangle\cdot\langle f\rangle^{2}\), and using that \(\min_{u,v}\frac{m_{g_{u},g_{v}}}{M(g_{u},g_{v})\cdot a(u,v)}=\frac{1}{\max_{u,v}g_{u},g_{v}\cdot a(u,v)}\). In other words, since, by increasing \(\mu\), we evenly increase the probability of all edges, the choice of \(\mu\) is possibly constrained by the existence of pairs \((u,v)\) for which the product \(s_{g_{u},g_{v}}\cdot a(u,v)\) is large, so as to make the existence of the edge \((u,v)\) significantly more likely than the average. The expected degree of a vertex \(u\) having fitness \(f_{u}\), age \(g_{u}\) and tile \(t_{u}\) can instead be computed as  
\[\mu_{u} =\mathbf{E}[\deg_{F}(u)\mid f_{u},g_{u},t_{u}]=\sum_{v}\Pr[u,v]= \sum_{t}\left[\sum_{j}\left(\sum_{v\in t,v\in V_{j}}\Pr[u,v]\right)\right]\] \[=\frac{\mu\cdot N\cdot f_{u}}{2\cdot M}\cdot\sum_{t}\left[D(t_{u },t)\cdot\sum_{j}\left(\frac{M(g_{u},j)}{A(g_{u},j)}\cdot\sum_{v\in t,v\in V _{j}}f_{v}\right)\right]. \tag{7}\]  
\(\mu_{u}\) is, thus, proportional to \(u\)'s social fitness \(f_{u}\) and to \(\mu\), as expected. Equation (7) also shows that \(\mu_{u}\) depends upon the tile \(t_{u}\) through a factor given by the average distance of \(t_{u}\) from all other tiles (included \(t_{u}\) itself), weighted by the (group-weighted) _total sociability_ of each tile. **Scale invariance and parameter range:** It is easy to verify that \(\Pr[u,v]\) is invariant under multiplication of \(s_{i,j}\), \(D(u,v)\), \(f_{u}\) and/or \(f_{v}\) by any positive constant. This means that any two approaches to derive the coefficients \(s_{i,j}\) from real data that only differ by a constant factor, are equivalent for our model. Now, for (2) to be meaningful, we need \(D(u,v)\) to be upper-bounded by a suitable constant \(D_{\max}\).