0% found this document useful (0 votes)
56 views16 pages

01 2.1 Clustering Coefficient

This document discusses methods for measuring clustering in social networks. The local clustering coefficient measures the fraction of a node's friends that are also friends. The global clustering coefficient can be measured as the average local clustering coefficient or through transitivity, which is the ratio of triangles to open triads in the network. NetworkX functions like nx.clustering() and nx.transitivity() can calculate these metrics.

Uploaded by

denice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views16 pages

01 2.1 Clustering Coefficient

This document discusses methods for measuring clustering in social networks. The local clustering coefficient measures the fraction of a node's friends that are also friends. The global clustering coefficient can be measured as the average local clustering coefficient or through transitivity, which is the ratio of triangles to open triads in the network. NetworkX functions like nx.clustering() and nx.transitivity() can calculate these metrics.

Uploaded by

denice
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

APPLIED SOCIAL NETWORK

ANALYSIS IN PYTHON

Triadic Closure

Triadic closure: The tendency for


people who share connections in a social
network to become connected.

How can we measure the prevalence of


triadic closure in a network?
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient

Local clustering coefficient of a node:


Fraction of pairs of the node’s friends that are
friends with each other.
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

# of pairs of Cʹ s friends =
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

ʹ 𝑑" (𝑑" − 1)
# of pairs of C s friends =
2
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

ʹ 𝑑" (𝑑" − 1) 12
# of pairs of C s friends = = = 6
2 2
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

ʹ 𝑑" (𝑑" − 1) 12
# of pairs of C s friends = = = 6
2 2
# of pairs of Cʹ s friends who are friends =
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

ʹ 𝑑" (𝑑" − 1) 12
# of pairs of C s friends = = = 6
2 2
# of pairs of Cʹ s friends who are friends = 2
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node C:
# of pairs of Cʹ s friends who are friends
# of pairs of Cʹ s friends

# of Cʹ s friends = 𝑑" = 4 (the “degree” of C)

ʹ 𝑑" (𝑑" − 1) 12
# of pairs of C s friends = = = 6
2 2
# of pairs of Cʹ s friends who are friends = 2
2 1
Local clustering coefficent of C = =
6 3
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node F:
# of pairs of F ʹ s friends who are friends
# of pairs of F ʹ s friends

𝑑. = 3
ʹ 𝑑. (𝑑. − 1) 6
# of pairs of F s friends = = = 3
2 2
# of pairs of Fʹ s friends who are friends = 1
1
Local clustering coefficent of F =
3
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Compute the local clustering coefficient of node J:
# of pairs of J ʹ s friends who are friends
# of pairs of J ʹ s friends

# of pairs of Jʹ s friends = 0 (Can not divide by 0)

We will assume that the local clustering coefficient


of a node of degree less than 2 to be 0.
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Local Clustering Coefficient


Local clustering coefficient in NetworkX:

G = nx.Graph()
G.add_edges_from([('A', 'K'), ('A', 'B'), ('A', 'C'), ('B', 'C'), ('B', 'K'),
('C', 'E'), ('C', 'F'), ('D', 'E'), ('E', 'F'), ('E', 'H'), ('F', 'G'), ('I', 'J')])

In: nx.clustering(G, 'F')


Out: 0.3333333333333333

In: nx.clustering(G, 'A')


Out: 0.6666666666666666

In: nx.clustering(G, ’J')


Out: 0.0
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Global Clustering Coefficient


Measuring clustering on the whole network:

Approach 1: Average local clustering coefficient


over all nodes in the graph.

In: nx.average_clustering(G)
Out: 0.28787878787878785
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Global Clustering Coefficient


Measuring clustering on the whole network (Approach 2):

Percentage of “open triads” that are triangles in a network.

Triangles: 3∗Number of closed triads


Transitivity =
Number of open triads

Open triads:
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Global Clustering Coefficient


Measuring clustering on the whole network:

Transitivity: Ratio of number of triangles and


number of “open triads” in a network.

In: nx.transitivity(G)
Out: 0.409090909091
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Transitivity vs. Average Clustering Coefficient


Both measure the tendency for edges to form triangles.
Transitivity weights nodes with large degree higher.

• Most nodes have • Most nodes have


high LCC low LCC
• The high degree • High degree node
node has low LCC have high LCC

Ave. clustering coeff. = 0.93 Ave. clustering coeff. = 0.25


Transitivity = 0.23 Transitivity = 0.86
APPLIED SOCIAL NETWORK
ANALYSIS IN PYTHON

Summary
Clustering coefficient measures the degree to which nodes in a network
tend to “cluster” or form triangles.
Local Clustering Coefficient Global Clustering Coefficient
Fraction of pairs of the node’s Average Local Transitivity
friends that are friends with each Clustering Coefficient
other. Ratio of number of
triangles and number of
nx.average_clustering(G) “open triads”.
2 1
LCC of C = =
6 3
Puts larger weight on
high degree nodes.
nx.transitivity(G)

You might also like