I Introduction and Related Work
Many graphs consist of labeled elements and many relations between elements. For example, two people in a social network can belong to different communities and interact in symmetric (e.g. as friends or colleagues) as well as asymmetric (e.g. one as fan of the other) ways. Such social networks can be represented as graphs whose nodes are people (or types of people) and edges between two persons may represent multiple interactions.
Similarly, protein-protein interaction graphs consist of nodes representing genes with particular identifiers connected by undirected edges. Combining a protein-protein interaction graph with a directed transcriptional graph can give rise to a graph in which a transcription factor may both physically interact (at the protein level) with a gene and induce its transcription. Thus, such graphs have multiple labels on nodes (e.g., developmental gene and transcription factor) and multiple edges between two nodes (e.g., a directed transcriptional edge and an undirected protein-protein interaction edge).
Analyzing such graphs can help to discover common features and underlying mechanisms that occur. Examples of graph analysis include: i) finding motifs, i.e. unexpectedly highly recurrent pattern of interactions, in a single graph [29, 30, 31, 32], ii) frequent subgraph mining with respect to a graph database or a single graph , and iii) graph alignment, i.e. finding structurally conserved subgraphs in a collection of graphs [3, 18, 25, 26, 27, 28]. In this paper, we focus on the Subgraph Matching problem on Multigraphs called Sub-Multigraph Matching (SMM), i.e. finding all the occurrences of a small query sub-multigraph, in a larger target multigraph, a problem known to be NP-complete already on simple graphs . The matching problem can also be inexact, allowing missing nodes and/or edges or different node and/or edge labels (see  for a comprehensive review), or deal with probabilistic graphs . However, the innovations in this paper pertain only to exact matching.
While subgraph matching (SM) is NP-complete, the complexity of graph isomorphism is unknown, though there has been excellent work in the area, with applications to image analysis, document processing, biometric identification and natural language processing[9, 12, 39, 15].
The SM problem has attracted much research in the case of simple graphs, i.e. graphs where there is exactly one edge between two nodes, which usually have single labels
. In the literature, several algorithms have been proposed and they can be classified into two major classes according to the paradigm used to solve the matching problem: Tree Search (TS) algorithms and Constraint Propagation (CP) algorithms.
Tree Search algorithms formulate the matching problem in terms of a State Space Representation (SSR), which consists of the exploration of a search space tree. Each state of the SSR corresponds to a partial solution. The search space is visited in a depth-first order and heuristics are devised to avoid exploring parts of the search space. Algorithms of this class include Ullmann’s algorithm, VF2 , VF3 , RI and RI-DS [4, 5].
In Constraint Propagation methods, the subgraph matching problem is represented as a Constraint Satisfaction Problem (CSP). Query nodes are represented as variables and target nodes represent values that can be assigned to such variables. Edges are translated into constraints that must be satisfied. CP algorithms first compute a compatibility domain for each node of the pattern graph and then iteratively propagate the constraints to reduce such domains and filter candidate nodes for matching. CP methods include nRF+ , Focus-Search , Zampelli et al.  and LAD .
While there are several works on subgraph matching in simple attributed or labeled graphs [14, 33, 35], less attention has been paid to the same problem in labeled multigraphs, i.e. graphs where nodes can have one or more labels and one or more labeled edges between two nodes may exist. The Subgraph Matching problem in labeled multigraph is the so-called Sub-Multigraph Matching (SMM) problem. Solving an instance of the SMM problem means to find all occurrences of the query in the target, such that all the labels of query nodes are present in the matched target nodes and all labeled edges in the query are present in the matched target edges. To the best of our knowledge, SuMGra  is the only algorithm proposed to solve the SMM problem.
SuMGra implements an efficient indexing strategy based on the multigraph properties of the target graph, such as node and edge multiplicities. In particular, two indexing structures are built before the searching phase: i) the vertex signature index, which captures information about the labels of edges incident on target nodes together with their multiplicities, ii) the vertex neighborhood index, which contains information about the neighbors of a given node , the edges connecting to its neighbors and the labels of each edge. The two indexes are then used to filter candidate nodes for the initial query node and the subsequent nodes during the search phase.
In this paper we introduce MultiRI, a novel and fast subgraph matching algorithm, inspired by RI [4, 5], for labeled multigraphs. MultiRI performs a series of pre-processing steps to speed up the matching process. These include the computation of: i) compatibility domains, i.e. a set of matchable target nodes, for each query node, ii) the ordering in which query nodes have to be processed during the matching phase, and iii) symmetry breaking conditions  to avoid the outputting of redundant occurrences. Breaking conditions are an aspect that has been already taken into account in the context of motif search [13, 31] but that no previous subgraph matching algorithm has used. Instead, current solutions for the SM and SMM problems ignore redundant occurrences or manage them at the end of the searching process with very naive and time consuming post-processing solutions.
The matching phase uses compatibility domains to scan target node candidates for the match with a query node and applies breaking conditions to avoid the generation of redundant occurrences. Our pre-processing and matching phase strategies result in significant improvements (up to one order of magnitude) across a variety of graphs and queries and enable scaling to multigraphs with millions of nodes and edges.
This paper compares MultiRI with SuMGra on a comprehensive benchmark of graphs. Results show that MultiRI outperforms SuMGra by up to one order of magnitude. A further scalability analysis shows that MultiRI is capable of dealing with large graphs: it is able to retrieve sub-multigraph occurrences within multigraphs containing millions of nodes and edges in few seconds. The paper is organized as follows. In Section II we give preliminary definitions. Section III introduces MultiRI providing details about its searching strategy. Section IV presents the experimental analysis. Section V concludes the paper by summing up the key innovations introduced by MultiRI.
Ii Preliminary definitions
These preliminary definitions describe the data types and the problem.
Definition 1 (Labeled Multigraph).
A labeled multigraph is a quintuple where is an alphabet of node labels, is an alphabet of edge labels, is the set of nodes, is the set of edges, each of which links two nodes and has a label and ( is the power set of ) is a function that assigns one or more distinct labels to each node in .
Each node in the graph has a unique identifier or id belonging to . With we denote the id of node . If , we say that is a neighbor of . A labeled multigraph is undirected iff , i.e. all neighbor relationships go both ways, directed otherwise. The neighborhood of is defined as . The neighborhood of a set of nodes is the set of nodes that are neighbors of at least one node in , i.e. S. For undirected multigraphs, the degree of a node , , is the number of neighbors of . In the case of directed multigraphs, we distinguish between the out-degree, , and the in-degree, . The multiplicity of a node , denoted as , is the number of labels of . If , we define . The multiplicity of a pair of nodes and , is the number of edges between and , i.e. .
The Sub-Multigraph Matching (SMM) is defined as follows:
Definition 2 (Sub-Multigraph Matching (SMM)).
Let and two labeled multigraphs, named query and target, respectively. The Sub-Multigraph Matching (SMM) problem aims to find an injective function , called a mapping, which maps each node in to a node in , such that the following conditions hold:
In other words, in the SMM problem all the labels of a query node must be present in the matched target node, but not necessarily conversely (condition 1). Further, each query edge must have a match with a target edge having the same label of (condition 2), again not necessarily conversely. If and have the same number of nodes and edges, the mapping is also called an isomorphism from to and and are said to be isomorphic.
The SMM problem can have more than one solution, i.e. there may exist one or more mappings. Given a mapping , a match of in is defined as the set of pairs of query and target matched nodes , where .
Fig 1 shows a toy example of SMM with a query and a target . In this case there are four matches of in , namely , , and .
An occurrence of in is the subgraph of formed by nodes and all edges such that for all . In other words, is isomorphic to .
Definition 3 (Automorphism).
Given a graph , an automorphism of is a permutation of the set of nodes such that:
In other words, an automorphism is a rearrangement of the set of nodes that preserves the structure of a graph and the labels of its nodes and edges. The result of the application of an automorphism is a new graph , obtained from by permuting the ids of its nodes based on . is said to be automorphic to .
Definition 4 (Automorphism Matrix).
Given a graph with nodes and automorphisms . The automorphims matrix, is a matrix containing rows and columns, where .
Definition 5 (Orbit).
Given an automorphims matrix , for a given a column of the matrix, , its set of nodes is an orbit of .
We denote with the orbit to which node belongs.
Fig. 2 illustrates a toy example of automorphisms and orbits. As the example shows, the number of distinct orbits may be less than the number of columns since two columns may have the same set of nodes. Furthermore orbits may have different cardinalities.
Iii MultiRI algorithm description
In this section we describe MultiRI, a novel algorithm for solving the SMM problem.
Fig. 3 describes the main steps of the MultiRI algorithm: (i) computation of compatibility domains, (ii) ordering of query nodes, (iii) computation of symmetry breaking conditions and (iv) matching process. Below, we describe each step in detail. MultiRI has been implemented in the Java and C++ languages. Both versions are freely available at https://alpha.dmi.unict.it/~gmicale/MultiRI.
Iii-a Computation of compatibility domains
The first step of MultiRI computes for each query node the compatibility domain which is the set of nodes in the target graph that could match based on node labels and degree. This step speeds up the matching process, because only target graph nodes in are considered to be possible candidates for a match to during the search.
Formally, let be a query labeled multigraph and be a target labeled multigraph. A node is compatible to a node iff the following conditions hold:
Therefore, is compatible to iff all the labels of node are also labels of (condition 1) and the degree of is less than or equal to the degree of (condition 2). In the case of directed multigraphs, condition 2 must hold for both the out-degree and the in-degree of and .Computation of domains is detailed in the pseudocode of Fig. 1 in the Appendix.
Referring to the toy example of Fig. 1, target node is compatible to query node , because the red node label of is among the labels of and . Target nodes and are compatible to too, so the compatibility domain of is .
After computing compatibility domains, an Arc Consistency (AC) technique is applied [6, 21]. The AC procedure states that if there exists an edge between two pattern nodes, and , then a target node in must have at least one neighbor in , and vice versa. This implies that if a target node belongs to the domain of a query node but does not satisfy the AC condition, it can be removed from . The AC procedure is detailed in lines 11-19 of Fig. 1.
Iii-B Ordering of query nodes
In the next step, MultiRI computes the order in which query nodes have to be processed for the search during the matching. This step is done in the same way as in the RI algorithm [4, 5]. The idea is to define a preferred order of processing query nodes, without regard to the target graph. We have found that this works well in practice.
In MultiRI, query nodes that both have high degree and are highly connected to nodes already present in the partial ordering come earlier in the final ordering. Fig. 2 in the Appendix illustrates the main steps of the algorithm to compute the ordering of query nodes.
Formally, let be the number of nodes in the query and be the partial ordering up to the -th node, with . We also define the set of unordered query nodes, i.e. nodes that are not in the partial ordering . To choose the next node of the ordering, we define for each candidate query node three sets (Fig. 2, lines 10-23):
: the set of nodes in and neighbors of ;
: the set of nodes in that are neighbors of at least one node in and connected to ;
: the set of neighbors of that are not in and are not even neighbors of nodes in .
The next node in the ordering (Fig. 2, lines 24-28) is the one with: (i) the highest value of , (ii) in the case of a tie in (i), the highest value of , (iii) in the case of a tie in (ii), the highest value of . In case of a tie according to all criteria, the next node is arbitrarily chosen.
Iii-C Computation of symmetry breaking conditions
One issue arising in subgraph matching is that the matching process may yield redundant occurrences.
Fig. 4 depicts a toy example with the query and the target of Fig. 1. Query nodes and have the same sets of labels, so they are indistinguishable. Since we can map the two nodes indifferently to target nodes with ids and , the two matches of in , and actually correspond to the same occurrence in . Therefore, one of them should be excluded in the final occurrence count. The same exclusion applies to matches and .
In order to exclude redundant occurrences during the matching process and prune the search space, MultiRI defines symmetry breaking conditions based on the node identifiers within the query graph.
Symmetry breaking conditions are related to the concepts of automorphisms and orbits of the query graph.
Given two query nodes and belonging to the same orbit, with , a symmetry breaking condition is an inequality of the form , indicating that node must precede node . In other words, a symmetry breaking condition is a condition that imposes a relative order between two query nodes belonging to the same orbit.
In the query graph of Fig. 2 nodes and belong to the same orbit and their ids are 2 and 3, respectively. So, we can define a symmetry breaking condition .
The algorithm for computing the set of all symmetry breaking conditions in a query is provided in Fig. 5. It is based on an iterative computation of query automorphisms and orbits starting from the current set of symmetry breaking conditions discovered by the algorithm. Given a set of breaking conditions , we denote with and the automorphism matrix and the set of orbits respecting the breaking conditions in , respectively. When is empty, corresponds to the automorphism matrix of and is the corresponding set of orbits. A breaking condition in , prevents from being mapped to in any automorphism. Then, becomes the automorphism matrix obtained from the set of all query automorphisms where is not mapped to , for all nodes and such that . is the set of orbits relative to .
The first step of the algorithm is the computation of the automorphism matrix of (Fig. 5, line 2). This can be accomplished by using any graph matching algorithm (e.g. the NAUTY algorithm ). Then, the orbits of are calculated (Fig. 5, line 3) and the query node with minimum id across all orbits with at least two equivalent nodes is computed (Fig. 5, line 5). For each node belonging to the same orbit of , a new symmetry breaking condition is defined and added to the final set of conditions (Fig. 5, line 7). This step is equivalent to preventing node from being mapped to any other node and putting in a separate orbit. To be consistent with that, we need to retain from the current automorphism matrix only the rows corresponding to the automorphisms mapping to itself (Fig. 5, line 9) and update the relative set of orbits (Fig. 5, line 10).
Note that line 10 of Fig. 5 does not always consist in just creating a new orbit containing , because putting in a separate orbit may also change the orbits of the remaining nodes. Consider, for example, an unlabeled square query with nodes and such that is linked to , is linked to , and so on. At the beginning we have (i) two automorphisms: the identity mapping and the permutation which swaps with and with , and (ii) two orbits: the first one containing and and the second one containing and . If we set the breaking condition , then we discard . As a result, both orbits change and each node is put in a separate orbit. Steps in lines 5-10 of Fig. 5 are iterated until has only one row (corresponding to the identity mapping) (Fig. 5, line 4). This is equivalent to having orbits with a single node, where is the number of query nodes.
Fig. 6 illustrates the execution of the algorithm for computing symmetry breaking conditions in a toy example.
Iii-D Matching process
Following the previously defined ordering of query nodes, MultiRI starts the matching process to find occurrences of the query within the target, using breaking conditions for pruning as it proceeds. Figs. 3 and 4 in the Appendix detail the steps of the matching process.
Matching is done by building a mapping function (initially undefined for all query nodes) and the corresponding match , which is initially empty (lines 3-6 of Fig. 3). Whenever a new match between a query node and a target node is found, the pair is added to (Fig. 4, line 4). When all query nodes have been matched, constitutes a new match of in , so it can be added to the list of matches found (Fig. 4, line 7).
The core of the matching process is the recursive Match procedure illustrated in Fig. 4. Let be the partial match found and a query node that has not been matched yet. If is the node that preceeds in the ordering , the set of candidate target nodes to be matched to is given by , i.e. the set of nodes which are neighbors of the target node that has been already matched to and are in the compatibility domain of (Fig. 4, line 12). If is the first node in , then the set of candidate nodes is just the compatibility domain of (line 8 of Fig. 3).
If some feasibility rules are satisfied, MultiRI adds the pair to the partial match and updates the mapping function (Fig. 4, lines 3-5).
When all query nodes have been matched, a new occurrence of in is found and the corresponding match is added to the list of matches found (Fig. 4, line 7).
Whenever all query nodes have been matched or no match has been found for a query node, the algorithm backtracks and continues the search from the last matched node (Fig. 4, lines 8-9 and 18-19). Backtracking implies removing both the last pair of matched query and target nodes from and the mapping between such nodes using . When no other matches can be built for any query node, MultiRI stops (Fig. 4, line 21).
At the end of the matching process, the algorithm returns the list of all matches found (Fig. 3, line 10).
Checking for Feasibility. Feasibility rules are defined in order to i) take into account the links of to already matched nodes and ii) ensure that the partial match does not result in a redundant occurrence. The latter condition can be satisfied by using symmetry breaking conditions and the following rule:
Symmetry Breaking Condition (SBC) rule: Let be a query with nodes , a target, the mapping between nodes of and and the corresponding match. Let and be any two query nodes. If but , then discard .
In other words, the SBC rule prevents certain mappings. Specifically, the SBC rule discards any mapping whose identifier order among the target nodes of a particular query orbit is inconsistent with the identifier of the query nodes of that orbit.
In the query of Fig. 4, is the only symmetry breaking condition. By applying the SBC rule, the match is included as a solution, because , whereas the match is discarded, because .
A candidate target node is matched to a query node iff the following feasibility rules hold:
Condition 1 applies the SBC rule and eventually discards a partial match that does not satisfy the order between already matched target nodes imposed by the rule. Condition 2 guarantees that every outgoing edge from to already matched query nodes has a corresponding matched edge in the target graph with the same label.
Thanks to the SBC rule, at the end of the matching process no redundant occurrences will be returned. Appendix (Lemma 2) proves this.
Iii-E MultiRI complexity analysis
In this section we analyze the time and space complexity of MultiRI. Let the number of query nodes, the number of target nodes.
The first step of MultiRI is the computation of compatibility domains. The building of domains (Fig. 1, lines 4-10) requires , while the AC procedure (Fig. 1, lines 11-19) takes because, in the worst case, for each query outgoing edge from we need to check all outgoing edges from target nodes in . So, computation of compatibility domains requires .
Then, MultiRI computes the ordering of query nodes for the matching process. The core of this step is the building of sets , and (Fig. 2, lines 13-21), which requires .
The third step of MultiRI is the computation of symmetry breaking conditions. The calculation of the automorphism matrix for the query (Fig. 5, line 2) is at least as difficult as solving graph isomorphism , and its complexity is bound by . Orbits are computed (Fig. 5, line 3) by scanning the automorphism matrix column by column. Since the number of automorphisms of a graph with nodes is at most (in the case the graph is complete), calculating orbits requires . In the worst case at each step of the while loop (Fig. 5, lines 4-11) the number of automorphisms decreases only by one and the loop is executed times. So, the computation of breaking conditions takes .
Finally, we evaluate the computational complexity of the matching process (Fig. 4). For ease of simplicity, we start with the case in which we do not have labels on nodes and edges and breaking conditions are not applied. In Section IV-F, we will empirically show how breaking conditions reduce the computation time of MultiRI. The computational complexity of the matching process depends on: i) the number of examined candidate pairs for the matching and ii) the time needed to check the feasibility rules for each candidate pair. In the worst case, the compatibility domain of each query node has nodes and the number of neighbors of each query node is at most . Therefore, the set of candidate nodes for the initial query node in the ordering has at most nodes ( Fig. 3, line 8). Once a new pair has been added to the partial match, the set of candidate nodes for the next query node in the ordering (Fig. 4, line 12) is at most , where is the number of already matched target nodes. By summing up, the total number of examined candidate pairs is . Since the last term of the summation is dominant, this sum is , i.e. . For each candidate pair, checking the feasibility rules (Fig. 4, line 2) requires , because we are ignoring breaking conditions. Therefore, the complexity of the matching process is , which is also the time complexity of MultiRI.
When we also consider breaking conditions, checking the feasibility rules in the matching process now requires , which is again . The number of explored candidate pairs scales by a factor , which depends on the topology of the query. Therefore, the complexity of MultiRI becomes .
For some special classes of topologies, we can provide theoretically an upper bound for . For instance, in the case of paths with any number of nodes, is at most 2. Therefore, a path can be traversed twice in two opposite directions, following two different orders of nodes. In this case, however, breaking conditions require the traversal of the path in only one direction. For stars, is at most , because we need to match the central node and one of the external nodes of the star in all possible ways, while the remaining nodes will be matched iff the ids of the candidate target nodes for the match will follow the order imposed by breaking conditions. Likewise, for a clique, is bounded by , because the first query node can be matched in all possible ways, but matches for the remaining nodes are subjected to breaking conditions.
Compared to MultiRI, the computational complexity of SuMGra is the same except for the factor related to breaking conditions, because in the worst case the number of examined candidate pairs for matching and the time needed to check if a pair can be added to the partial match are the same.
For general labeled multigraphs, a theoretical evaluation of the computational complexity of MultiRI becomes very unwieldy, because there are many ways in which node and edge labels can be combined and this has to be related to the multiplicity of nodes and edges and query’s topology too. For such general graphs, our experimental results show the impact of each of these features on the time performance of our algorithm. Please see Section IV-F.
Regarding the spatial complexity of MultiRI, given the edge multiplicity in the query and the target graph respectively, the query and the target graph require and space in the worst case, respectively. Additional data structures used by the algorithm during the search include the set of compatibility domains for each query node ( space in the worst case), the set of symmetry breaking conditions for the query ( space), the mapping and the partial match (both require space) and the set of candidate target nodes for the matching for each query node (which costs ). Therefore, the total spatial complexity of MultiRI is . Assuming and , this is dominated by , i.e. the space needed to store the target graph.
Iv Experimental Analysis
In this section we first analyze the performance of MultiRI on a benchmark of synthesized labeled multigraphs having varying number of nodes, varying number of node and edge labels, and varying node and edge multiplicities. We next test our algorithm on a dataset of real graphs of medium size (tens of thousands nodes and edges). For both real and synthetic graphs, we compare MultiRI with SuMGra , the state-of-the art algorithm for the SMM problem. We use a customized version of SuMGra provided by the authors that can handle multiple labels on nodes. In all experiments we evaluate the running times and the memory usage of both algorithms. Finally, we test the scalability of our method on a large actor association graph with millions of nodes and edges.
For the experimental analysis presented here we used the Java implementation of MultiRI. (Java is both more portable and is usually faster than our C++ version.) All experiments have been performed on an Intel Core i3-3240 CPU 3.40 Ghz with 32 GB RAM.
Iv-a Synthetic dataset
To test the performance of MultiRI and SuMGra on graphs of different size and variable number of node labels and edge multiplicities, we generated a benchmark of artificial undirected labeled multigraphs.
We used Barabasi-Albert  as the generative model. This model adopts the preferential attachment principle: a new node enters the graph and creates a link to an existing node
with a probability proportional to the out-degree of(which is the same as the degree for the undirected case). The Barabasi-Albert model describes the structure of graphs having few nodes with high degree, called hubs, and many nodes with low degree.
Artificial graphs were generated based on three values for each of the following features in the target graph:
Number of nodes : 10,000, 20,000 and 50,000;
Density , i.e. the ratio between the number of edges and the number of nodes: 2, 5 and 10 (multiple edges between two nodes are counted only once);
Number of distinct node labels : 2, 10 and 20;
Maximum node multiplicity (i.e. maximum number of labels that any single node has): 2, 4 and 6;
Number of distinct edge labels : 2, 10 and 20;
Maximum edge multiplicity (i.e. maximum number of edges there can be between two nodes) : 2, 4 and 6.
We generated 10 graphs for each combination of values of these features. When , is set to 2. Likewise, when , is set to 2. Labels for a node are numeric values between 1 and and are chosen as follows: first, the node multiplicity is set to a random value between 1 and , then distinct random labels are assigned to . Edge labels are numeric values between 1 and and are chosen similarly to node labels.
Queries for the experiments were randomly extracted from synthetic graphs as follows. We considered queries with nodes and, for each value of , we extracted 10 queries with nodes from graph as follows:
Compute the set of all connected components of with at least nodes in the graph;
Select uniformly and randomly a connected component in ;
Select a node
randomly with uniform distribution fromand do a random walk with restart which ends when exactly nodes in have been visited;
Consider the graph formed by all nodes and edges traversed during random walk;
Call , the set of edges between nodes of that are not present in , the remaining set. Pick a random number uniformly between 0 and , select randomly and without replacement edges in and add them to .
The final dataset includes 5,880 synthetic graphs and 132,300 queries.
Iv-B Real dataset
The performance of MultiRI and SuMGra have also been evaluated on a dataset of five real labeled multigraphs. Tab. I describes the main features of these graphs.
openflights is an undirected graph extracted from OpenFlights.org111https://openflights.org, a repository of data about airports, airlines, airplanes and routes. Nodes of openflights are world cities and node labels are the types of airports that are present in that city: air terminals, train stations and/or ferry terminals. Edges connect two cities if there is at least one air route linking them. Edges are labeled with the types of airplanes that fly between the two cities: ’short range’, ’short to medium range’, ’medium range’, ’medium to long range’ and ’long range’ planes.
foldoc is a semantic directed graph taken from the on-line computing dictionary FOLDOC222http://foldoc.org, where nodes are computer science terms and edges connect two terms and iff is used to explain the meaning of . Computing terms in foldoc have been labeled according to their domains (e.g. ’computer science’, ’hardware’, ’programming’, ’operating systems’). Edge labels represent the number of times a term is used to explain the meaning of another term.
ppiyeast is a protein-protein interaction network downloaded from Saccharomyces Genome Database (SGD)333http://www.yeastgenome.org. Proteins in ppiyeast have been annotated using the MIPS functional catalogue FunCat . So, node labels represent one or more functions or processes in which a protein is involved. Edges are labeled according to the type of interaction (physical and/or genetic), which is included in the SGD interaction data.
swissleaks is a relationship directed graph of people involved in the Swiss Leaks, a journalistic investigation in 2015 about giant tax evasion involving the British bank HSBC and its Swiss subsidiary, the HSBC Private Bank. Data are provided by the International Consortium of Investigative Journalists (ICIJ)444https://github.com/swissleaks/swiss_leaks_data. Nodes are people, companies and addresses and they are labeled according to their type: ’officer’ and/or ’master client’ for people, ’address’ for addresses and ’entities’ for companies. Edges denote the relationships between two nodes (e.g. ’director of’,’shareholder of’ or ’registered address’).
imdb is an association graph of movies extracted from the Internet Movie DataBase (IMDB)555http://www.imdb.com. Nodes are movies and an edge connects two movies if they share one or more actors, directors, producers and/or writers. Movies are labeled according to their genres (e.g. ’horror’, ’comedy’, ’drama’, ’thriller’). Edges are labeled according to the role of people shared by two movies (i.e. ’actors’, ’directors’, ’writers’ and/or ’producers’).
Iv-C Comparison between MultiRI and SuMGra on synthetic graphs
We first tested MultiRI and SuMGra on the graphs of the synthetic dataset. For each graph and each query of the dataset, we ran both algorithms and measured the corresponding running time and memory usage. In each experiment we fixed a timeout of 5 minutes for the execution of an algorithm.
To analyze the impact of each graph feature used to build the synthetic dataset on the performance, we varied one feature at a time and fixed all other features to their median value. Therefore, for example, if the feature of interest is the number of nodes , all experiments with , , , and are considered and partitioned into three groups according to the value of . Running times and memory consumption for MultiRI and SuMGra were then plotted as boxplots. Running times were considered only for experiments in which both algorithms ended before the timeout, while for memory usage we took into account all tests. Considering all experiments on synthetic graphs, both algorithms ended before the 5 minute timeout in 95.1% of the cases. In 0.3% of the experiments only MultiRI finished before the timeout, while in 0.3% of the cases only SuMGra ended before the timeout. In 4.3% of the experiments neither algorithm completed before the timeout.
Fig. 7 depicts boxplots of running times for varying values of number of target nodes, target density, number of node labels, maximum node multiplicity, number of edge labels, maximum edge multiplicity and number of query nodes, respectively.
Experimental results show that MultiRI generally outperforms SuMGra by one order of magnitude. The largest difference between SuMGra and MultiRI can be observed when varying the number of target nodes (Fig. (a)a), maximum node and edge multiplicity (Figs. (d)d and (f)f) and number of query nodes (Fig. (g)g). This shows the capability of MultiRI to perform well with large target graphs with a high multiplicity on both nodes and edges and large queries.
In Fig. 8 we compare the performance of both algorithms on each experiment performed with synthetic graphs. We show the ratios between the running time of MultiRI and the running time of SuMGra for each experiment. Experiments are ordered based on the ratios. Compared to SuMGra, MultiRI is eight times faster on average and finishes before SuMGra in 97% of the instances.
Fig. 9 show boxplots of memory usage of both algorithms. MultiRI generally uses less memory than SuMGra, except for networks with few node or edge labels, where we can observe a lot of variability in memory usage. The difference between the two algorithms is more evident when we consider bigger and denser graphs (Figs. (a)a and (b)b) and graphs with high edge multiplicity (Fig. (f)f). Interestingly, in these three cases both algorithms have an increase of memory usage, while in all remaining cases there is no significant variation in memory consumption. This suggests that the spatial complexity of both MultiRI and SuMGra is mainly influenced on the size of target graph and its edge multiplicity. In particular the one of SuMGra looks to be exponentially dominated by such a factor.
Iv-D Comparison between MultiRI and SuMGra on real graphs
Next, we tested MultiRI and SuMGra on the real dataset. Since SuMGra works only on undirected graphs, the comparison between MultiRI and SuMGra was done by converting all directed edges to undirected edges. However, we also tested MultiRI alone on the two directed multigraphs of our dataset, namely foldoc and swissleaks, to evaluate its performance on directed multigraphs as well.
We randomly extracted 1,000 queries with 4 nodes, 1,000 queries with 10 nodes and 1,000 queries with 16 nodes from each graph, following the extraction procedure described in Section IV-A. Then we ran MultiRI and SuMGra on each query. Again, to plot running times, we considered only experiments in which both algorithms ended before a timeout of 5 minutes, while for memory consumption we took into account all tests. Considering all experiments on real graphs, both algorithms ended before the timeout in 75.9% of the cases. In 1.6% of the experiments only MultiRI finished before the timeout, while in 1.3% of the cases only SuMGra ended before the timeout. In 23.6% of the experiments neither algorithm completed before the timeout.
Fig. 10 shows box-plots of the running times for each real graph for the set of extracted queries with 4, 10 and 16 nodes, respectively.
In the real dataset, SuMGra is almost as fast as MultiRI in the smallest graphs. However, MultiRI is approximately ten times faster than SuMGra in the largest graphs, i.e. swissleaks and imdb. The bottom line is that MultiRI performs well on large graphs.
In Fig. 11 we show boxplots of running times of MultiRI for the two real directed multigraphs of our dataset, i.e. foldoc and swissleaks. Boxplots consider only experiments in which MultiRI ended before a timeout of 5 minutes. MultiRI completed 96% and 27% of the experiments before the timeout for foldoc and swissleaks, respectively.
Again, we also compared the performance of both algorithms on each experiment performed with real graphs. Fig. 12 shows the ratios between the running time of MultiRI and the running time of SuMGra for each experiment. The plot experiments are ordered based on the ratios. In the real networks, MultiRI is on average seven times faster than SuMGra and finishes before SuMGra in 76% of the instances.
In Fig. 13 we compare the memory usage of MultiRI and SuMGra for real graphs. Except for the two smallest networks, i.e. openflights and foldoc, MultiRI uses much less memory than SuMGra for bigger graphs, namely 4 times less for ppiyeast and swissleaks and 1000 times less for imdb. More interestingly, while SuMGra’s memory usage mainly depends on graph size, edge multiplicity seems to be the main factor impacting on memory consumption for MultiRI. Indeed, we observe the highest memory usage of MultiRI (on average 300 MB) for swissleaks, for which .
Iv-E Scalability test
We ran MultiRI and SuMGra on a large collaboration multigraph between people working in the show business (e.g. actors, writers, directors). The graph was extracted from the IMDB database. Nodes are people and edges connect two people if they worked together in at least one movie. People are labeled according to their main profession (i.e. ’actor’, ’director’, ’writer’, ’producer’, ’composer’ and/or ’editor’), while edges are labeled according to the genres of the movies where they worked together (e.g. ’comedy’, ’drama’, ’thriller’). The final graph contains 2,508,369 nodes, 32,768,597 edges, 6 different node labels, 28 different edge labels, and maximum node and edge multiplicities equal to 3 and 22, respectively.
We designed a dataset of queries formed by small cliques with 3, 4 and 5 nodes, to understand if people tend to work together in movies of the same or different genres. In each clique, nodes have the same label, so they are all actors or directors for example, and edges can have all the same labels or mixed labels, considering all possible combinations of movie genres with repetitions. To avoid generating too many queries, we decided to focus on the five most popular genres, i.e. comedy, drama, action, thriller and horror. The final dataset includes 210 3-cliques, 1,260 4-cliques and 6,006 5-cliques.
We weren’t able to get any results from SuMGra, since it required more than 32 GB to perform the matching. By contrast, MultiRI required 20 GB to complete all tasks. The average running time of MultiRI in computing the number of occurrences of 3-cliques, 4-cliques and 5-cliques was 23 secs, 64 secs and 169 secs, respectively. These results show that MultiRI is efficient and scalable with query size.
Iv-F How Symmetry breaking conditions impact performances
In this subsection, we empirically show how symmetry breaking conditions affect the time complexity of MultiRI considering a set of small artificial graphs with varying density. Note that these results are general and hold for any subgraph matching algorithm, even though we applied here for our algorithm.
We built two datasets of artificial graphs generated using the Barabasi-Albert  model.
The first dataset includes unlabeled simple graphs with nodes and varying density . We built 10 networks for each value of , for a total number of 30 networks. Since the efficacy of breaking conditions mainly depends on the topology of the query, we considered three different types of query topologies, namely paths, stars and cliques with nodes.
In Figs. 14 and 15 we compare the running times and the number of examined candidate pairs for matching of MultiRI with breaking conditions and MultiRI with no breaking conditions (called MultiRI-NC) with varying values of target density and query size . For barplots with varying target density we took into account only queries with nodes, while for barplots with varying query size, we considered only targets with density . All results show that breaking conditions reduce time more for dense query topologies than for sparse ones. Specifically, independently of target density and query size, the reduction factor of running times and time complexity, derived theoretically in Section III-E, approximates the upper bounds 2 (for paths), (for stars) and (for cliques).
The second dataset comprises artificial Barabasi-Albert labeled graphs with nodes. Graphs were generated considering the following features in the target graph and three values for each parameter:
Density : 10, 25 and 40, that is the ratio between the number of edges and the number of nodes (multiple edges between two nodes are counted only once);
Number of distinct node labels : 2, 5 and 8;
Maximum node multiplicity (i.e. maximum number of labels that any single node has) : 1, 2 and 4;
Number of edge labels : 2, 5 and 8;
Maximum edge multiplicity (i.e. maximum number of edges there can be between two nodes) : 1, 2 and 4.
We generated 10 graphs for each combination of values of these features. We excluded from the analysis all the combinations with and . Labels for a node are numeric values between 1 and and are chosen as follows: first, the node multiplicity is set randomly and uniformly to a value between 1 and , then distinct labels are assigned to randomly and uniformly without replacement. Edge labels are numeric values between 1 and and are chosen similarly to node labels.
We randomly extracted from each network queries with three different types of topologies (paths, stars and cliques) and varying number of nodes (), by using a random walk approach similar to the one described in Subsection IV-A. For each kind of topology and value of , we extracted 10 queries from each graph. So, the final dataset includes 1,050 artificial labeled graphs and 94,500 queries.
Again, we compared both the running times and the number of examined pairs of MultiRI with and without breaking conditions on varying values of each feature.
Results at first glad say that on average there is no significant difference between the two versions of MultiRI (on both running time and number candidate pairs), even with few labels on nodes and edges and low multiplicities. On the other hand, they present very high standard deviation, implying that there is a lot of variability in results.
Since in this case queries with the same topology may have different number of automorphisms depending on labels and multiplicities of nodes and edges, we grouped queries by their numbers of automorphisms. Then we built boxplots on the time speedup and explored candidate pairs reduction (Fig.
Results at first glad say that on average there is no significant difference between the two versions of MultiRI (on both running time and number candidate pairs), even with few labels on nodes and edges and low multiplicities. On the other hand, they present very high standard deviation, implying that there is a lot of variability in results. Since in this case queries with the same topology may have different number of automorphisms depending on labels and multiplicities of nodes and edges, we grouped queries by their numbers of automorphisms. Then we built boxplots on the time speedup and explored candidate pairs reduction (Fig.16). These results confirm that breaking conditions strongly impact performances when we consider queries with a high number of automorphisms even on labeled multi-graphs.
Labeled multigraphs, i.e. graphs allowing multiple labels on nodes and multiple labeled edges between two nodes) are a natural way to represent information. In fact, they fit applications like movie databases in which actors can act in many genres and in which a given actor and other actor may be related in many ways.
MultiRI is a new algorithm and system for subgraph matching in multigraphs and allows queries on such graphs. MultiRI incorporates a few innovative algorithmic ideas including the use of filters based on lightweight compatibility domains and symmetry breaking conditions. The algorithm has been widely tested using a benchmark of both artificial and real multigraphs. Our analysis shows improvements of about a factor of ten with respect to the state-of-the art, across a variety of graphs and queries, with a limited usage of memory. MultiRI also enables scaling to multigraphs with millions of nodes and edges.
Many useful applications are already within reach of MultiRI as the real graphs of our experiments illustrate. Very large multigraphs will require access to secondary storage and parallelism. Those are subjects of future work.
-  A. L. Barabasi and R. Albert, Emergence of scaling in random networks. Science, 286, pp. 509-512, 1999.
-  V. Batagelj and M. Mrvar and M. Zavesnik, Network analysis of dictionaries. Language Technologies, pp. 135-142, 2002.
-  M. Bayati and D. F. Gleich and A. Saberi and Y. Wang, Message-passing algorithms for sparse network alignment. ACM Transactions on Knowledge Discovery from Data, 7, 2013.
-  V. Bonnici and R. Giugno and A. Pulvirenti and D. Shasha and A. Ferro, A subgraph isomorphism algorithm and its application to biochemical data. BMC Bioinformatics, 14(Suppl 7), S13, 2013.
-  V. Bonnici and R. Giugno, On the Variable Ordering in Subgraph Isomorphism Algorithms. IEEE/ACM Transactions on Computational Biology and Bioinformatics, 14(1), pp. 193-203, 2017.
-  F. Boussemart and F. Hemery and C. Lecoutre, Revision ordering heuristics for the constraint satisfaction problem. Proc. Constraint Propag. Implementation, pp. 29-43, 2004.
-  V. Carletti and P. Foggia and A. Saggese and M. Vento, Challenging the time complexity of exact subgraph isomorphism for huge and dense graphs with VF3. IEEE Trans. Pattern Anal. Mach. Intell. 40(4), pp. 804–818, 2018.
M. Codish and A. Miller and P. Prosser and P. Stuckey, Breaking Symmetries in Graph Representation
. International Joint Conference on Artificial Intelligence, pp. 510-516, 2013.
D. Conte and P. Foggia and C. Sansone and M. Vento, Thirty Years Of Graph Matching In Pattern Recognition
. International Journal of Pattern Recognition and Artificial Intelligence, 18(3), pp. 265-298, 2004.
S. A. Cook, The complexity of theorem-proving procedures
. Proc. 3rd ACM Symposium on Theory of Computing, pp. 151–158, 1971.
-  L. Cordella and P. Foggia and C. Sansone and M. Vento, A (sub)graph isomorphism algorithm for matching large graphs. IEEE Trans. Pattern Anal. Mach.Intell., 26, pp. 1367–1372, 2004.
-  P. Foggia and G. Percanella and M. Vento, Graph Matching and Learning in Pattern Recognition in the Last 10 Years. International Journal of Pattern Recognition and Artificial Intelligence, 2014.
-  J. Grochow and M. Kellis, Network motif discovery using subgraph enumeration and symmetry-breaking. Research in Computational Molecular Biology, pp. 92–106, 2007.
-  L. Hong and L. Zou and X. Lian and P. S. Yu, Subgraph Matching with Set Similarity in a Large Graph Database. IEEE Transactions on Knowledge and Data Engineering, 27(9), pp. 2507-2521.
S. Hu and L. Zou and J. X. Yu and H. Wang and D. Zhao,
Answering Natural Language Questions by Subgraph Matching over Knowledge Graphs. IEEE Transactions on Knowledge and Data Engineering, 30(5), pp. 824-837, 2018.
-  V. Ingalalli and D. Ienco and P. Poncelet, SuMGra: Querying Multigraphs via Efficient Indexing. International Conference on Database and Expert Systems Applications (DEXA 2016), pp. 387-401, 2016.
-  V. Ingalalli and D. Ienco and P. Poncelet, Mining frequent subgraphs in multigraphs. Information Sciences, 451-452, pp. 50-66, 2018.
-  G. W. Klau, A new graph-based method for pairwise global network alignment. BMC Bioinformatics, 10, S59, 2009.
J. Larrosa and G. Valiente,
Constraint satisfaction algorithms for graph pattern matching. Mathematical Structures in Computer Science, 12(4), pp. 403–422, 2002.
-  X. Lian and L. Chen and G. Wang, Quality-Aware Subgraph Matching Over Inconsistent Probabilistic Graph Databases. IEEE Transactions on Knowledge and Data Engineering, 28(6), pp. 1560-1574, 2016.
-  A. K. Mackworth, Consistency in networks of relations. Artif. Intell., 8(1), pp. 99–118, 1977.
K. Madi, Inexact graph matching : application to 2D and 3D Pattern Recognition
. Computer Vision and Pattern Recognition [cs.CV]. Université de Lyon, 2016. English.
-  R. Mathon, A note on the graph isomorphism counting problem. Information Processing Letters, 8, pp. 131–132, 1979.
-  B.D. McKay and A. Piperno, Practical Graph Isomorphism II. Journal of Symbolic Computation, 60, pp. 94-112, 2014.
-  G. Micale and A. Pulvirenti and R. Giugno and A. Ferro, GASOLINE: a Greedy And Stochastic algorithm for Optimal Local multiple alignment of Interaction NEtworks. PLoS One, 9(6), pp. 1-15, 2014.
-  G. Micale and A. Continella and A. Ferro and R. Giugno and A. Pulvirenti, GASOLINE: a Cytoscape app for multiple local alignment of PPI networks. F1000 Research, 3(140), 2014.
-  G. Micale and A. Pulvirenti and R. Giugno and A. Ferro, Proteins comparison through probabilistic optimal structure local alignment. Frontiers in Genetics, 5, pp. 302, 2014.
-  G. Micale and A. Ferro and A. Pulvirenti and R. Giugno, SPECTRA: An Integrated Knowledge Base for Comparing Tissue and Tumor-Specific PPI Networks in Human. Frontiers in Bioengineering and Biotechnology, 3, pp. 58, 2015.
-  G. Micale and R. Giugno and A. Ferro and M. Mongiovì and D. Shasha and A. Pulvirenti, Fast analytical methods for finding significant labeled graph motifs. Data Mining and Knowledge Discovery, 32(2), pp. 504-531, 2018.
-  G. Micale and A. Pulvirenti and A. Ferro and R. Giugno and D. Shasha, Fast methods for finding significant motifs on labelled multi-relational networks. Journal of Complex Networks, 2019.
-  P. Ribeiro and F. Silva, Discovering colored network motifs. Complex Networks V, Studies in Computational Intelligence, Springer, vol. 549, 2014.
-  F. Rinnone and G. Micale and V. Bonnici et al., NetMatchStar: an enhanced Cytoscape network querying app. F1000 Research, 4:479, 2015.
-  S. B. Roy and T. Eliassi-Rad and S. Papadimitriou, Fast best-effort search on graphs with multiple attributes. IEEE Transactions on Knowledge and Data Engineering, 27(3), pp. 755-768, 2015.
-  A. Ruepp and A. Zollner and D. Maier and K. Albermann et al., The FunCat, a functional annotation scheme for systematic classification of proteins from whole genomes. Nucleic Acids Res, 32(18), 2004.
-  M. Saltz and A. Jain and A. Kothari et al., DualIso: An Algorithm for Subgraph Pattern Matching on Very Large Labeled Graphs. 2014 IEEE International Congress on Big Data, pp. 498-505, 2014.
-  C. Solnon, All different-based filtering for subgraph isomorphism. Artificial Intelligence, 174(12–13), pp. 850-864, 2010.
-  J.R. Ullmann, An algorithm for subgraph isomorphism. J. Assoc. Comput. Mach., 23, pp. 31-42, 1976.
Bit-vector algorithms for binary constraint satisfaction and sub- graph isomorphism. Journal of Experimental Algorithmics, 15(1), 2010.
-  M. Vento, A long trip in the charming world of graphs for Pattern Recognition. Pattern Recognition, 48(2), pp. 291-301, 2015.
-  S. Zampelli and Y. Deville and C. Solnon, Solving subgraph isomorphism problems with constraint programming, Constraints, 15(3), pp. 327-353, 2010.