Community Detection in Quantum Complex Networks

Determining community structure is a central topic in the study of complex networks, be it technological, social, biological or chemical, in static or interacting systems. In this paper, we extend the concept of community detection from classical to quantum systems---a crucial missing component of a theory of complex networks based on quantum mechanics. We demonstrate that certain quantum mechanical effects cannot be captured using current classical complex network tools and provide new methods that overcome these problems. Our approaches are based on defining closeness measures between nodes, and then maximizing modularity with hierarchical clustering. Our closeness functions are based on quantum transport probability and state fidelity, two important quantities in quantum information theory. To illustrate the effectiveness of our approach in detecting community structure in quantum systems, we provide several examples, including a naturally occurring light-harvesting complex, LHCII. The prediction of our simplest algorithm, semiclassical in nature, mostly agrees with a proposed partitioning for the LHCII found in quantum chemistry literature, whereas our fully quantum treatment of the problem uncovers a new, consistent, and appropriately quantum community structure.

The identification of the community structure within a network addresses the problem of characterizing the mesoscopic boundary between the microscopic scale of basic network components (herein called nodes) and the macroscopic scale of the whole network [1][2][3]. In nonquantum networks, the detection of community structures dates back to Rice [4]. Such analysis has revealed countless important hierarchies of community groupings within real-world complex networks. Salient examples can be found in social networks such as human [5] or animal relationships [6], biological [7][8][9][10], biochemical [11] and technological [12,13] networks, as well as numerous others (see [1]). In quantum networks, as researchers explore networks of an increasingly non-trivial geometry and large size [14][15][16], the tractability of their analysis and understanding may rely on identifying relevant community structures. In this article, we devise methods to perform this task. The results here form an important component in the recent drive to unite quantum physics and complex network science [17][18][19]. Extending the concept of community detection to apply to quantum systems is a crucial step towards the ultimate goal of creating a theory of networks that augments the current statistical mechanics approach to complex network structure, evolution, and process with a new theory based on quantum mechanics.
As a motivating application, we point to the quantum biological simulation of exciton transport in dissipative networks [20][21][22][23][24][25]. The amount of resources used to accurately simulate such processes scales exponentially with the number of nodes. To overcome this, one can imagine * Electronic address: mauro.faccin@isi.it dividing the network in what we would call communities and using this new structure to simplify the computational task of numerically simulating the system. In past works, researchers have divided the light harvesting complex II (LHCII) by hand in order to gain more insight into the system dynamics [26][27][28]. Our methods optimize the task of identifying communities within a quantum network ab initio and, as we will show, the resulting communities consistently point towards a structure that is different to those previously identified for the LHCII. We also consider larger networks, for which an automatic method would appear to be the only feasible option.
Our specific approach is to generate a hierarchical community structure [29] by defining both inter-node and inter-community closeness. The optimum level in the hierarchy is determined by a modularity-based measure, which quantifies how good a choice of communities is for the quantum network on average relative to an appropriately randomized version of the network. While the backbone of our quantum community method is shared with classical methods, the details are very different and the extension is quite non-trivial. Two quantum properties are used to obtain closeness and modularity functions: the first is the coherent transport between communities and the second is the change in the states of individual communities during a coherent evolution.
In Section I we will begin by recalling several common notions from classical community detection that we rely on in this work. This sets the stage for the development of a quantum treatment of community detection in Section II. We then turn to several examples in Section III including the LHCII complex mentioned previously, before concluding in Section IV.

