Introduction

Network neuroscience is an emerging discipline that tries to examine brain organizing principles using network science tools. It was made possible by the intersection of networks science and neuroscience1. This allows the merging of two worlds which have shown tremendous advancements in recent years. The first world is given by complex system studies through graph analysis2; the second is given by neuroimaging, which permits modeling of brain structure and function even representing relevant information as a graph3. Community (also called cluster or module) detection is an explored yet not solved task in many fields using graph representations4. Previous research has demonstrated how a modular structure can be used to highlight links between topological and functional aspects of complex networks that are not trivial5.

The human brain is a complex network made up of physically connected areas that can be activated when performing certain tasks or while at rest. Indeed, in network neuroscience, the most used connectivity representations are the functional and structural representations, though other representations exist, as the effective connectivity which attempts to combine these two. More specifically, functional connectivity represents the covarying activity of spatially separated brain areas observed in time series data as functional magnetic resonance imaging or electroencephalogram6. A graph is then built defining nodes as brain regions and edges according to the correlation of brain activity. Structural connectivity is referred to the physical pathways bridging brain areas, typically evaluated in-vivo by diffusion-weighted imaging7, or ex-vivo with staining and histological imaging8. In this case, a graph is defined as nodes also given by the brain regions and edges are the physical neuronal pathways. Effective connectivity refers to the impact one neurological system has over another, either at the level of individual neurons or entire brain regions. Hence, it naturally incorporates structural and functional information as it combines the neuronal activities related by physical pathways9. We do not focus particularly in this last type of connectivity as many recent criticisms raised concerns about its validity, as it can be seen as just temporal correlation10. The most plausible structural organization describing the complexity of brain functions is emerging as the integration of segregated regions (communities)11. Therefore, detecting communities in all types of connectivity is relevant, even though what community means in neuroscience is still an open question lacking absolute ground-truth or based on specific characteristic gathering group of neurons5.

Previous research in this context has focused on representing properties of isolated brain networks focusing on network features important to brain function. Those include variants of Newman’s modularity function2, and its maximization through Louvain-like algorithms12 for the detection of clusters of regions13. More advanced approaches have expanded this considering brain networks as dynamic and not static networks14, and information flow at different time scales15. Indeed defining communities in absolute terms has been discouraged in many fields16 especially considering possible nodes which can overlap communities and mislabeling. Truly, the brain is not composed by strictly segregated regions with defined regions as Broadmann introduced in 190917, but by a more intricate and integrate complex of segregated networks with smooth borders18.

The present work is not focused on defining the ideal community detection algorithm in brain connectomes, but rather we investigate if better clustering results can be achieved using quantum devices. This is motivated by the fact that modularity maximization heuristics have a demanding optimization problem at their core. Moreover, optimal solutions have been shown to be elusive to classical computing devices19.

Optimization problems in quantum devices rely on minimization and sampling from energy-based models via combinatorial techniques. The 2-communities modularity maximization problem is closely related to an Ising-like model20,21. Furthermore, its generalization to a k-state Potts model is exploitable for Simulated Annealing22 as well as its quantum partner, namely Quantum annealing (QA) algorithms23 (but see also a comprehensive review24). Consequently, we start by formulating the relationship between modularity and energy functions to later exploit them for detecting multiple communities in structural and functional brain graphs. Considering the Louvain algorithm as a reliable state-of-the-art estimate of the true result, we compare its performance in a desktop computer with results obtained with the D-Wave quantum computer20. More specifically, we tested on a real quantum annealer device, and not on simulators. Lastly, we consider networks with deterministic connections on quantum devices, and not quantum inspired networks on classical computing25,26.

Methods

In this section we first revise in detail how modularity is defined and how it is mapped into energy based model for both quantum and classical computing (sections “Modularity” and “Mapping to energy-based models”). Then we clarify how our community detection is implemented inside the quantum annealer (section “k-community detection with a QA processor”).

Let us define a brain connectome as \(G=(V,E)\) a weighted graph with nodes \(i,j \in V\) and edges \((i,j) \in E\). With V being brain regions defined by an atlas, and E edges a set of either physical neuronal pathways or correlation of brain activity, such that the corresponding adjacency matrix \({\textbf {A}}\) is defined as follows:

