An Automorphic Distance Metric and Its Application to Node Embedding for Role Mining
Abstract
This work was partially supported by the Spanish Ministry of Economy and the European Regional Development Fund (FEDER), under grant TIN2012-36951, and the program "Ayudas para contratos predoctorales para la formacion de doc 2013," under grant BES-2013-064699. This work was also partially supported by the project "BIGDATAMED: Analisis de datos en Medicina, de las historias clinicas al BIGDATA" with references B-TIC-145-UGR18 and P18RT-1765.
Full text
Research Article An Automorphic Distance Metric and Its Application to Node Embedding for Role Mining V´ ıctor Mart´ ınez , Fernando Berzal , and Juan-Carlos Cubero Department of Computer Science and Artificial Intelligence, University of Granada, Granada, Spain Correspondence should be addressed to Fernando Berzal; [email protected] Received 2 February 2021; Accepted 14 September 2021; Published 13 October 2021 Academic Editor: Atila Bueno Copyright ©2021 V´ ıctor Mart´ ınez et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Role is a fundamental concept in the analysis of the behavior and function of interacting entities in complex networks. Role discovery is the task of uncovering the hidden roles of nodes within a network. Node roles are commonly defined in terms of equivalence classes. Two nodes have the same role if they fall within the same equivalence class. Automorphic equivalence, where two nodes are equivalent when they can swap their labels to form an isomorphic graph, captures this notion of role. The binary concept of equivalence is too restrictive, and nodes in real-world networks rarely belong to the same equivalence class. Instead, a relaxed definition in terms of similarity or distance is commonly used to compute the degree to which two nodes are equivalent. In this paper, we propose a novel distance metric called automorphic distance, which measures how far two nodes are from being automorphically equivalent. We also study its application to node embedding, showing how our metric can be used to generate role-preserving vector representations of nodes. Our experiments confirm that the proposed automorphic distance metric outperforms a state-of-the-art automorphic equivalence-based metric and different state-of-the-art techniques for the generation of node embeddings in different role-related tasks. 1. Introduction Role discovery is defined as the process of finding sets of nodes following similar connectivity patterns or structural behaviors [1]. The role of a node can be understood as the function that node plays in the network. Different studies have shown the importance of roles in different domains, including predator-prey food webs [2], international relations [3], or the function of proteins in proteomes [4]. Unfortunately, this problem has received limited attention when compared to community detection [5–7], despite that role discovery identifies complementary information and has found applications in several useful network data mining tasks. For example, roles can be used to model and characterize the behavior of entities in a network, to predict structural changes, and to detect anomalies [8]. Since the same roles can be observed across different networks, this information has been successfully exploited for transfer learning [9]. Role information can also be used for enhancing the visualization of interesting patterns in graphs [10]. Additional applications of role discovery have been described in the scientific literature [1]. Formally, two nodes have the same role if, given an equivalence relation, they belong to the same equivalence class [11, 12]. Different equivalence classes have been studied for nodes in networks. Structural equivalence, where two nodes play the same role if they are connected to exactly the same neighbor nodes, has been widely studied [13, 14]. These nodes will have exactly the same topological properties, such as degree, clustering coefficient, or centrality, since they are indistinguishable from a structural point of view. However, different authors have pointed out the limitations of structural equivalence for modeling roles or positions, which is the name that roles receive in sociology, since structural equivalence is more related to the concept of locality than the actual concept of role [15]. If the constraint of having to be connected to exactly the same neighbors is relaxed to being connected to neighbors with exactly the same topological function, we obtain automorphic equivalence classes, where two nodes are equivalent Hindawi Complexity Volume 2021, Article ID 5571006, 17 pages https://doi.org/10.1155/2021/5571006
if they can swap their labels to form an isomorphic graph [16, 17]. Automorphically equivalent nodes will also have exactly the same topological properties, but, without the requirement of locality imposed by structural equivalence, pairs of nodes at distances larger than two can still have the same role. Therefore, automorphic equivalence is more closely related to the intuitive concept of role, which is understood as the function of a node within a network. Other equivalence classes, less relevant than the previously mentioned ones, are not covered in this work. Regular equivalence deserves a special mention due to its importance as a relaxation of automorphic equivalence that only requires being connected to nodes with the same function, omitting the actual count of connections [18]. Regular equivalence does not preserve topological properties and is more suited to hierarchically organized networks [2]. These binary equivalences are strict mathematical abstractions that rarely occur in real-world networks, leading to all nodes being assigned a different role. In practice, equivalences are relaxed to similarities, allowing two nodes to play the same role by partially satisfying the constraints imposed by the mathematical definition of structural, automorphic, or regular equivalence. In this paper, we present a novel automorphic distance metric, capturing distances between nodes in terms of automorphic equivalence. According to the network structure, two nodes will be at a distance that is proportional to how far they are from being automorphically equivalent. This leads to a softer definition of automorphic roles, instead of forcing all nodes to fit in strict classes of roles. However, when needed, these distances can be used to discover and instantiate specific role classes. Our distance function satisfies metric axioms, as we prove below, does not require external parameters nor feature engineering, and is computable for nodes across different networks. We also present different applications of our proposal, with special emphasis on generating node embeddings that preserve node roles. Node embeddings are vector representations of nodes capturing relevant information in terms of pairwise distances [19]. Much work has been done in embedding techniques that preserve neighborhoods or communities [20–22]. However, role-preserving embeddings have only recently begun to be studied [23, 24]. Our paper is structured as follows. In Section 2, we discuss the relevant related work in automorphic distance metrics. In Section 3, we describe our proposed automorphic distance metric and study its admissibility as a distance metric, as well as its computational complexity. In addition, we present an approximated algorithm to compute our proposed automorphic distance that offers higher scalability. In Section 4, we analyze its performance for different rolerelated tasks and show how it outperforms previously proposed approaches. Finally, conclusions and suggestions for future research are presented in Section 5. 2. Related Work Different metrics have been proposed to measure node similarity. One of the most popular metrics is SimRank [25], which iteratively computes similarity scores based on the hypothesis that two nodes are similar if they link to similar nodes. Different extensions of SimRank have been proposed [26]. SimRank recursively computes the similarity of two nodes according to the average similarity of all their neighbor pairs, which can also be interpreted, as suggested by its original authors, as how soon two random walkers will meet if they start from these nodes. Thus, this definition is not suitable as a metric of similarity capturing automorphic equivalence because it requires the two nodes to be close to play the same role. Other similarity measures not based on SimRank have been proposed, such as PageSim [27] and Leicht’s vertex similarity [28]. However, these similarities have been formally rejected as valid metrics for capturing automorphic equivalence [29]. Since automorphic equivalence ensures the same topological properties, some authors have tried to capture automorphic equivalence by defining a similarity function over a set of network topological properties [30]. The problem of these feature-based methods is that they require combining different complex hand-crafted features provided by experts, which is far from a trivial process in practice. In addition, they cannot guarantee, which set of features will correctly approximate automorphic equivalence, resulting in a very limited approach for automorphic equivalence discovery. As far as we know, RoleSim [29, 31] is the only proposed metric that tries to formally capture the concept of automorphic equivalence without using limited approximations based on hand-crafted topological features. Omitting the decay factor they introduce, by setting it to 0 in order to capture the global network topology, this similarity measure is iteratively computed until convergence as s(x, y) � max M(x,y) (u,v)∈M(x,y)s(u, v) deg(x) + deg(y) − |M(x, y)|,(1) where deg(n)is the degree of a node nand M(x, y)is the optimal assignment of nodes in the neighborhood of xto nodes in the neighborhood of ymaximizing the expression, that is, the pairs of neighbors of xand ywith maximal similarity. In the original manuscript, this function is presented as a role similarity metric by proving the corresponding distance metric axioms. RoleSim is a form of generalized Jaccard coefficient based on a recursive definition of the similarity of neighbor roles. Despite the admissibility of RoleSim, their approach presents several limitations. The RoleSim similarity can be considered an automorphic distance by taking its complementary or Jaccard distance: d(x, y) � 1−s(x, y). The problem is that the Jaccard coefficient is a normalized metric, which leads to a normalized distance. As will be shown in our experimentation, this normalization has a negative impact on the results obtained by RoleSim. In addition, this similarity function exhibits serious inconsistencies. For example, in the graph shown in Figure 1, where node dhas a one-to-many relationship to xi nodes, the node pair (a, c)has the same exact similarity as any pair (a, xi), independent of the number of xinodes. This simple example shows the limitations of RoleSim when trying to capture the automorphic similarity. 2Complexity
As far as we know, no distance metric has been proposed that is able to capture the concept of automorphic distance in a consistent way, without relying on approximations based on extracted topological properties nor forcing the normalization of the distance function. 3. A Novel Automorphic Distance Metric An isomorphism is a bijection between the nodes of two graphs where two nodes are adjacent in one graph if and only if the nodes that result from applying the bijective function are also adjacent in the other graph. An automorphism is an isomorphism from one graph to itself. Therefore, two nodes are automorphically equivalent if there exists an automorphism creating a correspondence between them. One form of testing for automorphic equivalence is computing the canonical form of graphs. Graph canonicalization is the task of computing a labeling for nodes in a graph such that every isomorphic graph yields the same canonical labeling. Given a canonicalized graph, two automorphically equivalent nodes must have been assigned the same label. As previously stated, automorphic equivalence is too restrictive to appear in real-world networks, leading to most nodes having different canonical labels. The solution that we propose to this problem is the definition of distances between labels, which ultimately allows the definition of distances between nodes based on the concept of automorphic equivalence. This distance will be proportional to the number of changes that need to be done in the network to transform one label or equivalence class into another. A zero distance implies that two nodes are automorphically equivalent and play exactly the same role. According to this distance d, we can say that nodes xand y are more automorphically similar or have a more similar role to uand v, if d(x, y)<d(u, v). In order to propose a valid distance metric, we must also prove that our metric satisfies the metric distance axioms. Our work is based on the 1-dimensional Weisfeiler–Lehman test of isomorphism [32, 33], also known as color refinement, which is an algorithm to compute the canonical labeling of graphs. These canonical labels can be used to solve related problems, such as the computation of efficient graph kernels [34]. The Weisfeiler–Lehman algorithm works by initially assigning a label to each node according to its degree, so nodes with the same degree have the same initial label. Then, the algorithm iteratively updates these labels by the following procedure. First, it takes the labels from neighbor nodes, concatenates them according to certain arbitrary order (the same ordering must be applied for all nodes), and finally appends the label of the node at the beginning of the obtained list. Each different sequence is substituted by a newly generated unique label, so nodes exhibiting exactly the same sequence are assigned the same label. This refinement process is repeated until labels stabilize, that is, when every pair of nodes with the same label in the previous iteration have the same label in the current iteration. Therefore, after miterations, which depend on the network diameter, the canonical form is achieved, and an additional iteration is required for testing the stabilization condition. These final labels are the canonical form of the graph and, therefore, two nodes with the same final label are automorphically equivalent. An example of running the algorithm in a simple graph is shown in Figure 2. It can be noted that some pairs of the labels appearing in the same iteration of the Weisfeiler–Lehman algorithm are more similar than others. The automorphic distance between two nodes can be defined as the distance between their canonical labels. We propose a scheme to compute distances between the labels that are obtained by the Weisfeiler–Lehman algorithm. Since distances are only defined for labels appearing in the same iteration, a special label associated with nodes of degree 0, which we call the empty label ℓ∅, is considered for convenience. Isolated nodes are directly assigned this label and left out of the iterative process. Since labels created in the initial assignment are based on the node degree, we define the distance of labels of nodes x and yas the number of links that must be added to or removed from node xto transform it into node y. This can be easily computed as their absolute degree difference as follows: dℓ0(x),ℓ0(y) �|deg(x) − deg(y)|,(2) where ℓ0(n)is the initially assigned label to node n. This definition of distance for initial labels is also valid for isolated nodes, with degree 0, which have been assigned the empty label. Given these distances for initial labels, the distance between labels for the subsequent iterations can be computed as the distance of the optimally matched pairs of labels of their neighbors from the previous iteration. The distance of labels from the i-th iteration can be computed as dℓi(x),ℓi(y) �min Mi−1(x,y) (u,v)∈Mi−1(x,y) dℓi−1(u),ℓi−1(v) , (3) where Mi−1(x, y)is the optimal assignment of neighbors of xto neighbors of ythat minimizes the expression and, therefore, it is just the sum of distances between neighbors of xand y. If the neighborhood of one node is larger than the neighborhood of the other, leading to unmatched nodes, these nodes are directly matched with virtual nodes, which are labeled ℓ∅. The distances of unmatched nodes to the empty label can be seen as the cost, in terms of distance, of inserting and transforming a virtual isolated node to obtain a a bc d x1 … x2 xn Figure 1: Example graph where RoleSim yields inconsistent values. Node dhas a one-to-many relation to xinodes. Complexity 3
node with the label of the unmatched node. The optimal assignment, which would consider O(n!)alternatives using a naive brute force approach, can be computed in polynomial time using the Hungarian algorithm [35]. Initially, equation (2) and, in subsequent iterations, equation (3) are used to compute a distance table. At any given time, only distances from two iterations need to be maintained: the distances currently being computed and the distances from the most recent previous iteration. The described iterative process is carried out for each iteration of the 1-dimensional Weisfeiler–Lehman algorithm until label stabilization. The automorphic distance between a pair of nodes is defined as the distance between their canonical labels. It should be noted that labels can be represented using any set of symbols. However, for simplicity, we represent labels as positive integers. The complete algorithm is shown in Algorithm 1. The function neighbors(x)returns the set of labels of the neighbor nodes of x. The function sort(s)sorts a set of elements. The ordering among elements is not relevant for the algorithm, but the same ordering must always be applied. The function concatenate(x1,. . . , xn)returns the concatenation of elements x1,. . . , xn. Finally, the function unique(s)generates and returns a unique symbol, such as an integer, for each observed unique string s, where unique(s) � unique(s′)if and only if s�s′. 3.1. Example. In this section, we show an illustrative example applying the proposed automorphic distance metric to the network shown in Figure 2(a). The proposed algorithm for computing the automorphic distance initially assigns a label to each node according to its degree, as shown in Figure 2(b). Therefore, two nodes will have the same label if and only if they have the same degree. The initial distance table, represented as an upper triangular matrix due to the symmetry of distances, which will be proved in Section 3.2.3, is shown in Table 1. This distance table is computed using equation (2) according to the initial label assignments. For example, the distance between the labels 1 and 4 is 3, since this value is the absolute degree difference of the corresponding nodes. After initialization, the algorithm enters into its main loop and performs its first iteration. For each node, the labels of its neighbors are ordered and concatenated with its own label, as shown in Figure 2(c). For example, the only node with label 3 has the associated string 3|2,2,4, since its neighbors have labels 2, 4, and 2. These concatenated strings are replaced by a new label, chosen so that two nodes are assigned the same new label if and only if they had the same concatenated string. This process generates a new labeling as shown in Figure 2(d). Given these new labels, the algorithm computes their pairwise distances using equation (3), which are shown in Table 2. For example, in order to compute the distance between labels 5 and 9, the optimal assignment between their neighbors minimizing the summation of distances, according to the previous iteration, must be obtained. In the previous iteration, 3 and 4 were the labels of the neighbors of nodes with label 5. Likewise, 1, 1, 2, and 4 were the labels of the neighbors of nodes with label 9. The Hungarian algorithm matches these neighbor labels to minimize their sum of distances: (3,2)and (4,4)according to Table 1. Since the two neighbor labels 1 of label 9 were left unmatched, they are both matched with the empty label as (1,ℓ∅). Given this optimal assignment, we can compute the distance between labels 5 and 9 as d1(5,9) � d0(3,2) + d0(4,4) + d01,ℓ∅ +d01,ℓ∅ �1+0+1+1�3. (4) We can use the same algorithm to compute the distance between any other pair of labels. For example, to compute the distance between labels 6 and 7, we first identify their neighbor labels in the previous iteration: 2, 2, and 4 for label 6 and 4 for label 7. Using the Hungarian algorithm, both labels 4 are matched with each other and both labels 2 are (a) 44 1 1 1 2 23 (b) 4|1,1,2,4 1|4 1|4 1|4 2|3,43|2,2,4 2|3,4 4|1,2,3,4 (c) 9 7 7 5 56 7 8 (d) 9|5,7,7,88|5,6,7,9 6|5,5,8 5|6,9 7|9 7|9 5|6,8 7|8 (e) 13 1615 14 10 11 12 13 (f) Figure 2: The Weisfeiler–Lehman canonicalization algorithm applied to a simple graph. (a) Original graph, (b) initial labeling, (c) first iteration, (d) first relabeling, (e) second iteration, and (f) second and final relabeling. 4Complexity
matched with the empty label, since there are no remaining labels to match them with. Therefore, the distance between labels 6 and 7 is computed as follows: d1(6,7) � d02,ℓ∅ +d02,ℓ∅ +d0(4,4) � 2+2+0�4. (5) Following this iterative process, the algorithm performs a second iteration. Concatenated strings are computed as shown in Figure 2(e) and labels are updated as shown in Figure 2(f). It can be easily seen that labels have stabilized, obtaining the canonical labeling of this graph. The stabilization condition can be tested by performing an additional iteration and observing that nodes with label 13 are assigned the same label, while the other nodes are assigned an unique new label. This new labeling would be equivalent to the labeling obtained in the current iteration, the condition required to achieve stabilization. The pairwise distances computed in this iteration are shown in Table 3. For instance, let us compute the distance between labels 11 and 16. We start by finding the optimal assignment that minimizes the pairwise distances of their neighbor labels in the previous iteration, which are 5,5, and 8 for label 11 and 5,7,7, and 8 for label 16. The Hungarian algorithm obtains procedure Automorphic Distance Input: Set of nodes Nof an undirected graph. Output: Pairwise automorphic distances d(x, y)for each pair of nodes (x, y)∈N×N. for each xin Ndo ℓ0(x)⟵deg(x) end for for each x, y in N×Ndo d(ℓ0(x),ℓ0(y)) ⟵|deg(x) − deg(y)| end for i⟵1 stabilized ⟵false while not stabilized do stabilized ⟵true R⟵ for each xin Ndo hi(x)⟵concatenate(sort(neighbors(x))) ci(x)⟵concatenate(ℓi−1(x), hi(x)) ℓi(x)⟵unique(ci(x)) if R·contains(ℓi(x)) and not R[ℓi(x)] � ℓi−1(x)then stabilized ⟵false else R[ℓi(x)] � ℓi−1(x) end if end for if not stabilized then for each x, y in N×Ndo ▷Using the Hungarian algorithm. d(ℓi(x),ℓi(y)) ⟵minMi−1(x,y)(u,v)∈Mi−1(x,y)d(ℓi−1(u),ℓi−1(v)) end for i⟵i+1 end if end while for each x, y in N×Ndo d(x, y)⟵d(ℓi(x),ℓi(y)) end for end procedure A LGORITHM 1: Automorphic distance algorithm. Table 1: Initialization of the distance table. ℓ/ℓ ℓ∅1 2 3 4 ℓ∅0 1 2 3 4 1 0 1 2 3 2 0 1 2 3 0 1 4 0 Table 2: Distance table after the first relabeling. ℓ/ℓ ℓ∅5 6 7 8 9 ℓ∅0 7 8 4 10 8 5 0 3 3 3 3 6 0 4 4 2 7 0 6 4 8 0 2 9 0 Complexity 5
the optimal matching (5,5),(5,7), and (8,8), with an additional (ℓ∅,7), due to the difference of the node degrees associated with labels 11 and 16. Once this optimal matching has been obtained, we can easily compute the distance between labels 11 and 16 using equation (3) as follows: d2(11,16) � d1(5,5) + d1(5,7) + d1(8,8) + d1ℓ∅,7 �0+3+0+4�7. (6) The automorphic distance between a pair of nodes is defined as the distance between their canonical labels, which are the final labels assigned in the iteration where stabilization is achieved. Therefore, in our example, the distance between nodes is given by Table 3. For example, we can see how nodes with canonical labels 13 and 14 are close to being automorphically equivalent, since their automorphic distance is only 2. In contrast, nodes with canonical labels 14 and 15 have a large automorphic distance, equal to 21, which indicates that they are far from being automorphically equivalent. 3.2. Metric Admissibility. In this section, we prove that the distance function that we have defined is a valid metric or distance function. In order to assert this statement, we must prove the following four conditions: nonnegativity, identity of indiscernibles, symmetry, and triangle inequality. To prove these conditions, we note that equation (3) can be recursively decomposed as dℓi(x),ℓi(y) �min Mi−1(x,y) (u,v)∈ Mi−1(x,y) dℓi−1(u),ℓi−1(v) �min Mi−1(x,y) (u,v)∈ Mi−1(x,y) min Mi−2(u,v) u′,v′ ( )∈ Mi−2(u,v) dℓi−2u′ ,ℓi−2v′ � · · · � x′,y′ ( )∈M′(x,y) dℓ0x′ ,ℓ0y′ � x′,y′ ( )∈M′(x,y) deg x′ −deg y′ , (7) where M′(x, y)is the set of pairs of nodes that appear in the recursive summation at the deepest level of recursion as a result of choosing the optimal assignment in each iteration. 3.2.1. Proof of Nonnegativity. Nonnegativity requires that the distance function satisfies d(ℓi(x),ℓi(y)) ≥0 for any possible pair of nodes xand y. Given the decomposition of our metric as shown in equation (7), it is straightforward to see that the summation of absolute values is guaranteed to be always equal to or greater than 0. 3.2.2. Proof of the Identity of Indiscernibles. The identity of indiscernibles implies that the distance function satisfies d(ℓi(x),ℓi(y)) � 0 if and only if ℓi(x)≡ℓi(y). The Weisfeiler–Lehman algorithm guarantees that automorphically equivalent pairs of nodes are assigned the same canonical label, and nonautomorphically equivalent pairs of nodes are assigned different canonical labels. Equation (7) is only equal to zero when deg(x′) �deg(y′)for every pair of nodes in M′(x, y). Two nodes can only have the same canonical label if they are automorphically equivalent, as guaranteed by the Weisfeiler–Lehman algorithm. If two nodes are assigned the same canonical label, their neighbors must have been assigned equivalent labels in all the iterations. Since the distance of a label to itself is 0, we can see that the summation yields 0, leading to a zero distance for nodes when ℓi(x)≡ℓi(y). On the other side, when two nodes have different canonical labels, their neighbors must have been assigned Table 3: Distance table after the second and final relabeling. ℓ/ℓ ℓ∅10 11 12 13 14 15 16 ℓ∅0 18 24 16 8 10 27 25 10 0 10 2 12 8 13 11 11 0 12 16 14 13 7 12 0 8 10 11 13 13 0 2 19 17 14 0 21 15 15 0 6 16 0 6Complexity
different labels during the execution of the algorithm. This implies that, in the recursive decomposition shown in equation (7), at least one pair of nodes will not match nodes with the same initial labels, leading to a distance greater than 0 for nodes ℓi(x)≢ℓi(y). 3.2.3. Proof of Symmetry. The condition of symmetry requires that the proposed distance function must satisfy the property d(ℓi(x),ℓi(y)) � d(ℓi(y),ℓi(x)). We can prove that equation (7) is symmetric as dℓi(x),ℓi(y) � x′,y′ ( )∈M′(x,y) deg x′ −deg y′ � y′,x′ ( )∈M′(y,x) deg y′ −deg x′ �dℓi(y),ℓi(x) , (8) since M′(x, y)is equal to M′(y, x)when we swap the nodes. The order of the nodes in each pair does not affect the result of our distance function. 3.2.4. Proof of the Triangle Inequality. The triangle inequality requires that the inequality d(ℓi(x),ℓi(y)) ≤d (ℓi(x),ℓi(z)) + d(ℓi(z),ℓi(y)) is satisfied by the proposed automorphic distance function. By the definition of the proposed distance, we know that dℓi(x),ℓi(y) ≤dℓi(x),ℓi(z) +dℓi(z),ℓi(y) ⇒ (a,b)∈M′(x,y) |deg(a) − deg(b)| ≤ (a,c)∈M′(x,z) |deg(a) − deg(c)| + (c,d)∈M′(z,y) |deg(c) − deg(d)|. (9) We know that the absolute value satisfies the triangle inequality and thus the lower value that the right side can take is (a,b)∈M′(x,y) |deg(a) − deg(b)| ≤ (a,d)∈M″(x,y,z) |deg(a) − deg(d)| , (10) where M″(x, y, z)is the set of pairs resulting from chaining or combining M′(x, z)and M′(z, y)so that (a, d)∈M″(x, y, z)if and only if, (a, c)∈M′(x, z)and (c, d)∈M′(z, y). For this inequality to hold, it requires the nonexistence of a pairing of nodes better than the matching done in the lefthand side. Since the Hungarian algorithm ensures that matchings are optimal, minimizing their sum of distances, the matching at the right-hand side cannot be better than optimal and, therefore, the value of the right-hand side can only be equal to or greater than the value on the left-hand side, satisfying the triangle inequality condition. 3.3. Metric Computational Complexity. In this section, we analyze the time and spatial computational complexity of our proposed metric. The initialization of labels based on the degree of nodes has O(n)time and spatial complexity, where nis the number of nodes in the network. The computation of the table for the initial distances has O(n2)time and spatial complexity, since the distance is computed for every pair of nodes. Each iteration of the algorithm requires computing the sorted list of labels of the neighbors for each node. This task can be accomplished for each node with computational and spatial complexity O(k), where kis the degree of the node, when using radix, bucket, or counting sort. Thus, computing these strings for all nodes has O(nk)time and spatial complexity. Renaming these labels can be done in O(n)time using hash-based data structures. To compute the pairwise distances between labels in the current iteration, the Hungarian algorithm, with computational complexity O(k3), must be computed for each pair of nodes, leading to O(n2k3) time complexity and O(n2)spatial complexity. Finally, checking if the labels have stabilized can be done in O(n) using a hash-based index. The number of iterations, m, required for 1-dimensional Weisfeiler–Lehman algorithm to converge is closely related to the diameter of the network [32]. Even though the number of iterations is theoretically bounded by n, it has been widely observed that real-world networks tend to exhibit the small-world phenomenon, presenting a small diameter [36, 37] and leading to a small number of iterations required for convergence. Therefore, by combining these partial results, the total time complexity is O(mn2k3), where nis the number of nodes in the graph, kis the degree of nodes, and mis the number of iterations required for convergence. The spatial complexity of the algorithm is O(n2), since only the distances and labels from the previous and the current iteration must be maintained at any given time. Most of these steps can be easily parallelized, since most of them are independent of each node and are only based on the results from the previous iteration. For example, the initial labels for each node can be assigned independently. Once we have assigned these labels, the computation of their pairwise distances can be split among all the available processors, since they are independent. The iterative assignment of labels in each loop iteration can also be parallelized using a concurrent data structure to ensure that the new labels are properly generated. Furthermore, the pairwise distances between these new labels can be easily computed in a parallel way, since they are completely independent as they only rely on the distance table computed in the previous iteration. 3.4. A More Efficient Approximation. The quadratic time complexity with respect to the number of nodes in the network limits the applicability of our proposed approach in large networks. In this section, we introduce a more scalable approximation of our approach. Complexity 7
The proposed alternative approach is based on the idea of efficiently clustering similar labels just before computing distances between labels. This clustering only applies to the computation of distances, not to the steps related to the Weisfeiler–Lehman algorithm. Instead of requiring a distance matrix including all pairs of nodes, this approximated approach only requires computing the distance matrix between the obtained clusters. The distances between pairs of labels are approximated as the distance between the clusters to which they belong to. Therefore, using this approximation, the step where distances between pairs of labels are computed becomes quadratic with respect to the number of clusters, which are set by the experimenter and can be much lower than the number of nodes in the network. The proposed approximation algorithm is shown in Algorithms 2–4. The base structure of the algorithm remains unchanged, but a new label clustering step is introduced just before computing the distances between pairs of labels. This clustering procedure is based on choosing a representative label for each cluster. A set for storing representative labels, initially containing only the empty label, is created. While the size of the set of representative labels is less than the number of clusters cspecified as a parameter, a new representative label is added to this set as follows. A number of labels sis sampled from a set of remaining labels, which initially contains all the labels obtained except the empty label. The minimal distance to every representative label, i.e., the smallest distance to any label in the set of representative labels, is computed for each sampled label. The sampled label with the largest minimal distance is chosen as a representative label. Next, the chosen representative label is added to the set of representative labels and removed from the set of remaining labels. This greedy procedure approximates a set of representative labels with large distances among them. Each representative label represents a cluster. A cluster is assigned to each nonrepresentative label by choosing the closest cluster according to the distance to its representative label. The proposed approximation has a significant impact on our algorithm computational complexity. The spatial complexity becomes O(c2+nk), where cis the number of clusters and can be set to c≪n, since only distances between pairs of clusters obtained in the same iteration must be stored. The time complexity of the proposed approximation can be obtained as follows. The steps, which are also present in the original algorithm, without the clustering step, now have a computational complexity O(nk +mc2k3) as a result of computing only distances between pairs of clusters. The time complexity of the greedy clustering step is O(sc2k3)for the step where representative labels are chosen, where sis the number of the sampled labels, and for the step where clusters are assigned to each nonrepresentative label is O(nck3). The greedy clustering procedure must be executed mtimes until the convergence of the Weisfeiler–Lehman algorithm. Therefore, the computational complexity introduced by the clustering procedure is O(msc2k3+mnck3). Given these complexities, the time complexity of the complete algorithm is O(msc2k3+mnck3). Since cand scan be manually set to be much smaller than the number of nodes in the network, this approach is more scalable and can be applied to large networks. 4. Experimental Evaluation This section contains our experimental evaluation of the proposed automorphic distance metric. In addition to the theoretical results described in the previous sections of the manuscript, we aim to show how our proposal properly captures the concept of node role based on automorphic equivalence and its different practical applications. The experimental evaluation of the proposed distance metric is a complicated task due to the lack of a standard evaluation methodology for role-based metrics. In order to evaluate our distance metrics and compare the obtained results with other state-of-the-art approaches, we propose different experimental settings, which are described in the following sections. 4.1. Performance Evaluation of Distance Metrics. In this section, we evaluate and compare the proposed original automorphic distance metric with RoleSim considered as a distance metric. We follow an evaluation methodology based on the idea that nodes playing the same role in the network must show similar topological properties. Therefore, close nodes with regard to an automorphic distance metric should have similar topological properties, and their distance should be correlated with the similarity between these properties. For example, nodes with a similar role in the network should also exhibit a similar centrality, and similar nodes playing the role of bridges between different communities should exhibit similar topological properties measurable by different metrics proposed in the field of network analysis. We propose measuring the performance of these distance metrics by evaluating how well these metrics capture global network structural properties. This can be done by computing the Pearson correlation coefficient between the distances given by the evaluated methods for a given pair of nodes and the absolute difference of their scores associated with a given network structural property, as follows: score �corr dℓi(x),ℓi(y) :∀x, y ∈N×N ,(|s(x) − s(y)|:∀x, y ∈N×N) ,(11) 8Complexity
procedure APPROXIMATED AUTOMORPHIC DISTANCE Inputs: -Set of nodes Nof an undirected graph. -Number of clusters c. -Number of samples s. Outputs: -Approximated pairwise automorphic distances d(x, y)for each pair of clusters (x, y)∈Ci×Ci. -Mapping gi(x)from each label to its cluster representative. for each x in N do ℓ0(x)←deg(x) end for C0, g0←GREEDY LABEL CLUSTERING(N, c, s, 0) for each x,yin C0×C0do d(x, y)←COMPUTE DISTANCE(x, y, 0, g0) end for i←1 stabilized←false while not stabilize d do stabilized←true R← for each x in N do hi(x)←concatenate(sort(neighbors(x))) ci(x)←concatenate(ℓi−1(x), hi(x)) ℓi(x)←unique(ci(x)) If R·contains(ℓi(x)) and not R[ℓi(x)] � ℓi−1(x)then stabilized←false else R[ℓi(x)]←ℓi−1(x) end if end for if not stabilized then Ci, gi←GREEDY LABEL CLUSTERING(N, c, s, i, gi−1) for each x,yin Ci×Cido d(x, y)←COMPUTE DISTANCE(x, y, i, gi−1) end for i←i+1 end if end while end procedure A LGORITHM 2: Approximated automorphic distance algorithm. procedure COMPUTE_DISTANCE Inputs: -Labels xand y. -Iteration i. -Mapping from each label to its cluster representative g(optional). ▷The mapping is only used for i>0. Output: Computed distance d. If i�0then d←|x−y| else ▷Using the Hungarian algorithm. d←minMi−1(x,y)(u,v)∈Mi−1(x,y)d(g(ℓi−1(u)), g(ℓi−1(v))) end if end procedure A LGORITHM 3: Distance computation. Complexity 9
5. Conclusions In this paper, we have proposed a novel distance metric for nodes that relaxes the strict concept of automorphic equivalence. To the best of our knowledge, this is the first work to propose a consistent nonnormalized distance metric that captures the concept of automorphic equivalence without approximating it using feature engineering. In addition, we have shown that the proposed distance function is a valid distance metric by proving the required conditions. Furthermore, we have shown how our metric can be exploited to generate node embeddings that capture role information. Finally, we have carried out different experiments in order to show how our proposal can outperform other state-of-the-art techniques in different role-related tasks. Our proposal creates new opportunities in problems related to role discovery. Future work includes exploiting our distance metrics in problems related to anomaly detection in networks and transfer learning based on roles shared by nodes across different networks. Data Availability The network datasets used in our experiments are from publicly available studies, which have been cited in our paper. Conflicts of Interest The authors declare that they have no conflicts of interest. Acknowledgments This work was partially supported by the Spanish Ministry of Economy and the European Regional Development Fund (FEDER), under grant TIN2012-36951, and the program “Ayudas para contratos predoctorales para la formaci´ on de doc 2013,” under grant BES-2013-064699. This work was also partially supported by the project “BIGDATAMED: Analisis de datos en Medicina, de las historias cl´ ınicas al BIGDATA” with references B-TIC-145-UGR18 and P18- RT-1765. References [1] R. A. Rossi and N. K. Ahmed, “Role discovery in networks,” IEEE Transactions on Knowledge and Data Engineering, vol. 27, no. 4, pp. 1112–1131, 2015. [2] J. J. Luczkovich, S. P. Borgatti, J. C. Johnson, and M. G. Everett, “Defining and measuring trophic role similarity in food webs using regular equivalence,” Journal of Theoretical Biology, vol. 220, no. 3, pp. 303–321, 2003. [3] E. M. Hafner-Burton, M. Kahler, and A. H. Montgomery, “Network analysis for international relations,” International Organization, vol. 63, no. 3, pp. 559–592, 2009. [4] P. Holme and M. Huss, “Role-similarity based functional prediction in networked systems: application to the yeast proteome,” Journal of The Royal Society Interface, vol. 2, no. 4, pp. 327–333, 2005. [5] S. Fortunato, “Community detection in graphs,” Physics Reports, vol. 486, no. 3, pp. 75–174, 2010. [6] A. Lancichinetti and S. Fortunato, “Community detection algorithms: a comparative analysis,” Physical Review E, Statistical, Nonlinear, and Soft Matter Physics, vol. 80, no. 5, Article ID 056117, 2009. [7] S. Papadopoulos, Y. Kompatsiaris, A. Vakali, and P. Spyridonos, “Community detection in social media,” Data Mining and Knowledge Discovery, vol. 24, no. 3, pp. 515–554, 2012. [8] R. A. Rossi, B. Gallagher, J. Neville, and K. Henderson, “Modeling dynamic behavior in large evolving graphs,” in Proceedings of the 6th ACM International Conference on Web Search and Data Mining, pp. 667–676, ACM, Rome, Italy, February 2013. [9] K. Henderson, B. Gallagher, T. Eliassi-Rad et al., “RolX: structural role extraction & mining in large graphs,” in Proceedings of the 18th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 1231–1239, Beijing, China, August 2012. [10] E. P. Xing, W. Fu, and L. Song, “A state-space mixed membership blockmodel for dynamic network tomography,” Annals of Applied Statistics, vol. 4, no. 2, pp. 535–566, 2010. [11] R. S. Burt, “Detecting role equivalence,” Social Networks, vol. 12, no. 1, pp. 83–97, 1990. [12] H. C. White, S. A. Boorman, and R. L. Breiger, “Social structure from multiple networks. I. Blockmodels of roles and positions,” American Journal of Sociology, vol. 81, no. 4, pp. 730–780, 1976. [13] F. Lorrain and H. C. White, “Structural equivalence of individuals in social networks,” Journal of Mathematical Sociology, vol. 1, no. 1, pp. 49–80, 1971. [14] L. D. Sailer, “Structural equivalence: meaning and definition, computation and application,” Social Networks, vol. 1, no. 1, pp. 73–90, 1978. [15] S. P. Borgatti and M. G. Everett, “Notions of position in social network analysis,” Sociological Methodology, vol. 22, pp. 1–35, 1992. [16] N. E. Friedkin and E. C. Johnsen, “Social positions in influence networks,” Social Networks, vol. 19, no. 3, pp. 209–222, 1997. [17] P. E. Pattison, “Network models: some comments on papers in this special issue,” Social Networks, vol. 10, no. 4, pp. 383–411, 1988. [18] M. G. Everett and S. P. Borgatti, “Regular equivalence: general theory,” Journal of Mathematical Sociology, vol. 19, no. 1, pp. 29–52, 1994. [19] P. Goyal and E. Ferrara, “Graph embedding techniques, applications, and performance: a survey,” 2017, http://arxiv. org/abs/1705.02801. [20] J. Liu, Z. He, L. Wei, and Y. Huang, “Content to node: selftranslation network embedding,” in Proceedings of the 24th ACM SIGKDD International Conference On Knowledge Discovery & Data Mining, pp. 1794–1802, London, UK, August 2018. [21] J. Tang, M. Qu, M. Wang, M. Zhang, J. Yan, and Q. Mei, “Line: large-scale information network embedding,” in Proceedings of the 24th International Conference on World Wide Web, pp. 1067–1077, Florence, Italy, May 2015. [22] V. W. Zheng, S. Cavallari, H. Cai, K. C.-C. Chang, and E. Cambria, “From node embedding to community embedding,” 2016, http://arxiv.org/abs/1610.09950. [23] A. Grover and J. Leskovec, “node2vec: scalable feature learning for networks,” in Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 855–864, ACM, San Francisco, CA, USA, August 2016. 16 Complexity
[24] L. F. R. Ribeiro, P. H. P. Saverese, and D. R. Figueiredo, “struc2vec: learning node representations from structural identity,” in Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 385–394, Halifax, Canada, August 2017. [25] G. Jeh and J. Widom, “SimRank: a measure of structuralcontext similarity,” in Proceedings of the 8th ACM SIGKDD International Conference On Knowledge Discovery And Data Mining, pp. 538–543, ACM, Edmonton Alberta, Canada, July 2002. [26] M. R. Hamedani and S.-W. Kim, “SimRank and its variants in academic literature data: measures and evaluation,” in Proceedings of the 31st Annual ACM Symposium on Applied Computing, pp. 1102–1107, ACM, Pisa, Italy, April 2016. [27] Z. Lin, M. R. Lyu, and I. King, “PageSim: a novel link-based measure of web page similarity,” in Proceedings of the 15th International Conference on the World Wide Web, pp. 1019-1020, ACM, Edinburgh, UK, May 2006. [28] E. A. Leicht, P. Holme, and M. E. Newman, “Vertex similarity in networks,” Physical Review E, Statistical, Nonlinear, and Soft Matter Physics, vol. 73, no. 2, Article ID 026120, 2006. [29] R. Jin, V. E. Lee, and L. Li, “Scalable and axiomatic ranking of network role similarity,” ACM Transactions on Knowledge Discovery from Data, vol. 8, no. 1, 3 pages, 2014. [30] L. Li, L. Qian, V. E. Lee, M. Leng, M. Chen, and X. Chen, “Fast and accurate computation of role similarity via vertex centrality,” in Proceedings of the International Conference on Web-Age Information Management, pp. 123–134, Springer International Publishing, Qingdao, China, June 2015. [31] R. Jin, V. E. Lee, and H. Hong, “Axiomatic ranking of network role similarity,” in Proceedings of the 17th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 922–930, ACM, San Diego, CA, USA, August 2011. [32] M. F¨urer, “Weisfeiler-Lehman refinement requires at least a linear number of iterations,” in Proceedings of the 28th International Colloquium on Automata, Languages, and Programming, pp. 322–333, Berlin, Germany, July 2001. [33] B. Weisfeiler and A. Lehman, “A reduction of a graph to a canonical form and an algebra arising during this reduction,” Nauchno-Technicheskaya Informatsia, vol. 2, no. 9, pp. 12–16, 1968. [34] N. Shervashidze, P. Schweitzer, E. J. van Leeuwen, K. Mehlhorn, and K. M. Borgwardt, “Weisfeiler-Lehman graph kernels,” Journal of Machine Learning Research, vol. 12, pp. 2539–2561, 2011. [35] H. W. Kuhn, “The Hungarian method for the assignment problem,” Naval Research Logistics, vol. 2, no. 1-2, pp. 83–97, 1955. [36] J. Travers and S. Milgram, “The small–world problem,” Phychology Today, vol. 1, pp. 61–67, 1967. [37] D. J. Watts and S. H. Strogatz, “Collective dynamics of “small-world” networks,” Nature, vol. 393, no. 6684, pp. 440–442, 1998. [38] L. Page, S. Brin, R. Motwani, and T. Winograd, “The PageRank citation ranking: bringing order to the web,” Technical report, Stanford University Press, Redwood City, CA, USA, 1999. [39] L. C. Freeman, “Centrality in social networks conceptual clarification,” Social Networks, vol. 1, no. 3, pp. 215–239, 1978. [40] L. C. Freeman, “A set of measures of centrality based on betweenness,” Sociometry, vol. 40, no. 1, pp. 35–41, 1977. [41] J. H. Michael and J. G. Massey, “Modeling the communication network in a sawmill,” Forest Products Journal, vol. 47, no. 9, 25 pages, 1997. [42] D. Lusseau, K. Schneider, O. J. Boisseau, P. Haase, E. Slooten, and S. M. Dawson, “The bottlenose dolphin community of doubtful sound features a large proportion of long-lasting associations,” Behavioral Ecology and Sociobiology, vol. 54, no. 4, pp. 396–405, 2003. [43] D. E. Knuth, The Stanford GraphBase-A Platform For Combinatorial Computing, ACM, New York, NY, USA, 1993. [44] M. E. Newman, “Finding community structure in networks using the eigenvectors of matrices,” Physical Review E, Statistical, Nonlinear, and Soft Matter Physics, vol. 74, no. 3, Article ID 036104, 2006. [45] Y. Bengio, A. Courville, and P. Vincent, “Representation learning: a review and new perspectives,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 35, no. 8, pp. 1798–1828, 2013. [46] Y. Goldberg and O. Levy, “word2vec explained: deriving Mikolov et al.’s negative-sampling word-embedding method,” 2014, http://arxiv.org/abs/1402.3722. [47] B. Perozzi, R. Al-Rfou, and S. Skiena, “DeepWalk: online learning of social representations,” in Proceedings of the 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 701–710, ACM, New York, NY, USA, August 2014. [48] M. McPherson, L. Smith-Lovin, and J. M. Cook, “Birds of a feather: homophily in social networks,” Annual Review of Sociology, vol. 27, no. 1, pp. 415–444, 2001. [49] T. Mikolov, K. Chen, G. Corrado, and J. Dean, “Efficient estimation of word representations in vector space,” in Proceedings of the International Conference on Learning Representations, ICLR 2013, Scottsdale, AZ, USA, May 2013. [50] I. Borg and P. J. Groenen, Modern Multidimensional Scaling: Theory and Applications, Springer Science & Business Media, Berlin, Germany, 2005. [51] F. Wickelmaier, An Introduction to MDS, 46 pages, Aalborg University, Aalborg, Denmark, 2003. [52] W. W. Zachary, “An information flow model for conflict and fission in small groups,” Journal of Anthropological Research, vol. 33, no. 4, pp. 452–473, 1977. [53] T. M. J. Fruchterman and E. M. Reingold, “Graph drawing by force-directed placement,” Software: Practice and Experience, vol. 21, no. 11, pp. 1129–1164, 1991. [54] S. Bhagat, G. Cormode, and S. Muthukrishnan, “Node classification in social networks,” Social Network Data Analytics, Springer, Berlin, Germany, pp. 115–148, 2011. [55] W. D. Nooy, A. Mrvar, and V. Batagelj, Exploratory Social Network Analysis with Pajek, Cambridge University Press, Cambridge, UK, 2011. [56] D. A. Smith and D. R. White, “Structure and dynamics of the global Economy: network analysis of international trade 1965–1980,” Social Forces, vol. 70, no. 4, pp. 857–893, 1992. [57] D. Chirot and T. D. Hall, “World-system theory,” Annual Review of Sociology, vol. 8, no. 1, pp. 81–106, 1982. [58] J. Leskovec, J. Kleinberg, and C. Faloutsos, “Graph evolution,” ACM Transactions on Knowledge Discovery from Data, vol. 1, no. 1, 2 pages, 2007. [59] R. Guimer` a, L. Danon, A. D´ ıaz-Guilera, F. Giralt, and A. Arenas, “Self-similar community structure in a network of human interactions,” Physical Review E, Statistical, Nonlinear, and Soft Matter Physics, vol. 68, no. 6, Article ID 065103, 2003. Complexity 17