I. COMMUNITY DETECTION
Community detection is the partitioning of a set of nodes N into non-overlapping 1 and non-empty subsets A, B, C, . . . ⊆ N , called communities, that together cover N .
There is usually no agreed upon optimal partitioning of nodes into communities. Instead there is an array of approaches that differ in both the definition of optimality and the method used to achieve, exactly or approximately, this optimality (see [3] for a recent review). In classical networks optimality is, for example, defined statistically [30], e.g. in terms of connectivity [1] or communicability [31,32], or increasingly, and sometimes relatedly [33], in terms of stochastic random walks [34][35][36]. Our particular focus is on the latter, since the concept of transport (e.g. a quantum walk) is central to nearly all studies conducted in quantum physics. As for achieving optimality, methods include direct maximization via simulated annealing [10,37] or, usually faster, iterative division or agglomeration of communities [38]. We focus on the latter since it provides a simple and effective way of revealing a full hierarchical structure of the network, requiring only the definition of the closeness of a pair of communities.
Formally, hierarchical community structure detection methods are based on a (symmetric) closeness function c(A, B) = c(B, A) of two communities A = B. In the ag- Figure 1: Hierarchical community structure arising from a quantum evolution. On the left are the closenesses c(i, j) between n = 60 nodes. On the right is the dendrogram showing the resulting hierarchical community structure. The dashed line shows the optimum level within this hierarchy, according to the modularity. The particular example shown here is the one corresponding to Fig. 3d. glomerative approach, at the lowest level of the hierarchy, the nodes are each assigned their own communities. An iterative procedure then follows, in each step of which the closest pair of communities (maximum closeness c) are merged. This procedure ends at the highest level, where all nodes are in the same community. To avoid instabilities in this agglomerative procedure, the closeness function is required to be non-increasing under the merging of two communities, c(A ∪ B, C) ≤ max(c(A, C), c(B, C)), which allows the representation of the community structure as a linear hierarchy indexed by the merging closeness. The resulting structure is often represented as a dendrogram (as shown in Fig. 1). 2 This leaves open the question of which level of the hierarchy yields the optimal community partitioning. If a partitioning is desired for simulation, for example, then there may be a desired maximum size or minimum number of communities. However, without such constraints, one can still ask what is the best choice of communities within those given by the hierarchical structure.
A type of measure that is often used to quantify the quality of a community partitioning choice for this purpose is modularity [40][41][42], denoted Q. It was originally introduced in the classical network setting, in which a network is specified by a (symmetric) adjacency matrix of (non-negative) elements A ij = A ji ≥ 0 (A ii = 0), each off-diagonal element giving the weight of connections between nodes i and j = i 3 . The modularity attempts to measure the fraction of weights connecting elements in the same community, relative to what might be expected. Specifically, one takes the fraction of intra-community weights and subtracts the average fraction obtained when the start and end points of the connections are reassigned randomly, subject to the constraint that the total connectivity k i = j A ij of each node is fixed. The modularity is then given by where m = 1 2 i k i is the total weight of connections, B is the modularity matrix with elements B ij = A ij − k i k j /2m, and C is the community matrix, with elements C iA equal to unity if i ∈ A, otherwise zero. The modularity then takes values strictly less than one, possibly negative, and exactly zero in the case that the nodes form a single community.
As we will see, there is no natural adjacency matrix associated with the quantum network and so for the pur-2 In general it may happen that more than one pair of communities are at the maximum closeness. In this case the decision on which pair merges first can influence the structure of the dendrogram, see [29,39]. In [29] a permutation invariant formulation of the agglomerative algorithm is given, where more than two clusters can be merged at once. In our work we use this formulation unless stated otherwise. 3 As will become apparent, we need only consider undirected networks without self-loops.
poses of modularity we use A ij = c(i, j) for i = j. The modularity Q thus measures the fraction of the closeness that is intra-community, relative to what would occur if the inter-node closeness c(i, j) were randomly mixed while fixing the total closeness k i = j =i c(i, j) of each node to all others. Thus both the community structure and optimum partitioning depend solely on the choice of the closeness function. Finally, once a community partitioning is obtained it is often desired to compare it against another. Here we use the common normalized mutual information (NMI) [43][44][45] as a measure of the mutual dependence of two community partitionings. Each partitioning X = {A, B, . . . } is represented by a probability distribution P X = {|A|/|N |} A∈X , where |A| = i C iA is the number of nodes in community A. The similarity of two community partitionings X and X ′ depends on the joint distribution is the number of nodes that belong to both communities A and A ′ . Specifically, NMI is defined as Here H(X) is the Shannon entropy of P X , and the mutual information I(X, X ′ ) = H(X) + H(X ′ ) − H(X, X ′ ) depends on the entropy H(X, X ′ ) of the joint distribution P XX ′ . The mutual information is the average of the amount of information about the community of a node in X obtained by learning its community in X ′ . The normalization ensures that the NMI has a minimum value of zero and takes its maximum value of unity for two identical community partitionings. The symmetry of the definition of NMI follows from that of mutual information and Eq. (2).