$$\begin{aligned} A_{i j}= {\left\{ \begin{array}{ll}0, &{} \text{ if } \quad i=j \\ w_{i j}, &{} \text{ if } \quad i \ne j\end{array}\right. } \end{aligned}$$
(1)

with \(w_{ij}\) representing the weight for edge between nodes i and j. These weights are the representation of number of neuronal fiber bundles or intensity of activity correlation. In our case, we define \(w_{ij} \in \{0, 1\}\) as a binary variable taking into account the existence of a connection between two nodes i and j. Moreover, the degree of a node is defined as \(g_i = \sum _{j} A_{ij}\), and it measures the number of connections for the node i quantified by summing over all its neighbors.

Modularity

Suppose that a graph contains \(|V|=n\) vertices and is divided into k communities or clusters denoted as \(\{C_1, \ldots , C_k\}\). Given a specified partition, the modularity is defined as22,27

$$\begin{aligned} Q = \sum _{s=1}^{k}\left[ \frac{l_s}{m}-\gamma \left( \frac{d_s}{2m}\right) ^2\right] , \end{aligned}$$
(2)

where \(2m = \sum _{i}g_i\) is the total number of edges,

$$\begin{aligned} l_s=\sum _{i \in C_s} \sum _{j \in C_s}A_{ij} \end{aligned}$$

is the number of links between nodes inside cluster \(C_s\) and

$$\begin{aligned} d_s=\sum _{i \in C_s}g_i \end{aligned}$$

is the sum of the degrees of the nodes belonging to the cluster \(C_s\). The resolution parameter \(\gamma \) defines the arbitrary trade-off between intra- and inter-group edges28. Conveniently29, and without loss of generality it can be set to 1, although we comment on other cases in later sections. The modularity as expressed in Eq. (2) is very convenient if the communities present in the graph are already known. However, if the number of communities k is unknown, the summation over s becomes a problem. To bypass this limitation, one can define a binary variable identifying nodes and/or links that are part of the same cluster. The most widely used proposal was defined in2.

For the sake of clarity, we start by having only two communities \(\{C_1, C_2\}\). In this simple case, let \(s_i = 1\) if vertex i belongs to community \(C_1\) and \(s_i = -1\) if it belongs to community \(C_2\). We can now define a variable \(\frac{1}{2}(s_is_j+1)\) that returns 1 if and only if vertices ij belong to the same community and 0 otherwise. Thus, the total number of existing edges between nodes in the same community can be rewritten as

$$\begin{aligned} l_{C_1} + l_{C_2} = \frac{1}{2}\sum _{ij}A_{ij}\frac{1}{2}(s_is_j+1) \end{aligned}$$
(3)

where the \(\frac{1}{2}\) factor has been added to avoid double counting. Moreover, the sum of the degrees in all communities can be easily replaced using the same procedure.

$$\begin{aligned} d^2_{C_1} + d^2_{C_2} = \sum _{ij}g_ig_j\frac{1}{2}(s_is_j+1) \end{aligned}$$
(4)

where the double summation over ij has been used instead of \(\left( \sum _{i \in s}g_i\right) ^2\) for completeness. With these changes we can express the modularity Q in Eq. (2) as

$$\begin{aligned} Q=\frac{1}{4m} \sum _{i j}\left( A_{i j}-\frac{g_i g_j}{2 m}\right) (s_i s_j+1)=\frac{1}{4m}\sum _{i j}\left( A_{i j}-\frac{g_i g_j}{2 m}\right) s_i s_j \end{aligned}$$
(5)

where the rightmost equality follows from \(2m=\sum _{i}g_i=\sum _{ij}A_{ij}\).

Despite replacing a single summation for two, Eq. (5) has two main advantages, the first one being its easy interpretability. In a graph, if edges are placed at random, the expected number of links between two nodes i and j can be shown to be precisely \(\frac{g_ig_j}{2m}\)2. Hence, the modularity Q can be understood as the difference between the actual number of edges and those expected by chance inside all the different communities. Second, proposing different sets of two communities is now straightforward. According to Eq. (5), modifying the variable \(s_i\) of even a single node yields a completely different partition and corresponding modularity. Hence, to cluster nodes by in ways that increases the modularity of a network can be achieved by trying out (i.e., sampling) different combinations of the variables \(s_i\) and keeping track of the resulting communities. Note that when sampling, the network’s nodes and connections do not change, but rather the community to which they belong do. We will explore the latter in more detail in the following section.

Furthermore, in many graphs, and especially in brain networks, the number of communities is expected to be considerably higher than just a couple. A straightforward generalization can be achieved by replacing the binary variable in the case of just two communities \(\frac{1}{2}(s_is_j+1)\) for a community agnostic Kronecker delta function \(\delta (c_i,c_j)\). Then the modularity is expressed as

$$\begin{aligned} Q=\frac{1}{2m} \sum _{i j}B_{ij}\delta (c_i,c_j) \end{aligned}$$
(6)

where \({\mathbf {B}}\) is known as the modularity matrix whose elements are given by

$$\begin{aligned} B_{ij} = A_{ij} - \frac{g_ig_j}{2m}, \end{aligned}$$
(7)

and \(\delta (c_i, c_j)\) is one if two nodes belong to the same cluster \(C_s\).

Eventually, the partition in k communities is chosen by the maximum modularity score Q as a function of k. Note that permutation of the rows and columns of an adjacency matrix \({\mathbf {A}}\) does not alter the graph nor its modularity. However, the output of an algorithm whose goal is to find the partition with highest modularity, could depend on how this adjacency matrix was defined initially. Interestingly, results on many test cases in the literature show that the ordering of the nodes tends to not have a significant influence on the outcomes therefore showing rather deterministic behaviors12,27.

Mapping to energy-based models

The conundrum of community detection aims at finding the graph partition that maximizes the modularity Q which, for the case of binary and undirected networks, lies between \(-\frac{1}{2}\) and 1. The problem can be solved using brute force by simply trying out all possible combinations of the variables \(s_i\), \(s_j\) (or \(\delta (c_i,c_j)\) for more than two communities), computing the associated modularities and eventually choosing the highest one. However, even for rather small graphs, this approach becomes unfeasible due to a rapid growth in complexity.

Alternative algorithms, such as the ones we use in the current work, use heuristic reasoning12 or exploration of state and energy spaces21,22. To use the latter, one needs to map the modularity function to a physical system. The simplest of such systems is known as an Ising model, shown to be very useful to study properties of phase transitions in magnetic systems. Consider a system with N particles whose magnetic spin is characterised by a discrete variable \(s_i \in \{-1, 1\}\). The energy of the given system immersed in an external magnetic field \({\mathbf {h}}\) is given by

$$\begin{aligned} {\mathscr {H}}({\mathbf {h}}, {\mathbf {J}}, {\mathbf {s}})=-\sum _i h_i s_i-\frac{1}{2}\sum _{ij} J_{i j} s_i s_j \end{aligned}$$
(8)

where \(s_i\) are the spins of each particle, \(h_i\) are the local magnetic fields and \(J_{ij}\) encodes the couplings strengths that encode the interactions between particles i and j. Usually, Eq. (8) is defined in a regular lattice only considering interactions between 1-st neighbours. Note, nonetheless, that the formulation is agnostic towards the specific spatial topology of the system. Taking this into consideration, it is direct to see that the modularity in Eq. (5) corresponds to an Ising system defined in a non-regular graph, with no external field and coupling matrix \({\mathbf {J}}=-\frac{1}{2m}{\mathbf {B}}\).

Furthermore, an Ising model can be easily extended to include more than two states. In this case, each i-th particle is fully characterised by a discrete variable \(s_i \in \{0, \ldots , k-1\}\) where \(k \in {\mathbb {Z}}^{+}\) is a positive integer denoting the number of possible states.

$$\begin{aligned} {\mathscr {H}}({\mathbf {h}}, {\mathbf {J}}, {\mathbf {s}})=-\sum _i h_i s_i-\frac{1}{2}\sum _{ij} J_{i j} \delta (s_i,s_j) \end{aligned}$$
(9)

where \(h_i\) is the local magnetic field and the Kronecker function is 1 when two particles are in the same state (i.e., \(s_i=s_j\)). Once again, the modularity in Eq. (6) straightforwardly matches a physical system known as Potts model with the same coupling constant \({\mathbf {J}}=-\frac{1}{m}{\mathbf {B}}\) and no external field. A physical system is said to be in thermodynamic equilibrium if the energy of the configuration, given by the successive spin variables \(s_i\), rests at a minimum. The problem of how to find this ground state has been widely studied and solved using different methods including, but not limited to, QA. In this subsection, we have reviewed how computing the modularity of a certain network organization is equivalent to obtaining the energy of a given magnetic system. Thereafter, we use the same procedures and strategies to find partitions that maximized the modularity or, alternatively, minimized its opposite in Eqs. (5) and (6). That is, we explored configurations \(C_s\) such that the corresponding modularity \(Q^*\) satisfied:

$$\begin{aligned} \max _{C_s} Q \ \ \ \ \text { or } \ \ \ \ \ \ \ \min _{C_s}-Q. \end{aligned}$$
(10)
Figure 1
figure 1

Simplified description of a Quantum Annealing (QA) process in (a). Initially, the system is prepared in the ground state of an “easy” hamiltonian \({\mathscr {H}}_0\) (solid blue line), in this case a simple cuadratic function of a variable describing the quantum state. The hamiltonian of the system, as in Eq. (11), is let to evolve adiabatically (dashed grey lines) resting at the minimum of each intermediate hamiltonian \({\mathscr {H}}(t)\) (coloured circles). Under these conditions, the final state, depicted as the big orange square, will correspond to the ground state of the desired system \({\mathscr {H}}_p\) (solid black line). Note that the two discrete jumps (green-purple and cyan-orange) are possible thanks to quantum tunneling. In (b), schematic representation of the logical process explained in the Methods. To partition a graph via QA, the connections of the original network, given by an adjaceny matrix as in Eq. (1), need to be mapped to a fully connected Ising-like system of spins. Note that the dimensions of the Ising system are the same as the original network (identical node coloring) but the strengths of the connections (solid weighted black lines) are now given by the modularity matrix in Eq. (7). The system is then embedded in a Chimera graph20 (i.e., the quantum processor) by using the D-Wave platform. Each node in the Chimera graph represents a qubit.

k-community detection with a QA processor

QA23,24 relies on the preparation of a physical quantum system whose Hamiltonian evolves according to

$$\begin{aligned} {\mathscr {H}}(t) = \Gamma (t) {\mathscr {H}}_0 + \Lambda (t){\mathscr {H}}_p \end{aligned}$$
(11)

where the ground state of \({\mathscr {H}}_0\) is “easy” to prepare and to measure experimentally. The functions \(\Gamma \) and \(\Lambda \) are both continuous and monotonously decreasing and increasing respectively such that \({\mathscr {H}}(0)={\mathscr {H}}_0\) and \({\mathscr {H}}(T)={\mathscr {H}}_p\). If initially the system is prepared in a way that lies at the ground state of \({\mathscr {H}}_0\), the process in Eq. (11) is adiabatic and \([{\mathscr {H}}_0,{\mathscr {H}}_p]\ne 0\) (i.e., the Hamiltonians do not commute), given the adiabatic theorem of quantum mechanics, the system should remain in the ground state at all times, thus ending up in the minimum of \({\mathscr {H}}p\). In this state, any measurement of the system’s elements shall return this ground state configuration. We provide a simplified description of this process in Fig. 1a.

The D-Wave hardware, known as a Chimera graph, consists of \(i=1,\ldots ,N\) qubits coupled with weights \({\mathbf {J}}\) whose energetic state \({\mathscr {H}}_p\) is described with an Ising Hamiltonian20. Therefore, any optimization problem to be solved using quantum annealing necessitates the reduction (or embedding) from its original description (e.g., (6)) to an enclosed embedded form of Eq. (8) in the Chimera graph (i.e., a mapping from G to \({\mathscr {H}}_p\)). The D-Wave platform autonomously embeds the problem to the processor30 (see Fig. 1b).

The modularity maximization problem naturally maps to a Potts model, also known as a Discrete Quadratic Model (DQM). However, a DQM variable \(s_i\) takes 1 of k possible discrete positive values which is not exactly an Ising spin. Yet, an alternative representation using one-hot encodings facilitates the previously mentioned reduction. A vector \({\mathbf {x}}_i\) is defined such that \(x_{iu}=1\) if \(s_i=u\) and 0 otherwise. This way we obtain a quadratic model subject to the constraint \(\sum _u x_{iu}=1\) that is easily transformed to an Ising representation with the mapping \(s_{iu}=2x_{iu}-1\). Below, we provide snips of the Python code that reduces the original network object to an Ising model with which the D-Wave system performs the optimization to better understand how it is implemented. Fortunately, the D-Wave platform provides a straightforward way to do this. We used Networkx31 to compute the modularity matrix from an adjacency matrix \({\mathbf {A}}\) in Eq. (1). The reduction is based on the modularity matrix \({\mathbf {B}}\) in Eq. (7) and the expression of the coupling matrix \({\mathbf {J}}\) for the quadratic term in Eq. (9). Recall that the external field \({\mathbf {h}}\) need not be added. The DiscreteQuadraticModel class contains this model, and its methods provide convenient utilities with the specific representation of a problem.

figure a

The nested loop is used to express all the possible communities a single node can be assigned to as well as to set the corresponding coupling weight given by Bij. Note that the total number of edges m is constant and thus it does not modify the relevant ground state. The code, also skips self-referenced nodes. The token can be obtained by logging into https://cloud.dwavesys.com/leap/. The final result is a sample set assigning each node to a particular community.

figure b

We have used the Leap Hybrid Solver developed by D-Wave. In contrast to the D-Wave 2000Q, this solver service can read and accommodate very large problems. The classical part allocates quantum processing units to specific parts of the problem to optimize, these parts being different algorithm steps. This approach leverages unique problem-solving capabilities of the quantum processing units and extends these capabilities to larger and more varied types of inputs. It can be called through the D-Wave Ocean application programming interface (API) hence facilitating its usage to non-specialists.

In our experiments we investigated how similar the detected communities were to an external proxy both using classical and quantum computing. Where no ground-truth is available, we considered the results of the eigengap, from spectral communities analysis, to be the aforementioned proxy. With the eigengap heuristic, the number of communities is usually given by the value of k that maximizes the difference between two consecutive eigenvalues. We kept track of the three largest eigengaps. Then, we computed the modularity index obtained by 100 runs. The third eigengap acted as a limit to see whether the optimization identified the same number of communities or reached higher modularities with less communities.

Finally, we run the same calculation using the Louvain Community Detection Algorithm (LCDA) to solve the community detection problem. The Louvain Community Detection Algorithm is a state-of-the-art heuristic to extract the community structure of a network based on modularity optimization12. Given the nature of one of the datasets described later as representing a debated ground-truth16, we consider both the case of known and unknown number of communities for this dataset. As in previous similar studies32,33,34, we consider higher modularities as a proxy for better results. Statistical significance is also investigated.

Data and code availability

In this study, we performed experiments using 2 datasets. The first is a well-known dataset (Zachary karate club35) which has been investigated in several community detection studies (e.g.27). The second dataset is given by the brain connectomes comprised in the BrainNet Viewer Toolbox defined from atlases36, which are the main focus of the study. Both datasets are based on previously acquired data from previous studies, and our analysis represents a numerical simulation study for which no ethical approval was required. The karate club dataset was created by Zachary by observing 34 members of a karate club over a period of 2 years, where a partition of the members happened, and a network of friendships between members of the club was observed. This was previously done by Zachary et al. in accordance with relevant guidelines and regulations35, for more details and contacts on their ethical approval please find all information in their original paper35. The dataset has been traditionally defined as a ground-truth subdivision of 2 communities35 as shown in Supplementary Fig. 1. However, communities defined by a specific ground-truth labeling can be misleading and not necessarily reflect the network topology16, and in fact higher number of communities in this dataset have been investigated37. Therefore, we consider both the cases whether this labeling should be restricted to 2 communities and not. This toy example is really useful to validate the modularity in case of a known information flow example. The dataset is freely available at the URL https://networkrepository.com/soc-karate.php.

The brain connectivity dataset are obtained from the examples of BrainNet Viewer and freely available at the URL https://www.nitrc.org/projects/bnv/. More specifically, the Automated Anatomical Labeling (AAL) which is the most common atlas for structural connectivity38 comprising 90 regions of interest and the Dosenbach atlas which is a functional atlas with 160 regions of interest. For the details of how those regions are used as nodes to construct the networks within BrainNet Viewer, we refer to their paper36. There is no particular reason to use this dataset apart the fact that those are brain connectomes publicly available. The basic properties of the networks used in the experiments are reported in Supplementary Table 1.

The code was written in Python version 3.9.7, and it is available at the repository https://github.com/alecrimi/clustering-dwave, it comprises a series of custom scripts and the usage of the Networkx library version 2.8.339, and the Dwave-system library version 1.10 with all initialization parameters for the NetworkX implementation of LCDA were left empty.

The used hardware were respectively for quantum and classical computing: the D-Wave 2000Q with Chimera edges, and a powerful workstation with 11th Gen Intel(R) Core(TM) i9-11900KF @ 3.50GHz processor.

Results

In this section, we report the results obtained by using the aforementioned tools on the 2 datasets. We report here first the resulting eigengap for both datasets, the communities are defined by modularity and the value of modularity.

Karate club dataset

Computing the eigengap Fig. 3a within the karate club dataset we found that the highest gaps were related to \(k=3,4,2\). The highest eigengap was given by \(k=4\), while the original defined number of communities is \(k=2\)35.

Forcing both the classical and quantum community detection algorithm to look for 2 communities, both algorithms were able to assign correctly all members of the defined communitiesm (as shown in Supplementary Fig. 1. It is relevant to mention that to reach this goal, the resolution parameter \(\gamma \) in Eq. (2) had to be set smaller than 1. For all other experiments, we considered the more standard value \(\gamma =1\).

Following the experiments in an unsupervised manner as described in the previous section, the classical and quantum algorithm showed different results. In Fig. 2 we show the differences of the communities obtained by using classical and quantum computing. It can be seen that only 2 communities (depicted in red and blue) have different grouping. In Table 1 we can see summarized the modularity index for both classical and quantum device. As shown in literature12,27, the methods behave in a rather deterministic manner and as our results show the quantum hardware noise were close to zero even considering a large number of repeated experiments. Results are shown in Table 1. Note that the results of the LCDA as implemented in NetworkX31 slightly differ from what is found in the literature12,32 (see also Supplementary Fig. 2).

Figure 2
figure 2

Community detection for the Zachary karate club graph using Louvain Community Detection Algorithm (a), and using Leap Hybrid Solver (b). We can observe that the assignment to communities differs for these 2 methods in the red and blue communities.

Table 1 Results of community detection on the karate club dataset.

Brain connectivity

The eigengaps for the two brain connectome are depicted in Fig. 3b and c. We found some high eigengaps at the end of the spectrum, namely where we consider each node as a cluster. This might make sense as nodes in brain atlases represent an already relatively large region of interest according to functional activation of cytoarchitecture. Namely, those are already clusters of neurons or brain activity. However, this will not be interesting given the research question of this paper. The 3 largest eigengaps were, respectively, for the AAL and Dosenbach atlas: 4,5,11 and 7,11,27. Comparing the modularity obtained on classical and quantum devices with AAL90 and Dosembach brain connectivity graphs, we found different modularity indices reported in Table 2. The resulting communities are shown in Figs. 4 and 5 respectively for the AAL and Dosenbach atlas. The computational times for each algorithm are also reported in Table 2.

For the AAL atlas connectome, if we look for 5 communities as depicted in Fig. 4, those appear to be almost the traditional brain lobe subdivision: subcortical regions (yellow), occipital lobe (red), temporal medial (cyan), fronto-temporal medial including the default mode network (blue), fronto-temporal lateral (green). The parietal lobe was spread across the neighbouring.

For the Dosenbach parcellation, despite the difficulties of the methodology for identifying meaningful partitions, a large-scale pattern was observed, which mostly differentiated visual, sensory-motor and dorsal attention regions. More specifically, in Fig. 5 we can see nine clusters depicted: the visual network comprising the occipital lobe but also some parietal regions (yellow) as previously described40, lateral temporal-parietal (mild green), extended default mode network (DMN) (dark blue), mostly thalamus and basal ganglie (magenta), cerebellum, anterior cingulate cortex and supplementary motor area (orange), superior temporal (light green), some region of post-insula and temporal (dark green). The red cluster connected only two regions in the occipital lobe, and the light blue cluster only two regions in the parietal lobe. The acronyms of the brain regions are the same as reported in38. Statistical significance for all three dataset is depicted in Fig. 6.

Figure 3
figure 3

Eigengaps for the Karate club cluster (a), AAL90 brain atlas (b), and Dosenbach brain atlas (c). The red lines highlight the highest gap for each case, while the blue line the second highest gap. For the AAL (in b), the second eigengap is directly visible thus we explicitely mark the third. Last eigenvalues are not taken into consideration.

Table 2 Results of community detection on the benchmark brain atlases.
Figure 4
figure 4

Graph partitioning of the communities defined by using QA for the AAL atlas. Left: Reordered connectivity matrix according to module assignment. Right: Axial, coronal, and 2 hemispheres sagittal views of brain connectivity (plotted using the BrainNet Viewer Toolbox36). In both cases, connections and nodes belonging to the same community are plotted using the same color code while grey edges correspond to connections between different modules. The size of the nodes is given by the degree.

Figure 5
figure 5

Graph partitioning of the communities defined by using QA for the Dosenbach atlas. Left: Reordered connectivity matrix according to module assignment. Right: Axial, coronal, and 2 hemispheres sagittal views of brain connectivity (plotted using the BrainNet Viewer Toolbox36). In both cases, connections and nodes belonging to the same community are plotted using the same color code while grey edges correspond to connections between different modules. The size of the nodes is given by the degree.

Discussion

The human brain exhibits an organization of a small-world network, with segregated modular regions integrated by some hub nodes11. The use of connectomes as biomarkers has seen increasing use, and clustering features have also been introduced as both functional and structural network changes according to brain diseases41. Indeed, data driven approaches have being increasingly implemented to investigate relationships between brain connectivity pathology, for instance Alzheimer’s disease42. Therefore, it is crucial to increase the precision of clustering brain connectivity representations.

In the presented work we investigated the capacity of a quantum annealer to perform clustering on brain connectivity data. We focused on comparing the clusters obtained with the same data by using classical and quantum computing on a D-Wave machine. The modularity metric was used to assess the quality of a community organization. This metric has values between \(-\frac{1}{2}\) and 1, where the highest value is considered an indicator of better topological organization2,33.

The maximum number of clusters to detect is a parameter required by both algorithms we tested. Yet, in both cases, the algorithm was free to assign each node to any module which, in some cases, resulted in empty communities. In practice, this meant that both classical and quantum approaches could partition the graph into any number of communities only bounded by the maximum number of modules allowed. Communities obtained using the quantum device showed consistent and observable higher modularity indices, as shown in Fig. 6. Indeed, higher modularity indices are often considered as a measure of superiority for community detection algorithms34,43. This is in agreement with previous work comparing clustering with different datasets and similar settings21.

Figure 6
figure 6

Left: Percentage of relative increase of the QA result with respect to LCDA [MEAN±SEM]. Significancy (p<0.05, one-sided Welch’s t-test) is indicated in red. See exact values in Table S2. Errors bars were computed by propagating the SEM of the results with LCDA and QA. Dashed black line indicates the no increase threshold. Right: Effect size measured by Cohen’s d. Horizontal dashed and colored lines separate effect sizes according to standard thresholds. Cohen’s d is a measure of the effect size present in the two populations without assessing the statistical significance.

Interestingly, the number of modules found by the quantum device was consistently smaller despite reaching higher modularity. We might argue that LCDA overestimated the number of clusters, resulting in fewer edges between nodes within a given community. Were this to occur, the modularity index would decrease, since the number of edges expected by chance, as quantified in Eq. (5), remains unaltered. Furthermore, in the two brain graphs tested, the k-th eigengap corresponding to the assignment of k clusters was higher (Fig. 3b and c), which might be indicative of the significance of the obtained partition. Nonetheless, the lack of ground-truth for brain cases represents a limitation. We chose to compare QA to LCDA because the latter is considered as the state-of-the-art method despite being developed more than 10 years ago. However, alternative algorithms have recently been proposed that seem to show significant potential (see for example traversal-based methods44 or variations of LCDA43,45). Those address issues such as computational speed, detection of small communities compared to the average communities in the network and robustness to different initializations.

A puzzling question arises when trying to understand why QA finds higher modularity indices. To this end, we note that by enforcing both QA and LCDA to find 2 communities in the Karate club graph, the results were identical. We may hypothesize that the energetic landscape to explore in these limited conditions is simple, hence both algorithms successfully find the unique isolated minimum (e.g., minimum of a parabolic function). However, the unsupervised problem (i.e., not imposing a fixed number of communities) or the presence of large networks may add significant complexity46. Crucially, QA does not travel through the exact shape of the landscape23 hence providing a possible bypass to this issue (Fig. 1a).

Compared to previous studies based on the binary subdivision of hierarchical clustering21,47, our approach can handle odd numbers of clusters and settings where the value k is not a power of 2. Moreover, it is worth mentioning that the quantum results are stable even considering potential hardware problems known in this type of devices48, indeed we found a close to zero standard deviation repeating the experiments 100 times.

In our experiments with brain connectomes, we used two different types of brain connectome (both structural and functional) to test our algorithm by investigating differences. Interestingly, in both cases, the quantum algorithm obtained higher modularity. In this study, we avoided investigating the clinical outcomes related to clustering either structural or functional brain connectomes, as this is beyond the focus of this paper. Nevertheless, the brain communities obtained on the quantum device significantly resembled the conventional subdivision of brain structures.

Connectivity-based approaches tend to generally find at least 6 minimal clusters49. As we also found, one cluster is generally represented by the visual system (occipital cluster). In fact, even at coarse scale (4–6 clusters), the visual system generally represented a separate community from the somatosensory system and others50. Somatomotor communities usually remains connected. As in our results, there is a cluster spanning several midlines (medial prefrontal cortex and posterior cingulate cortex), defining the so-called default mode network: A popular network involved in wakeful rest, daydreaming and mind-wandering51. This division was present in both the structural and functional atlas-based connectomes of our experiments.

A concerning limitation of the proposed approach was the computational time. We noticed that the quantum annealer took a considerably larger amount of time than its classical counterpart. The speed was not dependent on the communication between the client and the quantum computer, but we believe it was related to the current configuration of the qubits and the solver. Successfully performing QA in system of qubits relies on smooth, adiabatic transitions (i.e., quantum tunneling) between the ground states of two energetic landscapes (see Eq. (11)). Eventually, these transitions govern the computational complexity and time52. Several factors can influence this complexity, including the number of nodes in a graph. However, solutions found through QA were more stable than expected, with not much noise and even achieving higher scores. Physical limitations on the D-Wave platforms currently in use include finite precision, sparse connectivity, and a finite amount of qubits which are connected in a Chimera graph. It can be hypothetized that having more qubits during computation and increased connectivity will improve the performance of this technique. In our approach, the community detection problem for the Zachary graph problem has been solved by using a more elegant solution than in the paper21. In that approach, a challenging aspect was also given splitting the graph into pieces supported by the combined effect of qbsolv53 and the annealing process.

Another group of quantum optimization techniques employ a quantum version of a network model from the early 1980s commonly used to model associative memory54. This approach differs from ours in that the optimization problem is encoded in a Hopfield network instead of an Ising-like system55,56. In practice, the resulting Hopfield encoding can be optimized by any available procedure including but not limited to QA57 and have, in fact, already been implemented on actual quantum processing units58. Successful applications of this approach include image restoration59, pattern-recalling60 and recognition of genetic sequences56. As far as we know, nonetheless, its application to community detection problems remains unexplored. New optimization strategies such as the Hopfield network encoding and the usage of alternative quantum processing units deserve further study58,61. Moreover, in future studies we will expand individual analysis of brain connectomes to multi-layer connectomes14 and to common eigenspaces of networks from population studies9.

Conclusion

In this article, we rigorously described how sampling spin-like variables can be used to find communities that yield high modularity organizations in networks. We have explored the potential of quantum computing for brain community detection, utilizing a quantum annealer to tackle an NP hard optimization problem. The analysis show that the quantum computer is capable of rendering a highly efficient community structure with a modularity superior to classical computing. One of the most noteworthy results from applying this QA process is that the community structure is obtained “all at once” in the technique within the annealing period and we can compute any number of clusters in contrast with previous approaches which could compute only power of 2 number of clusters.