返回资讯

Network Sampling: A Case Study on Triangle Counting

发布时间:2026年11月4日

What We Do

How can we quickly find the number of triangles in a large social network?

What are triangles?

  • Let's say we are given a indirected graph G=(V, E), where V is a set vertices and E is a set of edges, without self-edges;
  • A triangle is a set of three fully connected nodes.

Why are triangles so important in social networks?

  • Most stable and common cliques;
  • Lying at the herat of the clustering coefficient;
  • Many applications:
    • The distribution of the local number of triangles can be used to create successful spam filters [Becchetti 08];
    • The distribution of trinagles is used to uncover hidden thematic structure in world wide web [Eckmann 02].

Algorithms

So far, we have implemented three algorithms:

  • Edge Iterator: computes for each edge the number of triangles that contain it, with time complexity as O(\sum_i d_i^2 * log M), where d_i is the degree of i-th node, and M is the number of edges, space complexity as O(m).
  • Greedy: only scan top K nodes with largest degrees in Edge Iterator. Particularly, we scan r% (r < 100) of vertices in our experiments.
  • EigenTriangle: an algorithm introduced in [Tsourakakis, 08]. It calculates top K eigenvalues of the adjacent matrix of G and uses them to approximate the number of triangles in G. We utilize ARPACK++ for calculating eigenvalues. 
  • Sampling: it first samples a subnetwork G' by removing each edge with the probability (1-p). For each triangle in G', we let counter += 1/p^3, we use counter to approximate the number of triangles in G. 

Data Set

 

We employ 16 networks from SNAP to test our toolkit. Please find the details of these network below:

Dataset

#Vertices

#Edges

Description

Facebook 4,039 88,234 Social circles from Facebook (anonymized)
Twitter 81,306 2,420,766 Social circles from Twitter
Wiki-vote 7,150 103,710 Wikipedia who-votes-on-whom network
Slashdot-1 77,384 905,482 Slashdot social network from November 2008
Slashdot-2 82,192 948,478 Slashdot social network from February 2009
Epinion 75,899 508,849 Who-trusts-whom network of Epinions.com
Enron 36,720 367,678 Email communication network from Enron
Europe-Email 265,253 420,067 Email network from a EU research institution
Patent 3,774,768
16,518,948
Citation network among US patents.
Cite-HEP-TH 27,797 352,822 Arxiv High Energy Physics Theory paper citation network
Cite-HEP-PH 34,572 421,593 Arxiv High Energy Physics paper citation network
CA-HEP-TH 9,913 51,991 Collaboration network of Arxiv High Energy Physics Theory
CA-HEP-PH 12,043 237,030 Collaboration network of Arxiv High Energy Physics
CA-GRQC 5,276 28,999 Collaboration network of Arxiv General Relativity
CA-CONDMAT 23,166 186,955 Collaboration network of Arxiv Condensed Matter
CA-ASTROPH 18,806 396,179 Collaboration network of Arxiv Astro Physics

 

Performance

We compare our 4 algorithms in 16 networks described above. Particularly, we care about the error rate, which is defined as (Answer - Algorithm_Result) / Answer, and the running time of each algorithm. See the details of the performance report below.​

For Greedy, we set r = 80. For EigenTriangle, we set k = {0.01, 0.001, 0.0001} according to the number of edges in G. For Sampling, we set p = 0.1. 

Download

Download the lattest source code & follow us on Github.​

Relevant document: coming soon...