II. QUANTUM COMMUNITY DETECTION
The task of community detection has a particular interpretation in a quantum setting. The state of a quantum system is described in terms of a Hilbert space H, spanned by a complete orthonormal set of basis states {|i } i∈N . Each basis state |i can be associated with a node i in a network and often, as in the case of single exciton transport, there is a clear choice of basis states that makes this abstraction to a spatially distributed network natural.
The partitioning of nodes into communities then corresponds to the partitioning of the Hilbert space H = A∈X V A into mutually orthogonal subspaces V A = span i∈A {|i }. As with classical networks, one can then imagine an assortment of optimality objectives for community detection, for example, to identify a partitioning into subspaces in which inter-subspace transport is small, or in which the state of the system remains relatively unchanged within each subspace. In the next two subsections we introduce two classes of community closeness measures that correspond to these objectives. A more detailed derivation can be found in the Supplementary Material.
Our closeness measures take into account the full unitary evolution of an isolated system governed by its Hamiltonian H. Rather than being applicable to isolated systems only however, this type of community partitioning could be used, among other things, to guide the simulation or analysis of a more complete model in the presence of an environment, where this more complete model may be much more difficult to describe.
A. Inter-community transport Several approaches to detecting communities in classical networks are based on the flow of probability through the network during a classical random walk [33-36, 46, 47]. In particular, many of these methods seek communities for which the inter-community probability flow or transport is small. A natural approach to quantum community detection is thus to consider the flow of probability during a continuous-time quantum walk, and to investigate the change in the probability of observing the walker within each community: where ρ(t) = e −iHt ρ(0)e iHt is the state of the walker, at time t, during the walk generated by H, and where Π A = i∈A |i i| is the projector on the A subspace, is the probability of a walker in state ρ being found in community A upon a von Neumann-type measurement. 4 The initial state ρ(0) can be chosen freely. The change in inter-community transport is clearest when the process begins either entirely inside or entirely outside each community. Because of this, we choose the walker to be initially localized at a single node ρ(0) = |i i| and then, for symmetry, sum T X (t) over all i ∈ N . This results in the particularly simple expression where R(t) is the doubly stochastic transfer matrix whose elements R ij (t) = | i|e −iHt |j | 2 give the probability of transport from node j to node i, and R(t) its symmetrization. This is reminiscent of classical community detection methods, e.g. [36], using closeness measures based on the transfer matrix of a classical random walk. We can thus build a community structure that seeks to reduce T X (t) at each hierarchical level by using the closeness function where the numerator is the decrement in T X (t) caused by merging communities A and B. The normalizing factor in Eq. (6) avoids the effects due to the uninteresting scaling of the numerator with the community size. Since a quantum walk does not converge to a stationary state, a time-average of the closeness defined in Eq. (6) is needed to obtain a quantity that eventually converges with increasing time. Given the linearity of the formulation, this corresponds to replacing the transport probability R ij (t) in Eq. (6) with its time-average It follows that, as with similar classical community detection methods [34], our method is in fact a class of approaches, each corresponding to a different time t. The appropriate value of t will depend on the specific application, for example, a natural time-scale might be the decoherence time. Not wishing to lose generality and focus on a particular system, we focus here on the short and long time limits.
In the short time limit t → 0, relevant if tH ij ≪ 1 for i = j, the averaged transfer matrix T ij (t) is simply proportional to |H ij | 2 . Note that in the short time limit there is no interference between different paths from |i to |j , and therefore for short times c T t (i, j) does not depend on the on-site energies H ii or the phases of the hopping elements H ij . This is because, to leading order in time, interference does not play a role in the transport out of a single node. For this reason we can refer to this approach as "semi-classical".
In the long time limit t → ∞, relevant if t is much larger than the inverse of the smallest gap between distinct eigenvalues of H, the probabilities are elements of the mixing matrix [48], where Λ k is the projector onto the k-th eigenspace of H. This thus provides a simple spectral method for building the community structure. Note that, unlike in a classical infinitesimal stochastic walk where each R ij (t) eventually becomes proportional to the connectivity k j of the final node j, the long time limit in the quantum setting is non-trivial and, as we will see, R ij (t) retains a strong impression of the community structure for large t. 5

