# Mapping Higher-Order Network Flows in Memory and Multilayer Networks with Infomap
## 3 Mapping Network Flows
### The Map Equation for First-Order Network Flows
In this case, there are no intermediate submodules and the two-level map equation is  
\[L(\mathsf{M})=q_{\curvearrow}H(\mathcal{Q})+\sum_{m=1}^{M}p_{m}^{\circlearrow}H( \mathcal{P}_{m}). \tag{24}\]  
Figure 3: Network flows at different modular levels. Large circles represent physical nodes, small circles represent state nodes, and dashed areas represent modules. (**a**) Finest modular level with physical nodes for first-order network flows; (**b**) Finest modular level with physical nodes and state nodes for higher-order network flows; (**c**) Intermediate level; (**d**) Coarsest modular level. Therefore, the two-module clustering gives best compression for all relax rates (Figure 4e). For the sparse memory network with six virtual physical nodes, the one-module clustering, \(\mathsf{M}_{1}^{\mathsf{6p}}\), has code length  
\[L(\mathsf{M}_{1}^{\mathsf{6p}})=\frac{6}{6}H\left(\frac{1}{6},\frac{1}{6},\frac {1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\right)\approx 2.58, \tag{29}\]  
and the two-module clustering, \(\mathsf{M}_{2}^{\mathsf{6p}}\), has code length  
\[L(\mathsf{M}_{2}^{\mathsf{6p}})=\frac{r}{6}H\left(\frac{r}{12},\frac{r}{12} \right)+2\frac{6+r}{12}H\left(\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{r}{12} \right)\approx[1.58,2.44]\text{ for }r\in[0,1]. \tag{30}\]  
While the two-module clustering again gives best compression for all relax rates, the code lengths are shifted by 1 bit compared with the memory network with twelve virtual physical nodes (Figure 4e). Same dynamics but different code length. These expanded solutions with virtual physical nodes do not capture the important and special role that physical nodes play as representatives of a system's objects. Properly separating state nodes and physical nodes as in Equation (26) instead gives equal code lengths for identical clusterings irrespective of representation. For example, the one-module clustering of the memory network with twelve state nodes, \(\mathsf{M}_{1}^{\mathsf{5p12s}}\), and the sparse memory network with six state nodes, \(\mathsf{M}_{1}^{\mathsf{5p6s}}\), have identical code length  
\[L(\mathsf{M}_{1}^{\mathsf{5p12s}})=L(\mathsf{M}_{1}^{\mathsf{5p6s}})=H\left( \frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{2}{6}\right)\approx 2.25, \tag{31}\]  
Figure 4: Mapping higher-order network flows. (**a**) A clustered multilayer network with relax rate \(r\); (**b**) The same network flows in a clustered second-order memory network; (**c**) The same network flows in a clustered sparse memory network; (**d**) Sample of corresponding higher-order flow pathways; (**e**) Code length as a function of the transition rate for all representations as well as extended networks with virtual physical nodes. because visits to a physical node's state nodes in the same module are aggregated according to Equation (25) such that those state nodes share code words and the encoding represents higher-order flows between a system's objects. Similarly, the two-module clustering of the memory network with twelve state nodes, \(\mathrm{M}_{2}^{\mathrm{5p128}}\), and the sparse memory network with six state nodes, \(\mathrm{M}_{2}^{\mathrm{5p6s}}\), have identical code length  
\[L(\mathrm{M}_{2}^{\mathrm{5p128}})=L(\mathrm{M}_{2}^{\mathrm{5p6s}})=\frac{r}{6 }H\left(\frac{r}{12},\frac{r}{12}\right)+2\frac{6+r}{12}H\left(\frac{1}{6}, \frac{1}{6},\frac{1}{6},\frac{r}{12}\right)\approx[1.58,2.44]\text{ for }r\in[0,1], \tag{32}\]  
That is, same dynamics give same code length for identical clusterings with proper separation of state nodes and physical nodes. For these solutions with physical nodes and state nodes that properly capture higher-order network flows, the overlapping two-module clustering gives best compression with relax rate \(r\lessapprox 0.71\) (Figure 4e). In this example, the one-module clustering can for sufficiently high relax rate better compress the network flows than the two-module clustering.