# Geographically Weighted Flow Cross K-Function for Network-Constrained Flow Data
## 2 Methods
### Global Geographically Weighted Flow Cross K-Function  
A network-constrained spatial flow \(f_{i}\) of type A can be expressed as \(<\)NO\({}_{i}\), ND\({}_{i}\), A\(>\), where NO\({}_{i}\) and ND\({}_{i}\) are the network-constrained origin point and network-constrained destination point of \(f_{i}\), respectively. The Euclidean distance is often used to calculate the distance of two spatial flows, which is based on the Euclidean distance between origin points and between destination points. However, the planar space assumption is not suitable for network-constrained spatial flows. To overcome this problem, the network distance, rather than the Euclidean distance, is applied to calculate the distance between origin points and between destination points. In this study, the network-constrained mean distance is utilized as the flow distance measurement:  
\[ND_{f}\left(f_{i},f_{j}\right)=\frac{ND_{p}\left(NO_{i},NO_{j}\right)+ND_{p} \left(ND_{i},ND_{j}\right)}{2} \tag{1}\]  
where ND\({}_{p}\) (NO\({}_{i}\), ND\({}_{i}\)) and ND\({}_{p}\) (ND\({}_{i}\), ND\({}_{j}\)) are the shortest path distances between the origin and destination points of network-constrained spatial flows \(f_{i}\) and \(f_{j}\), respectively. Given a distance threshold \(r\), if ND\({}_{f}\left(f_{i},f_{j}\right)\) is less than or equal to \(r,f_{i}\) and \(f_{j}\) are nearby flows to each other.  
Based on the Cross K-Function for points, [PERSON] (2019) proposed the Flow Cross K-Function by defining flow distance measurement under the assumption of planar space, which can be calculated as follows:  
\[FK_{A,B}(r)=\lambda_{B}^{-1}N_{A}^{-1}\sum\
olimits_{i}^{N_{A}}\sum\
olimits_ {j}^{N_{B}}I\left(d_{ij},\ r\right) \tag{2}\]  
where \(I(\cdot)\) is an indicator function; if \(d_{ij}\leq r\) (scale), then \(I=1\); otherwise, \(I=0\). \(d_{ij}\) is the Euclidean distance between spatial flows \(f_{i}\) and \(f_{j}\); \(\lambda_{B}\) is the intensity (number of spatial flows per unit area) of type B over the study area; \(N_{A}\) and \(N_{B}\) are the number of spatial flows of type A and type B, respectively. Although the Flow Cross K-Function can detect bivariate spatial flow patterns effectively, it may over-detect the bivariate spatial flow patterns of network-constrained spatial flows.  
By adopting the network-constrained mean distance and taking the effect of distance decay into account, this study proposes the Geographically Weighted Flow Cross K-Function for the network-constrained spatial flows:  
\[GWFK_{A,B}(r)=\lambda_{B}^{-1}N_{A}^{-1}\sum\
olimits_{i}^{N_{A}}\sum \
olimits_{j}^{N_{B}}w_{ij} \tag{3}\]  
\[w_{ij}=\left\{\begin{array}{cc}\exp\left(-0.5*\frac{nd_{ij}^{2}}{\left(r_{ max}\right)^{2}}\right)&if\ nd_{ij}\leq r\\ 0&otherwise\end{array}\right. \tag{4}\]  
where \(nd_{ij}\) is the network-constrained mean distance between spatial flows \(f_{i}\) and \(f_{j}\), \(r\) is the scale, \(w_{ij}\) is the weight of \(nd_{ij}\), \(r_{max}\) is the maximum of all scales. In this study, the Gaussian kernel density function is used to calculate weights. Because different bandwidths of the Gaussian kernel density function can lead to different results, we choose the maximum of all scales (\(r_{max}\)) as the bandwidth to ensure the consistency of results at different scales. The \(GWFK_{A,B}\) uses the weighted number of nearby spatial flows with the Gaussian kernel density function, whereas \(FK_{A,B}\) uses the number of nearby spatial flows to measure spatial associations (Equation (1)). Using the weighted number of nearby spatial flows can measure spatial associations in more detail. The spatial association captured by the Geographically Weighted Flow Cross K-Function is asymmetrical, which means that the strength of the spatial association between type A and type B (\(GWFK_{A,B}\)) can be different from that between type B and type A (\(GWFK_{B,A}\)).