B. Intra-community fidelity
Classical walks, and the community detection methods based on them, are fully described by the evolution of the probabilities of the walker occupying each node. The previous quantum community detection approach is based on the evolution of the same probabilities but for a quantum walker. However, quantum walks are richer than this, they are not fully described by the evolution of the node-occupation probabilities. We therefore introduce another community detection method that captures the full quantum dynamics within each community subspace.
Instead of reducing merely the change in probability within the community subspaces, we reduce the change in the projection of the quantum state in the community subspaces. This change is measured using (squared) fidelity, a common measure of distance between two quantum states. For a walk beginning in state ρ(0) we therefore focus on the quantity where Π A ρΠ A is the projection of the state ρ onto the subspace V A and (10) is the fidelity, which is symmetric between ρ and σ.
We build a community structure that seeks to maximize the increase in F X (t) at each hierarchical level by using the closeness measure i.e., the change in F X (t) caused by merging communities A and B. Our choice for the denominator prevents uninteresting size scaling, as in Eq. (6). The initial state ρ(0) can be chosen freely. Here we choose the pure uniform superposition state ρ(0) = |ψ 0 ψ 0 | satisfying i | ψ 0 = 1/ √ n for all i. This state was used to investigate the effects of the connectivity on the dynamics of a quantum walker in Ref. [17].
As for our other community detection approach, we consider the time-average of Eq. (11) which yields where ρ ij (t) = 1 t t 0 dt ′ ρ ij (t ′ ). In the long time limit, the time-average of the density matrix takes a particularly simple expression: where Λ k is as in the previous Sec. II A. The definition of community closeness given in Eq. (11) can exhibit negative values. In this case the usual definition of modularity fails [49] and one must extended it. In this work we use the definition of modularity proposed in [49], which coincides with Eq. (1) in the case of non-negative closeness. The extended definition treats negative and positive links separately, and tries to minimize intra-community negative links while maximizing intra-community positive links.

III. PERFORMANCE ANALYSIS
To analyze the performance of our quantum community detection methods we apply them to three different networks. The first one (Sec. III A) is a simple quantum network, which we use to highlight how some intuitive notions in classical community detection do not necessarily transfer over to quantum systems. The second example (Sec. III B) is an artificial quantum network designed to exhibit a clear classical community structure, which we show is different from the quantum community structure obtained and fails to capture significant changes in this structure induced by quantum mechanical phases on the hopping elements of the Hamiltonian. The final network (Sec. III C) is a real world quantum biological network, the LHCII light harvesting complex, for which we find a consistent quantum community structure differing from the community structure cited in the literature. These findings confirm that a quantum mechanical treatment of community detection is necessary as classical and semiclassical methods cannot be reproduce the structures that appropriately capture quantum effects.
Below we will compare quantum community structures against more classical community structures, such the one given by the semi-classical method based on the short time transport and, in the case of the example of Sec. III B, the classical network from which the quantum network is constructed. Additionally we use a traditional classical community detection algorithm, OSLOM [30], an algorithm based on the maximization of the statistical significance of the proposed partitioning, whose input adjacency matrix A must be real. For this purpose we use the absolute values of the Hamiltonian elements in the site basis: A ij = |H ij |.

