**2. Model and Method**

In this study, the maze is composed of nodes and edges that connect pairs of nodes. The number of nodes is finite, but pairs of nodes can be connected arbitrarily without limit. The distance between two nodes is given by the smallest number of edges connecting them. Therefore, only distances expressed in positive integers are considered. The start and goal can be placed at any node in the network, even at nodes that are not dead ends. To run the quantum walk, scattering matrices and state vectors are placed on nodes and edges, respectively, as in previous studies on SQWs [13].

The state vectors consist of two complex amplitudes, which express the two directions of the quantum walkers on the edges. As in quantum mechanics, the density of the walkers on an edge is given by the square of the complex amplitude. At each evolution of time, the vector of the incoming component is multiplied by the scattering matrix, generating the vector of the outgoing component. The scattering matrix of the *d*-dimensional unitary matrix is placed at each node, where *d* is the number of edges connected to that node. Specifically, we use the scattering matrix of the Grover walk, which, in concrete form, is given by

$$
\begin{pmatrix} b\_1 \\ b\_2 \\ b\_3 \\ \vdots \\ b\_d \end{pmatrix} = \begin{pmatrix} \frac{2}{d} - 1 & \frac{2}{d} & \frac{2}{d} & \cdots & \frac{2}{d} \\ \frac{2}{d} & \frac{2}{d} - 1 & \frac{2}{d} & \cdots & \frac{2}{d} \\ \frac{2}{d} & \frac{2}{d} & \frac{2}{d} - 1 & \cdots & \frac{2}{d} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ \frac{2}{d} & \frac{2}{d} & \frac{2}{d} & \cdots & \frac{2}{d} - 1 \end{pmatrix} \begin{pmatrix} a\_1 \\ a\_2 \\ a\_3 \\ \vdots \\ a\_d \end{pmatrix} \tag{1}
$$

where *ai* is the incoming complex amplitude from the *i*-th edge, and b*i* is the outgoing complex amplitude to the *i*-th edge. An example with *d* = 3 is given in Figure 1a.

To implement maze-solving, two self-loops and a sink are introduced, and the conceptual diagram is shown in Figure 1b. Self-loops are the same as edges except that they are only attached to a single node. As a result, a self-loop has a one-dimensional state vector, where the outgoing amplitude from the node becomes the next incoming amplitude without being modified. For this method, one self-loop is attached to the start node, and the other is attached to the goal node to which a sink node is also attached. The sink node has only one edge, which is connected to the goal node, and its scattering matrix is a zero matrix. The sink serves as the exit from the network for complex amplitudes.

**Figure 1.** Conceptual schematics of the numerical model. (**a**) Example of the time-evolution for a node with three edges injected with the amplitude 1 from one edge. (**b**) Setup of the start and goal with self-loops and a sink. The colors of the start (yellow), the goal (green), and the sink (blue) are unified in all the examples given later.

The initial amplitude "1" is placed at the self-loop of the start node. To discover the correct path, the initial amplitude should be placed on the path between the start and goal, and it should be kept at a distance from the sink node. In this method, placing the localized amplitude at the self-loop of the start node is the best initial condition for solving the maze correctly without requiring any prior knowledge of the structure of the maze. Finally, note that all the amplitudes in the system are denoted by the real numbers even though the quantum walks are defined using complex amplitudes.

Maze solving was studied for simple structures only because of the large amount of computational time involved by the current code (by the current code on our standard personal computer, the calculation of 10<sup>5</sup> steps took several hours because of unoptimized function–call overhead). For the maze without a cycle, a tree-like structure and a single line with branches were investigated. For the maze with a cycle, independent multiple paths and a ladder-like structure were investigated.

Two undesirable cases, namely, a maze with odd cycles and a maze showing eternal vibration are also investigated. For each kind of structure, the dependence of convergence steps on the size of the structure was investigated. The convergence was judged by the stability of the second decimal place for all the amplitudes in the network, and the convergence steps were expressed with an accuracy of one (or two) significant digits.

For discussion regarding the amount of amplitude remaining, about five digits after the decimal point were considered. The numerical error estimated from the squared sum of the amplitudes was of nearly the same order as the double-precision real number error computed using code written in Python. The source code is available in the repository [29].
