# Physarum-Inspired Bicycle Lane Network Design in a Congested Megacity
## 3 Physarum-Inspired Bicycle Lane Network Design
### Physarum-Inspired BLN Design Method
#### 3.2.4 Complete Algorithm of BLN Design  
Algorithm 1 shows the complete steps of the proposed BLN design. The method takes pressure (\(p\)), link length (\(L\)) and link hinder (\(h\)) as input for a particular road environment; it returns \(BLN\) as a selected number of links for the bicycle lane network, based on the provided data. In initialization, links' conductivity (\(D_{\bar{i}j}\)) and the accumulated pressures of individual nodes (\(P_{i}\)) are prepared accordingly. The viscosity (\(\epsilon\)), total number of nodes (\(N\)), and the conductivity decay (\(\mu\)) are used at different steps.  
```
//\(p\) is a 1D pressure matrix, where \(p_{i}\) denotes pressure of individual node \(i\) //\(L\) is a \(n\times n\) matrix, \(L_{ij}\) denotes the length of link \(e_{ij}\) between node \(i\) and node \(j\) //\(h\) is a \(n\times n\) matrix, \(h_{ij}\) denotes the hinder value of link \(e_{ij}\) between node \(i\) and node \(j\) //\(i\) is the viscosity value, \(N\) is total number of nodes, and \(\mu\) is the conductivity decay //\(\delta\) is a threshold value of conductivity // Maxltrn is the Maximum Number of Iteration as the termination criteria //\(D\) is a \(n\times n\) matrix, \(D_{ij}\) denotes the conductivity between node \(i\) and node \(j\) //\(Q\) is a \(n\times n\) matrix, \(Q_{ij}\) denotes the flux between node \(i\) and node \(j\)  Set links' initial conductivity \(D_{ij}\) according to Equations (4) and (5)  Normalize links' conductivity according to Equation (12)  Calculate accumulated pressure of each individual nodes \(P_{i}\) according to Equations (6) and (7)  For\(itr=1\): Maxltrndo  //Flux Update For\(i=1\): Ndo For\(j=i+1\): Ndo \(Q_{ij}\gets D_{ij}\times(P_{i}+P_{j})\) // Using Equation (8) endfor  //Conductivity Update For\(i=1\): Ndo For\(j=i+1\): Ndo \(\Delta D_{ij}\leftarrow\left|Q_{ij}\right|-\mu D_{ij}\) //UsingEquation(10) \(D_{ij}\leftarrow\left.D_{ij}+\Delta D_{ij}\right.\) //UsingEquation(11) endfor  endfor  Normalize links' conductivity according to Equation (12) \(itr\getsitr+1\) endfor  //Bicycle Lane Network Construction  BLN = [ ] // Empty For\(i=1\): Ndo For\(j=i+1\): Ndo  If\((D_{ij}\geq\delta)\mid\mid\) (Traversal discontinued without \(e_{ij}\))  BLN = BLN \(\cup\)\(e_{ij}\) // / Include the link in the network endif endfor  endfor returnBLN
```  
**Algorithm 1** Physarum-inspired Bicycle Lane Network Design (\(p\),\(L\),\(h\))  
The main task of the conductivity update is performed in an iterative process up to a maximum number of iterations (i.e., _Maxltrn_), the termination criteria of the algorithm. At every iteration, the individual links' flux are measured first, and then conductivity is updated. In this study, bidirectional flows are considered and flux and conductivity matrixes are assumed to be symmetrical; thus, the nodal loop is optimized as \(i=1\): \(N\) and \(j=i+1\): \(N\). Finally, the _BLN_ is populated with selected links based on its conductivity value comparing with a threshold value (\(\delta\)) and its importance to make the network traversable.