A. Simple quantum network
Here we use a simple six-site network model to study ways in which quantum effects lead to non-intuitive results, and how methods based on different quantum properties can, accordingly, lead to very different choices of communities.
We begin with two disconnected cliques of three nodes each, where all Hamiltonian matrix elements within the groups are identical and real. Fig. 2 illustrates this highly symmetric topology. The community detection method based on quantum transport identifies the two fullyconnected groups as two separate communities (Fig. 2a), as is expected. Contrastingly, the methods based on fidelity predict counter-intuitively only a single community; two disconnected nodes can retain coherence and, by this measure, be considered part of the same community (Fig. 2b).
This symmetry captured by the fidelity-based community structure breaks down if we introduce random perturbations into the Hamiltonian. Specifically, the fidelitybased closeness c F t is sensitive to perturbations of the order t −1 , above which the community structure is divided into the two groups of three (Fig. 2c) expected from transport considerations. Thus we may tune the resolution of this community structure method to asymmetric perturbations by varying t.
Due to quantum interference we expect that the Hamiltonian phases should significantly affect the quantum community partitioning. The same toy model can be used to demonstrate this effect. For example, consider adding four elements to the Hamiltonian corresponding to hopping from nodes 2 and 3 to 4 and 5 (see diagram in Fig. 2). If these hopping elements are all identical to the others, it is the two nodes, 1 and 6, that are not directly connected for which the inter-node transport is largest (and thus their inter-node closeness is the largest). However, when the phases of the four additional elements are randomized, this transport is decreased. Moreover, when the phases are canceling, the transport between nodes 1 and 6 is reduced to zero, and the closeness between them is minimized (see Figs. 2d-2f).
The fidelity method has an equally strong dependence on the phases (see Figs. 2g-2i), with variations in the phases breaking up the network from a large central community (with nodes 1 and 6 alone) into the two previously identified communities.

B. Artificial quantum network
The Hamiltonian of our second quantum network is constructed from the adjacency matrix A of a classical unweighted, undirected network exhibiting a clear classical partitioning, using the relation H ij = A ij . We construct A using the algorithm proposed by Lancichinetti et al. in [50], which provides a method to construct a network with heterogeneous distribution both for the node degree and for the communities dimension and a controllable inter-community connection. We start with a rather small network of 60 nodes with average intracommunity connectivity k = 6, and only 5% of the edges are rewired to join communities. The network is depicted in Fig. 3a. To confirm the expected, the known classical community structure is indeed obtained by the semi-classical short-time-transport algorithm 6 and the OSLOM algorithm (see Figs. 3b-3e), achieving NMI = 0.953 and NMI = 0.975 with the known structure, respectively.
The quantum methods based on the long-time average of both transport and fidelity reproduce the main features of the original community structure while unveiling new characteristics. The transport-based long-time average method (NMI = 0.82 relative to the classical partitioning) exhibits disconnected communities, i.e. the corresponding subgraph is disconnected. This behavior can be explained by interference-enhanced quantum walker dynamics, as exhibited by the toy model in the previous subsection. The long-time average fidelity method (NMI = 0.85) returns the four main classical communities plus a number of single-node communities. Both methods demonstrate that the quantum and classical community structures are unsurprisingly different, with the quantum community structure clearly dependent on the quantum property being optimized, more so than the different classical partitionings.

Adjusted phases
As shown in Sec. III A, due to interference the dynamics of the quantum system can change drastically if the phases of the Hamiltonian elements are non-zero. This is known as a chiral quantum walk [18]. Such walks exhibit, for example, time-reversal symmetry breaking of transport between sites [18] and it has been proposed that nature might actually make use of phase controlled interference in transport processes [51]. OSLOM, our semi-classical short-time transport algorithm and other classical community partitioning methods are insensitive to changes in the hopping phases. Thus, by establishing that the quantum community structure is sensitive to such changes in phase, as expected from above, we show that classical methods are inadequate for finding quantum community structure.
To analyze this effect we take the previous network and adjust the phases of the Hamiltonian terms while preserving their absolute values. Specifically, the phases are sampled randomly from a normal distribution with mean zero and standard deviation σ. We find that, typically, as the standard deviation σ increases, when comparing quantum communities and the corresponding communities without phases the NMI between them decreases, as shown in Fig. 3f. A similar deviation reflects on the comparison with the classical communities used to construct the system, shown in Fig. 3g. This sensitivity of the quantum community structures to phases, as revealed by the NMI, confirms the expected inadequacy of classical methods. The partitioning based on long-time average fidelity seems to be the most sensitive to phases.

