G-Tries: a data structure for storing and finding subgraphs

Pedro Ribeiro and Fernando Silva



The ability to find and count subgraphs of a given network is an important non trivial task with multidisciplinary applicability. Discovering network motifs or computing graphlet signatures are two examples of methodologies that at their core rely precisely on the subgraph counting problem. Here we present the g-trie, a data-structure specifically designed for discovering subgraph frequencies. We produce a tree that encapsulates the structure of the entire graph set, taking advantage of common topologies in the same way a prefix tree takes advantage of common prefixes. This avoids redundancy in the representation of the graphs, thus allowing for both memory and computation time savings. We introduce a specialized canonical labeling designed to highlight common substructures and annotate the g-trie with a set of conditional rules that break symmetries, avoiding repetitions in the computation. We introduce a novel algorithm that takes as input a set of small graphs and is able to efficiently find and count them as induced subgraphs of a larger network. We perform an extensive empirical evaluation of our algorithms, focusing on efficiency and scalability on a set of diversified complex networks. Results show that g-tries are able to clearly outperform previously existing algorithms by at least one order of magnitude.


Complex Networks; Subgraphs; Data structures; Trees; Network motifs; Graphlets

Digital Object Identifier (DOI)

doi 10.1007/s10618-013-0303-4

Publication in PDF format

pdf Download PDF


software gtrieScanner


Data Mining and Knowledge Discovery

Reference (text)

Pedro Ribeiro and Fernando Silva. G-Tries: a data structure for storing and finding subgraphs. In Data Mining and Knowledge Discovery, Vol. 28(2), pp. 337-377, Springer, March, 2014.


  author = {Pedro Ribeiro and Fernando Silva},
  title = {G-Tries: a data structure for storing and finding subgraphs},
  doi = {10.1007/s10618-013-0303-4},
  journal = {Data Mining and Knowledge Discovery},
  volume = {28},
  issue = {2},
  pages = {337-377},
  publisher = {Springer},
  month = {March},
  year = {2014}