## 2 Community Detection across Space and Its Variation across Time
### Community Detection across Space
#### 2.2.2 Algorithm  
Based on the integrated similarity measure, we then calculated the final distance for each pair of directly or indirectly connected nodes (i.e., cells) in the network traffic flow. \[fdis_{(N_{i},N_{j})}=\frac{1}{fsim_{(N_{i},N_{j})}} \tag{9}\]  
In the process of detecting community, the dissimilarity index for each pair of nodes is adopted, with which one can measure the extent of proximity between the nodes of a network and signify to what extent two nodes would 'like' to be in the same community [30]. This proximity reflects the connectivity property of nodes in a diffusion process. The final minimization problem under this distance can also be solved by a k-means algorithm [31]. For our community detection algorithm, we adopted the K-Medoids algorithm, which belongs to the family of k-means clustering. More specifically, we first calculate the distances between all the pairs of nodes, and then select \(k\) nodes (i.e., initial \(k\) medoids) which have the largest distance to each other. Secondly, we assign each node (except the nodes that have already been labeled) to its nearest cluster according to the distances measured on the network traffic flow. This process is iteratively conducted until the medoids do not change or the number of iterations is equal to the threshold. In addition, in the end of each iteration, the node that has the minimum sum of distances within the cluster is selected as the medoid. Our community detection algorithm is as follows (Algorithm 1):```
Input: A spatially embedded network consisting of nodes and edges with weight, the number of communities \(k\), the maximum number of iterations Max1. Output: A set of communities: C= {\(C_{1}\), \(C_{2}\),..., \(C_{k}\)}
1. Initialization: \(fdis_{(N_{i}N_{i})}=0\), iteration=0, ClusterCentriod [] C=null;
2. Node distance calculating: //calculate the distance between each pair of nodes. for each pair of nodes \(N_{i}\) and \(N_{j}\) (i + j) \(fsim_{(N_{i},N_{j})}=sim_{(N_{i},N_{i})}+Attr_{(N_{i},N_{i})}\); \(fdis_{(N_{i}N_{j})}=\frac{1}{fsim_{(N_{i},N_{j})}}\); endfor for each pair of nodes \(N_{i}\) and \(N_{j}\) (i = j) \(fdis_{(N_{i},N_{j})}=1\); endfor
3. Community detection based on the K-Medoids framework: Select \(k\) nodes that have the largest distance to each other as initial \(k\) medoids, i.e., {\(C_{1}\), \(C_{2}\),..., \(C_{k}\)}; Assign each node to the closest medoid;  While (the medoids do not change or iteration \(\leq\)Max1) for each node \(N_{i}\)  Assign \(N_{i}\) to the closest medoid \(C_{m}\) with min {\(fdis_{(N_{i},C_{m})}\)}; endfor for each cluster \(C_{j}\) (j\(\leq\)k)  Update the medoid of each community by detecting the node that has the minimum sum of distances within the cluster; endfor iteration++; endwhile Return the structure consisting of \(k\) communities: C= {\(C_{1}\), \(C_{2}\),..., \(C_{k}\)}. ```

**Algorithm 1**Community Clustering

### Variation of Community across Time

Besides the spatial heterogeneity, a transport system also has the dynamic property, and, in order to analyze such variation of a transport system across time, we propose a graph structure matching measurement (GSMM) between two network traffic flows sharing the node set. Specifically, as presented in previous sections, a network traffic flow in a specific time slice can be divided into several communities. In other words, the variation of a transport system across time can be represented as the change of the corresponding community structures. Hence, the GSMM measures the degree of matching between two community structures, i.e., two node sets. **Definition 6**. : _(Similarity of two node sets): Let \(S_{1}\) and \(S_{2}\) be two node sets, the similarity between \(S_{1}\) and \(S_{2}\) is defined as follows:_

\[Ssim_{(S_{1},S_{2})}=\frac{2|S_{1}\cap\ S_{2}|}{|S_{1}|+|S_{2}|} \tag{10}\]

_where \(|S|\) is the number of the nodes of set \(S\) and \(|S_{1}\cap\ S_{2}|\) is the number of the nodes that \(S_{1}\) and \(S_{2}\) share.