C. Light-harvesting complex
An increasing number of biological networks of nontrivial topology are being described using quantum mechanics. For example, light harvesting complexes have drawn significant attention in the quantum information community.
One of these is the LHCII, a two-layer 14-chromophore complex embedded into a protein matrix (see Fig. 4 for a sketch) that collects light energy and directs it toward the reaction center where it is transformed into chemical energy. The system can be described as a network of 14 sites connected with a non-trivial topology. The singleexciton subspace is spanned by 14 basis states, each corresponding to a node in the network, and the Hamiltonian in this basis was found in Ref. [28].
In a widely adopted chromophore community structure [27], the sites are partitioned by hand into communities according to their physical closeness (e.g. there are no communities spanning the two layers of the complex), and the strength of Hamiltonian couplings (see the top right of Fig. 4). Here, we apply our ab initio automated quantum community detection algorithms to the same Hamiltonian.
All of our approaches predict a modified partitioning to that commonly used in the literature. The method based on short-time transport returns communities that do not connect the two layers. This semi-classical approach relies only on the coupling strength of the system, without considering interference effects, and provides the closest partitioning to the one provided by the literature (also relying only on the coupling strengths). Meanwhile, the methods based on the long-time transport and fidelity return very similar community partitionings, in which node 6 on one layer and node 9 on the other are in the same community. These two long-time community partitionings are identical, except one of the communities predicted by the fidelity based method is split when using the transport based method. It is therefore a difference in modularity only.
The classical OSLOM algorithm fails spectacularly: it gives only one significant community involving nodes 11 and 12 which exhibit the highest coupling strength. If assigning a community to each node is forced, a unique community with all nodes is provided.

IV. DISCUSSION
We have developed methods to detect community structure in quantum systems, thereby extending the purview of community detection from classical networks to include quantum networks. Our approach involves the development of a number of methods that focus on different characteristics of the system and return a community structure reflecting that specific characteristic. The variation of the quantum community structure with the property on which this structure is based seems greater than for classical community structures.
All our methods are based on the full unitary dynamics of the system, as described by the Hamiltonian, and account for quantum effects such as coherent evolution and interference. In fact phases are often fundamental to characterizing the system evolution. For example, Harel et al. [51] have shown that in light harvesting complexes interference between pathways is important even at room temperature. In our light harvesting complex example (see Sec.III C), the ab-initio community structures provided by the long-time measures propose communities that stretch across the lumenal and stromal layers of the complex, absent in the structure proposed by the community.
Since we consider time evolution, the averaging time t acts as a tuning parameter for the partitioning methods. In the case of transport it transforms the method from a semi-classical approach (t → 0) to a fully quantumaware measure (t → ∞), For all times, the complexity of our algorithms scales polynomially in the number of nodes |N |, at worst O(|N | 3 ) if the diagonalization of H is required.
As with classical community structure, there are many possible definitions of a quantum community. We restricted ourselves to two broad classes based on transport and fidelity under coherent evolution, both based on dy-namics, though in the limits considered in this paper the closenesses and thus quantum community structure can be expressed purely in terms of static properties. We end by briefly discussing other possible definitions based on statics (the earliest classical community definitions were based on statics [52]). The first type is based on some quantum state |ψ , e.g. the ground state of H. We might wish to partition the network by repeatedly diving the network in two based on minimally entangled bipartitions. This could be viewed as identifying optimum communities for some cluster-based mean-field-like simulation [53] whose entanglement structure is expected to be similar to |ψ . The second type is based directly on the spectrum of the Hamiltonian H. We might partition the Hilbert space into unions of the eigenspaces of H by treating the corresponding eigenvalues as 1D coordinates and applying a traditional agglomerative or divisive clustering algorithm on them. Note that the resulting partitioning would normally not be in the node basis.
The use of community detection in quantum systems addresses an open challenge in the drive to unite quantum physics and complex network science, and we expect such partitioning, based on our definitions or extensions such as above, to be used extensively in making the large quantum systems currently being targeted by quantum physicists tractable to numerical analysis. Conversely, quantum measures have also been shown to add novel perspectives to classical network analysis [54].
Appendix A: Definitions

