Professional Documents
Culture Documents
Fall 2018
http://www.cs.upc.edu/~caim
1 / 72
7. Introduction to Network Analysis
Network Analysis, Part I
Today’s contents
3 / 72
Examples of real networks
I Social networks
I Information networks
I Technological networks
I Biological networks
4 / 72
Social networks
Links denote social “interactions”
I friendship, collaborations, e-mail, etc.
5 / 72
Information networks
6 / 72
Technological networks
Man-built for the distribution of a commodity
I telephone networks, power grids, transportation networks,
etc.
7 / 72
Biological networks
8 / 72
Representing networks
I Network ≡ Graph
I Networks are just collections of “points” joined by “lines”
points lines
vertices edges, arcs math
nodes links computer science
sites bonds physics
actors ties, relations sociology
9 / 72
Types of networks
From [Newman, 2003]
(a) unweighted,
undirected
(b) discrete vertex and
edge types,
undirected
(c) varying vertex and
edge weights,
undirected
(d) directed
10 / 72
Small-world phenomenon
11 / 72
Measuring the small-world phenomenon, I
I Let dij be the shortest-path distance between nodes i and
j
I To check whether “any two nodes are within 6 hops”, we
use:
I The diameter (longest shortest-path distance) as
d = máx dij
i,j
12 / 72
From [Newman, 2003]
13 / 72
But..
14 / 72
The (basic) random graph model
a.k.a. ER model
15 / 72
Measuring the diameter in ER networks
16 / 72
ER networks have small diameter
As shown by the following simulation
17 / 72
Measuring the small-world phenomenon, II
18 / 72
Global clustering coefficient
3 × number of triangles
C=
number of connected triples
3×1
C= = 0.375
8
19 / 72
Local clustering coefficient
20 / 72
Local clustering coefficient example
I C1 = C2 = 1/1
I C3 = 1/6
I C4 = C5 = 0
I C = 15 (1 + 1 + 1/6) = 13/30 = 0.433
21 / 72
From [Newman, 2003]
22 / 72
ER networks do not show transitivity
23 / 72
ER networks do not show transitivity
24 / 72
So ER networks do not have high clustering, but..
25 / 72
The Watts-Strogatz model, I
From [Watts and Strogatz, 1998]
26 / 72
The Watts-Strogatz model, II
I Start with all n vertices arranged on a ring
I Each vertex has intially 4 connections to their closest
nodes
I mimics local or geographical connectivity
I With probability p, rewire each local connection to a
random vertex
I p = 0 high clustering, high diameter
I p = 1 low clustering, low diameter (ER model)
I What happens in between?
I As we increase p from 0 to 1
I Fast decrease of mean distance
I Slow decrease in clustering
27 / 72
The Watts-Strogatz model, III
28 / 72
Degree distribution
29 / 72
Scale-free networks
30 / 72
Random networks are not scale-free!
z k e−z
n k
fk = p (1 − p)(n−k) ≈
k k!
31 / 72
So ER networks are not scale-free, but..
32 / 72
Preferential attachment
33 / 72
Barabási-Albert model
From [Barabási and Albert, 1999]
I “Growth” model
I The model controls how a network grows over time
I Uses preferential attachment as a guide to grow the
network
I new nodes prefer to attach to well-connected nodes
I (Simplified) process:
I the process starts with some initial subgraph
I each new node comes in with m edges
I probability of connecting to existing node i is proportional to
i’s degree
I results in a power-law degree distribution with exponent
α=3
34 / 72
ER vs. BA
35 / 72
In summary..
1
clustering coefficient is higher than in random networks, but not as high
as for example in WS networks
36 / 72
Network Analysis, Part II
Today’s contents
1. Centrality
I Degree centrality
I Closeness centrality
I Betweenness centrality
2. Community finding algorithms
I Hierarchical clustering
I Agglomerative
I Girvan-Newman
I Modularity maximization: Louvain method
37 / 72
Centrality in Networks
38 / 72
Degree centrality
Power through connections
def
degree_centrality(i) = k(i)
39 / 72
Degree centrality
Power through connections
def
in_degree_centrality(i) = kin (i)
40 / 72
Degree centrality
Power through connections
def
out_degree_centrality(i) = kout (i)
41 / 72
Degree centrality
Power through connections
42 / 72
Closeness centrality
Power through proximity to others
P −1
def j6=i d(i, j) n−1
closeness_centrality(i) = =P
n−1 j6=i d(i, j)
43 / 72
Betweenness centrality
Power through brokerage
44 / 72
Betweenness centrality
Power through brokerage
Where
I gjk is the number of shortest-paths between j and k, and
I gjk (i) is the number of shortest-paths through i
Oftentimes it is normalized:
def betweenness_centrality(i)
norm_betweenness_centrality(i) = n−1
2
45 / 72
Betweenness centrality
Examples (non-normalized)
46 / 72
What is community structure?
47 / 72
Why is community structure important?
48 / 72
.. but don’t trust visual perception
it is best to use objective algorithms
49 / 72
Main idea
A community is dense in the inside but sparse w.r.t. the outside
Most common..
nr. of intra-cluster edges > nr. of inter-cluster edges
50 / 72
Some definitions
Let G = (V, E) be a network with |V | = n nodes and |E| = m
edges. Let C be a subset of nodes in the network (a “cluster” or
“community”) of size |C| = nc . Then
I intra-cluster density:
A community should have δint (C) > δ(G), where δ(G) is the
average edge density of the whole graph G, i.e.
nr. edges in G
δ(G) =
n(n − 1)/2
51 / 72
Most algorithms search for tradeoffs between large δint (C) and
small δext (C)
P
C δint (C) − δext (C) over all communities
I e.g. optimizing
C
Define further:
I mc = nr. edges within cluster C = |{(u, v)|u, v ∈ C}|
I fc = nr. edges in the frontier of C = |{(u, v)|u ∈ C, v 6∈ C}|
52 / 72
Community quality criteria
fc
I conductance: fraction of edges leaving the cluster 2mc +fc
I expansion: nr of edges per node leaving the cluster fc
nc
I internal density: a.k.a. “intra-cluster density” mc
nc (nc −1)/2
I cut ratio: a.k.a. “inter-cluster density” f c
nc (n−nc )
I modularity: difference between nr. of edges in C and the
expected nr. of edges E[mc ] of a random graph with the
same degree distribution
1
(mc − E[mc ])
4m
53 / 72
Methods we will cover
I Hierarchical clustering
I Agglomerative
I Divisive (Girvan-Newman algorithm)
I Modularity maximization algorithms
I Louvain method
54 / 72
Hierarchical clustering
From hairball to dendogram
55 / 72
Suitable if input network has hierarchical structure
56 / 72
Agglomerative hierarchical clustering [Newman, 2010]
Ingredients
I Similarity measure between nodes
I Similarity measure between sets of nodes
Pseudocode
1. Assign each node to its own cluster
2. Find the cluster pair with highest similarity and join them
together into a cluster
3. Compute new similarities between new joined cluster and
others
4. Go to step 2 until all nodes form a single cluster
57 / 72
Example
Data
80 ●
● ●
60
●
40
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
D. Blei Clustering 02 5 / 21
Example
iteration 001
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 002
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 003
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 004
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 005
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 006
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 007
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 008
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 009
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 010
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 011
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 012
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 013
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 014
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 015
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 016
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 017
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 018
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 019
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 020
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 021
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 022
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 023
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Example
iteration 024
80 ●
● ●
60
●
40
V2
●
●
20
● ●
● ●
● ●
● ●
●
0
●
●
●
●
● ●●
●
−20
0 20 40 60 80
V1
D. Blei Clustering 02 5 / 21
Similarity measures wij for nodes I
Let A be the adjacency matrix of the network, i.e. Aij = 1 if
(i, j) ∈ E and 0 otherwise.
I Jaccard index:
|Γ(i) ∩ Γ(j)|
wij =
|Γ(i) ∪ Γ(j)|
where:
P
I |Γ(i) ∩ Γ(j)| = k Aik Akj , and
nij =P
I ki = k Aik is the degree of node i
58 / 72
Similarity measures wij for nodes II
I Euclidean distance: (or rather Hamming distance since A
is binary) X
dij = (Aik − Ajk )2
k
2
From the equation xy = |x||y| cos θ
3
Uses the idea that the maximum value of dij is when there are no
common neighbors and then dij = ki + kj
59 / 72
Similarity measures for sets of nodes
60 / 72
Agglomerative hierarchical clustering on Zachary’s
network
Using average linkage
61 / 72
The Girvan-Newman algorithm
A divisive hierarchical algorithm [Girvan and Newman, 2002]
Edge betweenness
The betweenness of an edge is the nr. of shortest-paths in the
network that pass through that edge
62 / 72
The Girvan-Newman algorithm
Pseudocode
1. Compute betweenness for all edges in the network
2. Remove the edge with highest betweenness
3. Go to step 1 until no edges left
Result is a dendogram
63 / 72
Definition of modularity [Newman, 2010]
Using a null model
In particular:
1 X
Q= (Aij − Pij ) δ(Ci , Cj )
2m
ij
64 / 72
How do we compute Pij ?
Using the “configuration” null model
65 / 72
Properties of modularity
1 X ki kj
Q= Aij − δ(Ci , Cj )
2m 2m
ij
66 / 72
The Louvain method [Blondel et al., 2008]
Considered state-of-the-art
Pseudocode
1. Repeat until local optimum reached
1.1 Phase 1: partition network greedily using modularity
1.2 Phase 2: agglomerate found clusters into new nodes
67 / 72
The Louvain method
Phase 1: optimizing modularity
68 / 72
The Louvain method
Phase 2: agglomerating clusters to form new network
69 / 72
The Louvain method
Observations
70 / 72
References I
71 / 72
References II
Newman, M. E. (2003).
The structure and function of complex networks.
SIAM review, 45(2):167–256.
Watts, D. J. and Strogatz, S. H. (1998).
Collective dynamics of small-world networks.
nature, 393(6684):440–442.
72 / 72