Modularity
Assume we have a directed, weighted graph (with possibly negative weights) and self-links, described by a real adjacency matrix A. The element A ij is the weight of the link from node i to node j.
The in-and outdegrees of node i are defined as For a symmetric graph A is symmetric and the indegree is equal to the outdegree. The total connection weight is The community matrix C defines the membership of the nodes in different communities. The element C iA is equal to unity if i ∈ A, otherwise zero. 7 The size of a community is given by |A| = i C iA . For strict (non-fuzzy) communities we can define C using an assignment vector σ (the entries being the communities of each node): C iA = δ A,σi . This yields (CC T ) ij = δ σi,σj .
There are many different ways of partitioning a graph into communities. A simple approach is to minimize the frustration of the partition, defined as the sum of the absolute weight of positive links between communities and negative links within them: Frustration is inadequate as a goodness measure for partitioning nonnegative graphs (in which a single community containing all the nodes minimizes it). For nonnegative graphs we can instead maximize another measure called modularity: where p ij is the "expected" link weight from i to j, with ij p ij = m, and is what separates modularity from plain frustration. Different choices of the "null model" p give different modularities. Using degrees, we can define p ij = k out i k in j /m. For graphs with both positive and negative weights the usual definitions of degrees do not make much sense, since usually negative and positive links should not simply cancel each other out. Also, plain modularity will fail e.g. when m = 0. This can be solved by treating positive and negative links separately [49].

Hierarchical clustering
All our community detection approaches share a common theme. For each (proposed) community A we have a goodness measure M A (t) that depends on the system Hamiltonian, the initial state, and t. This induces a corresponding measure for a partition X: Using this, we define a function for comparing two partitions, X and X ′ , which only differ in a single merge that combines A and B: We can make M A,B (t) into a symmetric closeness measure c(A, B) by fixing the time t and normalizing it with |A||B|.
Using this closeness measure together with the agglomerative hierarchical clustering algorithm (as explained in Sec. I) we then obtain a community hierarchy. The goodness of a specific partition in the hierarchy is given by its modularity, obtained using the adjacency matrix given by A ij = c(i, j). for any communities A, B, C. If this does not hold, we may encounter a situation where the merging closeness sometimes increases, which in turn means that the results cannot be presented as a dendrogram indexed by decreasing closeness. The real downside of not having the monotonicity property, however, is stability-related. The clustering algorithm should be stable, i.e. a small change in the system should not dramatically change the resulting hierarchy. Assume we encounter a situation where all the pairwise closenesses between a subset of clusters S = {A i } i are within a given tolerance. A small perturbation can now change the pair {A, B} chosen for the merge. If Eq. (A6) is fulfilled, then the rest of S is merged into the same new cluster during subsequent rounds, and hence their relative merging order does not matter.

Intra-community fidelity
Our next measure aims to maximize the "similarity" between the evolved and initial states when projected to a community subspace. We do this using the squared fidelity where Π A ρΠ A is the projection of the state ρ onto the subspace V A and is the fidelity, which is symmetric between ρ and σ. If either ρ or σ is rank-1, their fidelity reduces to F {ρ, σ} = tr{ρσ}. Thus, if the initial state ρ(0) is pure, we have F A (t) = tr (Π A ρ(t)Π A ρ(0)) .
This assumption makes F X (t) equivalent to the squared fidelity between ρ X (t) and a pure ρ(0): and yields Re (ρ ab (t)ρ ba (0)) .
We use as the initial state the uniform superposition of all the basis states with arbitrary phases: |ψ = 1 √ n k e iθ k |k , which gives In this case the short-term limit does not yield anything interesting. The long-time limit of the time-average of F A,B (t) is Re e i(θx−θy+θ b −θa) (Λ k ) ax (Λ k ) yb .
We may now (somewhat arbitrarily) choose all the phases θ k to be the same, or average the closeness measure over all possible phases θ k ∈ [0, 2π].

Purity
The coherence between any communities X = {A, B, . . . } is completely destroyed by measuring in which community subspace V A the quantum state is located, see Eq. (A8). If the measurement outcome is not revealed, the purity of the measured state ρ X (t) is, due to the orthogonality of the projectors, P X (t) = tr ρ 2 where P A (t) = tr (Π A ρ(t)Π A ) 2 = tr (Π A ρ(t)) 2 .
If ρ(t) is pure, we have (cf. Eq. (B10)) P X (t) = A∈X tr(Π A ρ(t)Π A ρ(t)) = F 2 {ρ X (t), ρ(t)}. (B14) The change in purity of the state after a projective measurement locating the walker into one of the communities is (B16) As with the fidelity-based measure, the short-time limit is uninteresting. The long-time limit of the time-average of P A,B (t) is