Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining...

83
Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto University visiting in Sapienza University of Rome fall 2016

Transcript of Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining...

Page 1: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Course : Data miningLecture : Spectral graph analysis

Aristides GionisDepartment of Computer Science

Aalto University

visiting in Sapienza University of Romefall 2016

Page 2: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral graph theory

Page 3: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral graph theoryobjective :

• view the adjacency (or related) matrix of a graph with alinear algebra lens

• identify connections between spectral properties of such amatrix and structural properties of the graph

• connectivity• bipartiteness• cuts• ...

• spectral properties = eigenvalues and eigenvectors

• in other words, what does the eigenvalues andeigenvectors of the adjacency (or related) matrixtell us about the graph?

Data mining — Spectral graph analysis 3

Page 4: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

background: eigenvalues and eigenvectors

• consider a real n × n matrix A, i.e., A ∈ Rn×n

• λ ∈ C is an eigenvalue of A

if there exists x ∈ Cn, x 6= 0

such thatA x = λx

• such a vector x is called eigenvector of λ

• alternatively,

(A− λI) x = 0 or det(A− λI) = 0

• it follows that A has n eigenvalues(possibly complex and possibly with multiplicity > 1)

Data mining — Spectral graph analysis 4

Page 5: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

background: eigenvalues and eigenvectors

• consider a real and symmetric n × n matrix A

(e.g., the adjacency matrix of an undirected graph)

• then

– all eigenvalues of A are real

– eigenvectors of different eigenvalues are orthogonali.e., if x1 an eigenvector of λ1

and x2 an eigenvector of λ2

then λ1 6= λ2 implies x1 ⊥ x2 (or xT1 x2 = 0)

• A is positive semi-definite if xT A x ≥ 0 for all x ∈ Rn

• a symmetric positive semi-definite real matrix hasreal and non negative eigenvalues

Data mining — Spectral graph analysis 5

Page 6: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

background: eigenvalues and eigenvectors• consider a real and symmetric n × n matrix A

• the eigenvalues λ1, . . . , λn of A can be ordered

λ1 ≤ . . . ≤ λn

• theorem [variational characterization of eigenvalues]

λn = maxx 6=0

xT A xxT x

λ1 = minx6=0

xT A xxT x

λ2 = minx6=0

xT x1=0

xT A xxT x

and “so on” for the other eigenvalues

• very useful way to think about eigenvalues

Data mining — Spectral graph analysis 6

Page 7: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

background: eigenvalues and eigenvectors

• the inverse holds, i.e.,

λ1 = minx 6=0

xT A xxT x

= minx6=0

∑ij Aijxixj∑

i x2i

• and if x is an optimal vector, then x is eigenvector of λ1

• similarly

λ2 = minx6=0

xT x1=0

xT A xxT x

= minx 6=0

xT x1=0

∑ij Aijxixj∑

i x2i

• and if x is an optimal vector, then x is eigenvector of λ2

Data mining — Spectral graph analysis 7

Page 8: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral graph analysis

• apply the eigenvalue characterization for graphs• question : which matrix to consider ?

– the adjacency matrix A of the graph– some matrix B so that xT B x is related to a structural– property of the graph

• consider G = (V ,E) an undirected and d-regular graph(regular graph is used wlog for simplicity of expositions)

• let A be the adjacency matrix of G:• define the laplacian matrix of G as

L = I − 1d

A or Lij =

1 if i = j−1/d if (i , j) ∈ E , i 6= j

0 if (i , j) 6∈ E , i 6= j

Data mining — Spectral graph analysis 8

Page 9: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral graph analysis• for the laplacian matrix L = I − 1

d A it is

xT L x =1d

∑(u,v)∈E

|xu − xv |2

• here, xu is the coordinate of the eigenvector xthat corresponds to vertex u ∈ V

• eigenvector x is seen as a one-dimensional embedding• i.e., mapping the vertices of the graph onto the real line

Tuesday, July 23, 13

Data mining — Spectral graph analysis 9

Page 10: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral graph analysis

high-level remark

• many graph problems can be modeled as mapping ofvertices to a discrete space

e.g., a cut is a mapping of vertices to {0,1}

• we aim to find a spectral formulation so that aneigenvector x is a relaxation of the discrete graph problem

i.e., optimizes the same objective but without theintegrality constraint

Data mining — Spectral graph analysis 10

Page 11: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the smallest eigenvalue

apply the eigenvalue characterization theorem for L

• what is λ1 ?

λ1 = minx 6=0

xT L xxT x

= minx 6=0

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

• observe that λ1 ≥ 0

• can it be λ1 = 0 ?

• yes : take x to be the constant vector

Data mining — Spectral graph analysis 11

Page 12: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the second smallest eigenvalue

apply the eigenvalue characterization theorem for L

• what is λ2 ?

λ2 = minx6=0

xT x1=0

xT L xxT x

= minx6=0

xT x1=0

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

• can it be λ2 = 0 ?

• λ2 = 0 if and only if the graph is disconnected

map the vertices of each connected component toa different constant

Data mining — Spectral graph analysis 12

Page 13: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the k -th smallest eigenvalue

• alternative characterization for λk

λk = minx6=0x∈S

S:k -dim

max

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

• λk = 0 if and only if the graph has at least k connectedcomponents

Data mining — Spectral graph analysis 13

Page 14: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the largest eigenvalue

• what about λn ?

λn = maxx6=0

xT L xxT x

= maxx 6=0

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

• consider a boolean version of this problem

• restrict mapping to {−1,+1}

λn ≥ maxx∈{−1,+1}n

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

Data mining — Spectral graph analysis 14

Page 15: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the largest eigenvalue• mapping of vertices to {−1,+1} corresponds to a cut S

then

λn ≥ maxx∈{−1,+1}n

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

= maxS⊆V

4 E(S,V \ S)

d n

= maxS⊆V

4 E(S,V \ S)

2 |E |

=2 maxcut(G)

|E |

• it follows that if G bipartite then λn ≥ 2(because if G bipartite exists S that cuts all edges)

Data mining — Spectral graph analysis 15

Page 16: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the largest eigenvalue

• on the other hand

λn = maxx6=0

∑(u,v)∈E |xu − xv |2

d∑

u∈V x2u

= maxx6=0

2d∑

u∈V x2u −

∑(u,v)∈E (xu + xv )2

d∑

u∈V x2u

= 2−minx6=0

∑(u,v)∈E (xu + xv )2

d∑

u∈V x2u

• first note that λn ≤ 2

• λn = 2 iff there is x s.t. xu = −xv for all (u, v) ∈ E

• λn = 2 iff G has a bipartite connected component

Data mining — Spectral graph analysis 16

Page 17: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

summary so far

eigenvalues and structural properties of G :

• λ2 = 0 iff G is disconnected

• λk = 0 iff G has at least k connected components

• λn = 2 iff G has a bipartite connected component

Data mining — Spectral graph analysis 17

Page 18: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

robustness

• how robust are these results ?

• for instance, what if λ2 = ε?

is the graph G almost disconnected ?

i.e., does it have small cuts ?

• or, what if λn = 2− ε?

does it have a component that is “close” to bipartite ?

Data mining — Spectral graph analysis 18

Page 19: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the second eigenvalue

λ2 = minx6=0

xT x1=0

∑(u,v)∈E (xu − xv )2

d∑

u∈V x2u

= minx6=0

xT x1=0

∑(u,v)∈E (xu − xv )2

dn∑

(u,v)∈V 2(xu − xv )2

where V 2 is the set of ordered pairs of vertices

why?

∑(u,v)∈V 2

(xu − xv )2 = n∑

v

x2v − 2

∑u,v

xuxv = n∑

v

x2v − 2

(∑u

xu

)2

and∑

u

xu = 0 since xT x1 = 0

Data mining — Spectral graph analysis 19

Page 20: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

the second eigenvalue

λ2 = minx6=0

xT x1=0

∑(u,v)∈E (xu − xv )2

dn∑

(u,v)∈V 2(xu − xv )2= min

x6=0xT x1=0

nd

E(u,v)∈E [(xu − xv )2]

E(u,v)∈V 2 [(xu − xv )2]

consider again discrete version of the problem, xu ∈ {0,1}

minx6={0,1}n

x non const

nd

E(u,v)∈E [(xu − xv )2]

E(u,v)∈V 2 [(xu − xv )2]= min

S⊆V

nd

E(S,S)

|S| |S|= usc(G)

usc(G) : uniform sparsest cut of G

Data mining — Spectral graph analysis 20

Page 21: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

uniform sparsest cut

• it can be shown that

λ2 ≤ usc(G) ≤√

8λ2

• the first inequality holds the by definition of relaxation

• second inequality is constructive :

• if x is an eigenvector of λ2

then there is some t ∈ V such that

the cut (S,V \ S) = ({u ∈ V | xu ≤ xt}, {u ∈ V | xu > xt})

has cost usc(S) ≤√

8λ2

Data mining — Spectral graph analysis 21

Page 22: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

conductance

• conductance : another measure for cuts• the conductance of a set S ⊆ V is defined as

φ(S) =E(S,V \ S)

d |S|

• expresses the probability to “move out” of S by followinga random edge from S

• we are interested in sets of small conductance• the conductance of the graph G is defined as

φ(G) = minS⊆V

0≤S≤|V |/2

φ(S)

Data mining — Spectral graph analysis 22

Page 23: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Cheeger’s inequality

• Cheeger’s inequality:

λ2

2≤ usc(G)

2≤ φ(G) ≤

√2λ2

⇒ conductance is small if and only if λ2 is small

• the two leftmost inequalities are “easy” to show

• the first follows by the definition of relaxation

• the second follows by

usc(S)

2=

n2d

E(S,V \ S)

|S||V \ S|≤ E(S,V \ S)

d |S|= φ(S)

since |V \ S| ≥ n/2

Data mining — Spectral graph analysis 23

Page 24: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Cheeger’s inequality

λ2

2≤ usc(G)

2≤ φ(G) ≤

√2λ2

• the rightmost inequality is the “difficult” to show

• proof sketch (three steps):1. consider a vector y ≥ 0– we can find a set S ⊆ {v ∈ V | yv > 0} such that

φ(S) ≤∑

(u,v)∈E |yu − yv |d∑

u∈V |yu|(no squares)

– pick random t ∈ [0,maxv yv ] and define S = {v | yv ≥ t}– then φ(S) ≤ r.h.s on expectation– thus, there is some t that the property holds

Data mining — Spectral graph analysis 24

Page 25: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Cheeger’s inequality

λ2

2≤ usc(G)

2≤ φ(G) ≤

√2λ2

• proof sketch (three steps):

2. given a vector x we can find another vector y such that∑(u,v)∈E |yu − yv |d∑

u∈V |yu|≤

√2

∑(u,v)∈E |xu − xv |2

d∑

u∈V |xu|2

and |{v | yv > 0}| ≤ n2

– proof of this claim is constructive; uses Cauchy-Schwarz

3. take x to be the eigenvector of λ2

Data mining — Spectral graph analysis 25

Page 26: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

generalization to non-regular graphs

• G = (V ,E) is undirected and non-regular• let du be the degree of vertex u• define D to be a diagonal matrix whose u-th diagonal

element is du

• the normalized laplacian matrix of G is defined

L = I − D−1/2 A D−1/2

or

Luv =

1 if u = v

−1/√

du dv if (u, v) ∈ E ,u 6= v0 if (u, v) 6∈ E ,u 6= v

Data mining — Spectral graph analysis 26

Page 27: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

generalization to non-regular graphs

• with the normalized laplacian

the eigenvalue expressions become (e.g., λ2)

λ2 = minx6=0

〈x,x1〉D=0

∑(u,v)∈E (xu − xv )2∑

u∈V dux2u

where we use weighted inner product

〈x,y〉D =∑u∈V

duxuyu

Data mining — Spectral graph analysis 27

Page 28: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

summary so far

eigenvalues and structural properties of G :

• λ2 = 0 iff G is disconnected

• λk = 0 iff G has at least k connected components

• λn = 2 iff G has a bipartite connected component

• small λ2 iff G is “almost” disconnected (small conductance)

Data mining — Spectral graph analysis 28

Page 29: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks

Page 30: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks

• consider random walk on the graph G by following edges

• from vertex i move to vertex j with prob. 1/di if (i , j) ∈ E

• p(t)i probability of being at vertex i at time t

• process is described by equation p(t+1) = p(t)P,where P = D−1 A is row-stochastic

• process converges to stationary distribution π = π P(under certain irreducibility conditions)

• for undirected and connected graphs

πi =di

2m(stationary distribution ∼ degree)

Data mining — Spectral graph analysis 30

Page 31: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks — useful concepts

• hitting time H(i , j): expected number of steps beforevisiting vertex j , starting from i

• commute time κ(i , j): expected number of steps beforevisiting j and i again, starting at i : κ(i , j) = H(i , j) + H(j , i)

• cover time: expected number of steps to reach every node

• mixing time τ(ε): a measure of how fast the random walkapproaches its stationary distribution

τ(ε) = min{t | d(t) ≤ ε}

where

d(t) = maxi||pt (i , ·)− π|| = max

i

∑j

|pt (i , j)− πj |

Data mining — Spectral graph analysis 31

Page 32: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks vs. spectral analysis

• consider the normalized laplacian L = I − D−1/2A D−1/2

L u = λu(I − D−1/2A D−1/2) u = λu

(D − A) u = λD uD u = A u + λD u

(1− λ) u = D−1A uµu = P u

• (λ,u) is an eigenvalue–eigenvector pair for L if and only if(1− λ,u) is an eigenvalue–eigenvector pair for P

• the eigenvector with smallest eigenvalue for L is theeigenvector with largest eigenvalue for P

Data mining — Spectral graph analysis 32

Page 33: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks vs. spectral analysis

• stochastic matrix P, describing the random walk

• eigenvalues: −1 < µn ≤ . . . ≤ µ2 < µ1 = 1

• spectral gap: γ∗ = 1− µ2 = λ2

• relaxation time: τ∗ = 1γ∗

• theorem: for an aperiodic, irreducible, and reversiblerandom walk, and any ε

(τ∗ − 1) log(

12ε

)≤ τ(ε) ≤ τ∗ log

(1

2ε√πmin

)

Data mining — Spectral graph analysis 33

Page 34: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random walks vs. spectral analysis

• intuition: fast mixing related to graph being an expander

small spectral gap⇔ large mixing time⇔ bottlenecks⇔

⇔ clusters⇔ low conductance⇔ small λ2

Data mining — Spectral graph analysis 34

Page 35: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

graph partitioning

Page 36: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

graph partitioning and community detection

motivation

• knowledge discovery

– partition the web into sets of related pages (web graph)

– find groups of scientists who collaborate with each other(co-authorship graph)

– find groups of related queries submitted in a search engine(query graph)

• performance

– partition the nodes of a large social network into differentmachines so that, to a large extent, friends are in the samemachine (social networks)

Data mining — Spectral graph analysis 36

Page 37: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

graph partitioning

(Zachary’s karate-club network, figure from [Newman and Girvan, 2004])

Data mining — Spectral graph analysis 37

Page 38: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

basic spectral-partition algorithm

1. form normalized Laplacian L′ = I − D−1/2A D−1/2

2. compute eigenvector x2 (Fielder vector)

3. order vertices according their coefficient value on x2

4. consider only sweeping cuts: splits that respect the order

5. take the sweeping cut S that minimizes φ(S)

theorem: the basic spectral-partition algorithm findsa cut S such that φ(S) ≤ 2

√φ(G)

proof: by Cheeger inequality

φ(S) ≤√

2 · λ2 ≤√

2 · 2 · φ(G)

Data mining — Spectral graph analysis 38

Page 39: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral partitioning rules

1. conductance: find the partition that minimizes φ(G)

2. bisection: split in two equal parts

3. sign: separate positive and negative values

4. gap: separate according to the largest gap

Tuesday, July 23, 13

Data mining — Spectral graph analysis 39

Page 40: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

other common spectral-partitioning algorithms

1. utilize more eigenvectors than just the Fielder vectoruse k eigenvectors

2. different versions of the Laplacian matrix

Data mining — Spectral graph analysis 40

Page 41: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

• ideal scenario: the graph consists of k disconnectedcomponents (perfect clusters)

• then: eigenvalue 0 of the Laplacian has multplicity kthe eigenspace of eigenvalue 0 is spanned by indicatorvectors of the graph components

Data mining — Spectral graph analysis 41

Page 42: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

1111

111

11

111

Tuesday, July 30, 13

Data mining — Spectral graph analysis 42

Page 43: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

1111

111

11

111

Tuesday, July 30, 13

Data mining — Spectral graph analysis 43

Page 44: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

1111

111

11

111

1

1

1

Tuesday, July 30, 13

Data mining — Spectral graph analysis 44

Page 45: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

• robustness under perturbations: if the graph has lesswell-separated components the previous structure holdsapproximately

• clustering of Euclidean points can be used to separatethe components

Data mining — Spectral graph analysis 45

Page 46: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

using k eigenvectors

Tuesday, July 30, 13

Data mining — Spectral graph analysis 46

Page 47: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

laplacian matrices

• normalized laplacian: L = I − D−1/2A D−1/2

• unormalized laplacian: Lu = D − A

• normalized “random-walk” laplacian: Lrw = I − D−1A

Data mining — Spectral graph analysis 47

Page 48: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

all laplacian matrices are related

• unormalized Laplacian: λ2 = min ||x||=1xT u1=0

∑(i,j)∈E (xi − xj)

2

• normalized Laplacian:

λ2 = min||x||=1xT u1=0

∑(i,j)∈E

(xi√di−

xj√dj

)2

• (λ,u) is an eigenvalue/vector of Lrw if and only if(λ,D1/2 u) is an eigenvalue/vector of L

• (λ,u) is an eigenvalue/vector of Lrw if and only if(λ,u) solve the generalized eigen-problem Lu u = λD u

Data mining — Spectral graph analysis 48

Page 49: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

algorithm 1: unormalized spectral clustering

input graph adjacency matrix A, number k

1. form diagonal matrix D

2. form unormalized Laplacian L = D − A

3. compute the first k eigenvectors u1, . . . ,uk of L

4. form matrix U ∈ Rn×k with columns u1, . . . ,uk

5. consider the i-th row of U as point yi ∈ Rk , i = 1, . . . ,n,

6. cluster the points {yi}i=1,...,n into clusters C1, . . . ,Ck

e.g., with k -means clustering

output clusters A1, . . . ,Ak with Ai = {j | yj ∈ Ci}

Data mining — Spectral graph analysis 49

Page 50: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

algorithm 2: normalized spectral clustering[Shi and Malik, 2000]

input graph adjacency matrix A, number k

1. form diagonal matrix D

2. form unormalized Laplacian L = D − A

3. compute the first k eigenvectors u1, . . . ,uk of thegeneralized eigenproblem L u = λD u (eigvctrs of Lrw)

4. form matrix U ∈ Rn×k with columns u1, . . . ,uk

5. consider the i-th row of U as point yi ∈ Rk , i = 1, . . . ,n,

6. cluster the points {yi}i=1,...,n into clusters C1, . . . ,Ck

e.g., with k -means clustering

output clusters A1, . . . ,Ak with Ai = {j | yj ∈ Ci}

Data mining — Spectral graph analysis 50

Page 51: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

algorithm 3: normalized spectral clustering[Ng et al., 2001]

input graph adjacency matrix A, number k

1. form diagonal matrix D

2. form normalized Laplacian L′ = I − D−1/2A D−1/2

3. compute the first k eigenvectors u1, . . . ,uk of L′

4. form matrix U ∈ Rn×k with columns u1, . . . ,uk

5. normalize U so that rows have norm 1

6. consider the i-th row of U as point yi ∈ Rk , i = 1, . . . ,n,

7. cluster the points {yi}i=1,...,n into clusters C1, . . . ,Ck

e.g., with k -means clustering

output clusters A1, . . . ,Ak with Ai = {j | yj ∈ Ci}

Data mining — Spectral graph analysis 51

Page 52: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

notes on the spectral algorithms

• quite similar except for using different Laplacians

• can be used to cluster any type of data, not just graphsform all-pairs similarity matrix and use as adjacency matrix

• computation of the first eigenvectors of sparse matricescan be done efficiently using the Lanczos method

Data mining — Spectral graph analysis 52

Page 53: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Zachary’s karate-club network

1

111213

14

18

2

20

22

3

324

5

6

7

8

9

10 34

15 3316 19

31

21

2324

26

28

30

25

27

29

17

Data mining — Spectral graph analysis 53

Page 54: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Zachary’s karate-club network

Thursday, August 1, 13

unormalized normalized normalizedLaplacian symmetric random walk

Laplacian LaplacianData mining — Spectral graph analysis 54

Page 55: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

Zachary’s karate-club network

1

111213

14

18

2

20

22

3

324

5

6

7

8

9

10 34

15 3316 19

31

21

2324

26

28

30

25

27

29

17

1

111213

14

18

2

20

22

3

324

5

6

7

8

9

10 34

15 3316 19

31

21

2324

26

28

30

25

27

29

17

1

111213

14

18

2

20

22

3

324

5

6

7

8

9

10 34

15 3316 19

31

21

2324

26

28

30

25

27

29

17

unormalized normalized normalizedLaplacian symmetric random walk

Laplacian Laplacian

Data mining — Spectral graph analysis 55

Page 56: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

which Laplacian to use?

[von Luxburg, 2007]

• when graph vertices have about the same degree alllaplacians are about the same

• for skewed degree distributions normalized laplacians tendto perform better

• normalized laplacians are associated with conductance,which is a good objective(conductance involves vol(S) rather than |S| and capturesbetter the community structure)

Data mining — Spectral graph analysis 56

Page 57: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

modularity

• cut measures (conductance) useful to find one component

• how to find many components ?

• related question: what is the optimal number of partitions ?

• modularity has been used to answer those questions[Newman and Girvan, 2004]

• originally developed to find the optimal number of partitionsin hierarchical graph partitioning

Data mining — Spectral graph analysis 57

Page 58: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

modularity• intuition: compare actual subgraph density with

expected subgraph density, if vertices were attachedregardless of community structure

Q =1

2m

∑ij

(Aij − Pij)δ(Ci ,Cj)

=1

2m

∑ij

(Aij −didj

2m)δ(Ci ,Cj)

=∑

c

[mc

2m−(

dc

2m

)2]

Pij = 2mpipj = 2m(di/2m)(dj/2m) = (didj/2m)

mc : edges within cluster cdc : total degree of cluster c

Data mining — Spectral graph analysis 58

Page 59: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

values of modularity

• 0 random structure; 1 strong community structure;[0.3..0.7]; typical good structure; can be negative, too

• Q measure is not monotone with k4

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5x 105

−0.1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

xth join

mod

ular

ity, Q

FIG. 1: The modularity Q over the course of the algorithm(the x axis shows the number of joins). Its maximum value isQ = 0.745, where the partition consists of 1684 communities.

in practical situations it is usually unnecessary to main-tain the separate max-heaps for each row. These heapsare used to find the largest element in a row quickly, buttheir maintenance takes a moderate amount of e!ort andthis e!ort is wasted if the largest element in a row doesnot change when two rows are amalgamated, which turnsout often to be the case. Thus we find that the followingsimpler implementation works quite well in realistic sit-uations: if the largest element of the kth row was "Qki

or "Qkj and is now reduced by Eq. (10b) or (10c), wesimply scan the kth row to find the new largest element.Although the worst-case running time of this approachhas an additional factor of n, the average-case runningtime is often better than that of the more sophisticatedalgorithm. It should be noted that the hierarchies gen-erated by these two versions of our algorithm will di!erslightly as a result of the di!erences in how ties are bro-ken for the maximum element in a row. However, we findthat in practice these di!erences do not cause significantdeviations in the modularity, the community size distri-bution, or the composition of the largest communities.

III. AMAZON.COM PURCHASING NETWORK

The output of the algorithm described above is pre-cisely the same as that of the slower hierarchical algo-rithm of [32]. The much improved speed of our algorithmhowever makes possible studies of very large networks forwhich previous methods were too slow to produce usefulresults. Here we give one example, the analysis of a co-purchasing or “recommender” network from the onlinevendor Amazon.com. Amazon sells a variety of products,particularly books and music, and as part of their websales operation they list for each item A the ten otheritems most frequently purchased by buyers of A. This

FIG. 2: A visualization of the community structure at max-imum modularity. Note that the some major communitieshave a large number of “satellite” communities connected onlyto them (top, lower left, lower right). Also, some pairs of ma-jor communities have sets of smaller communities that actas “bridges” between them (e.g., between the lower left andlower right, near the center).

information can be represented as a directed network inwhich vertices represent items and there is a edge fromitem A to another item B if B was frequently purchasedby buyers of A. In our study we have ignored the directednature of the network (as is common in community struc-ture calculations), assuming any link between two items,regardless of direction, to be an indication of their simi-larity. The network we study consists of items listed onthe Amazon web site in August 2003. We concentrate onthe largest component of the network, which has 409 687items and 2 464 630 edges.

The dendrogram for this calculation is of course toobig to draw, but Fig. 1 illustrates the modularity over thecourse of the algorithm as vertices are joined into largerand larger groups. The maximum value is Q = 0.745,which is high as calculations of this type go [21, 32]and indicates strong community structure in the network.The maximum occurs when there are 1684 communitieswith a mean size of 243 items each. Fig. 2 gives a visual-ization of the community structure, including the majorcommunities, smaller “satellite” communities connectedto them, and “bridge” communities that connect two ma-jor communities with each other.

Looking at the largest communities in the network, wefind that they tend to consist of items (books, music) insimilar genres or on similar topics. In Table I, we give in-formal descriptions of the ten largest communities, whichaccount for about 87% of the entire network. The remain-der is generally divided into small, densely connectedcommunities that represent highly specific co-purchasinghabits, e.g., major works of science fiction (162 items),music by John Cougar Mellencamp (17 items), and books

4

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5x 105

−0.1

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

xth join

mod

ular

ity, Q

FIG. 1: The modularity Q over the course of the algorithm(the x axis shows the number of joins). Its maximum value isQ = 0.745, where the partition consists of 1684 communities.

in practical situations it is usually unnecessary to main-tain the separate max-heaps for each row. These heapsare used to find the largest element in a row quickly, buttheir maintenance takes a moderate amount of e!ort andthis e!ort is wasted if the largest element in a row doesnot change when two rows are amalgamated, which turnsout often to be the case. Thus we find that the followingsimpler implementation works quite well in realistic sit-uations: if the largest element of the kth row was "Qki

or "Qkj and is now reduced by Eq. (10b) or (10c), wesimply scan the kth row to find the new largest element.Although the worst-case running time of this approachhas an additional factor of n, the average-case runningtime is often better than that of the more sophisticatedalgorithm. It should be noted that the hierarchies gen-erated by these two versions of our algorithm will di!erslightly as a result of the di!erences in how ties are bro-ken for the maximum element in a row. However, we findthat in practice these di!erences do not cause significantdeviations in the modularity, the community size distri-bution, or the composition of the largest communities.

III. AMAZON.COM PURCHASING NETWORK

The output of the algorithm described above is pre-cisely the same as that of the slower hierarchical algo-rithm of [32]. The much improved speed of our algorithmhowever makes possible studies of very large networks forwhich previous methods were too slow to produce usefulresults. Here we give one example, the analysis of a co-purchasing or “recommender” network from the onlinevendor Amazon.com. Amazon sells a variety of products,particularly books and music, and as part of their websales operation they list for each item A the ten otheritems most frequently purchased by buyers of A. This

FIG. 2: A visualization of the community structure at max-imum modularity. Note that the some major communitieshave a large number of “satellite” communities connected onlyto them (top, lower left, lower right). Also, some pairs of ma-jor communities have sets of smaller communities that actas “bridges” between them (e.g., between the lower left andlower right, near the center).

information can be represented as a directed network inwhich vertices represent items and there is a edge fromitem A to another item B if B was frequently purchasedby buyers of A. In our study we have ignored the directednature of the network (as is common in community struc-ture calculations), assuming any link between two items,regardless of direction, to be an indication of their simi-larity. The network we study consists of items listed onthe Amazon web site in August 2003. We concentrate onthe largest component of the network, which has 409 687items and 2 464 630 edges.

The dendrogram for this calculation is of course toobig to draw, but Fig. 1 illustrates the modularity over thecourse of the algorithm as vertices are joined into largerand larger groups. The maximum value is Q = 0.745,which is high as calculations of this type go [21, 32]and indicates strong community structure in the network.The maximum occurs when there are 1684 communitieswith a mean size of 243 items each. Fig. 2 gives a visual-ization of the community structure, including the majorcommunities, smaller “satellite” communities connectedto them, and “bridge” communities that connect two ma-jor communities with each other.

Looking at the largest communities in the network, wefind that they tend to consist of items (books, music) insimilar genres or on similar topics. In Table I, we give in-formal descriptions of the ten largest communities, whichaccount for about 87% of the entire network. The remain-der is generally divided into small, densely connectedcommunities that represent highly specific co-purchasinghabits, e.g., major works of science fiction (162 items),music by John Cougar Mellencamp (17 items), and books

(figures from [Clauset et al., 2004])

Data mining — Spectral graph analysis 59

Page 60: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

optimizing modularity

• problem: find the partitioning that optimizes modularity

• NP-hard problem [Brandes et al., 2006]

• top-down approaches [Newman and Girvan, 2004]

• spectral approaches [Smyth and White, 2005]

• mathematical-programming [Agarwal and Kempe, 2008]

Data mining — Spectral graph analysis 60

Page 61: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

top-down algorithms for optimizing modularity

[Newman and Girvan, 2004]

• a set of algorithms based on removing edges from thegraph, one at a time

• the graph gets progressively disconnected, creating ahierarchy of communities

3

22 14 4 13 8 3 10 23 19 16 15 21 9 31 33 29 25 26 32 24 27 30 34 281 6 17 7 5 11 12 20 2 18

FIG. 2: Dendrogram of the communities found by our algo-rithm in the “karate club” network of Zachary [5, 17]. Theshapes of the vertices represent the two groups into which theclub split as the result of an internal dispute.

not to continue using it—it appears to give the bestresults. For systems too large to make use of this ap-proach, however, our new algorithm gives useful com-munity structure information with comparatively littlee!ort.

We have applied our algorithm to a variety of real-world networks also. We have looked, for example, atthe “karate club” network studied in [5], which representsfriendships between 34 members of a club at a US univer-sity, as recorded over a two-year period by Zachary [17].During the course of the study, the club split into twogroups as a result of a dispute within the organization,and the members of one group left to start their ownclub. In Fig. 2 we show the dendrogram derived by feed-ing the friendship network into our algorithm. The peakmodularity is Q = 0.381 and corresponds to a split intotwo groups of 17, as shown in the figure. The shapes ofthe vertices represent the alignments of the club mem-bers following the split and, as we can see, the divisionfound by the algorithm corresponds almost perfectly tothese alignments; only one vertex, number 10, is classifiedwrongly. The GN algorithm performs similarly on thistask, but not better—it also finds the split but classifiesone vertex wrongly (although a di!erent one, vertex 3).In other tests, we find that our algorithm also success-fully detects the main two-way division of the dolphinsocial network of Lusseau [6, 18], and the division be-tween black and white musicians in the jazz network ofGleiser and Danon [11].

As a demonstration of how our algorithm can some-times miss some of the structure in a network, we takeanother example from Ref. 5, a network representingthe schedule of games between American college foot-ball teams in a single season. Because the teams are di-vided into groups or “conferences,” with intra-conferencegames being more frequent than inter-conference games,we have a reasonable idea ahead of time about what com-munities our algorithm should find. The dendrogramgenerated by the algorithm is shown in Fig. 3, and hasan optimal modularity of Q = 0.546, which is a little shy

of the value 0.601 for the best split reported in [5]. Asthe dendrogram reveals, the algorithm finds six commu-nities. Some of them correspond to single conferences,but most correspond to two or more. The GN algorithm,by contrast, finds all eleven conferences, as well as accu-rately identifying independent teams that belong to noconference. Nonetheless, it is clear that the new algo-rithm is quite capable of picking out useful communitystructure from the network, and of course it is much thefaster algorithm. On the author’s personal computer thealgorithm ran to completion in an unmeasureably smalltime—less than a hundredth of a second. The algorithmof Girvan and Newman took a little over a second.

A time di!erence of this magnitude will not presenta big problem in most practical situations, but perfor-mance rapidly becomes an issue when we look at largernetworks; we expect the ratio of running times to in-crease with the number of vertices. Thus, for example,in applying our algorithm to the 1275-node network ofjazz musician collaborations mentioned above, we foundthat it runs to completion in about one second of CPUtime. The GN algorithm by contrast takes more thanthree hours to reach very similar results.

As an example of an analysis made possible by thespeed of the new algorithm, we have looked at a networkof collaborations between physicists as documented bypapers posted on the widely-used Physics E-print Archiveat arxiv.org. The network is an updated version of theone described in Ref. 13, in which scientists are consid-ered connected if they have coauthored one or more pa-pers posted on the archive. We analyze only the largestcomponent of the network, which contains n = 56 276 sci-entists in all branches of physics covered by the archive.Since two vertices that are unconnected by any path arenever put in the same community by our algorithm, thesmall fraction of vertices that are not part of the largestcomponent can safely be assumed to be in separate com-munities in the sense of our algorithm. Our algorithmtakes 42 minutes to find the full community structure.Our best estimates indicate that the GN algorithm wouldtake somewhere between three and five years to completeits version of the same calculation.

The analysis reveals that the network in question con-sists of about 600 communities, with a high peak modu-larity of Q = 0.713, indicating strong community struc-ture in the physics world. Four of the communities foundare large, containing between them 77% of all the ver-tices, while the others are small—see Fig. 4, left panel.The four large communities correspond closely to subjectsubareas: one to astrophysics, one to high-energy physics,and two to condensed matter physics. Thus there ap-pears to be a strong correlation between the structurefound by our algorithm and the community divisions per-ceived by human observers. It is precisely correlationof this kind that makes community structure analysis auseful tool in understanding the behavior of networkedsystems.

We can repeat the analysis with any of the subcom-

(figure from [Newman, 2004])

Data mining — Spectral graph analysis 61

Page 62: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

top-down algorithms

• select edge to remove based on “betweenness”

three definitions• shortest-path betweenness: number of shortest paths that

the edge belongs to• random-walk betweenness: expected number of paths for

a random walk from u to v• current-flow betweenness: resistance derived from

considering the graph as an electric circuit

Data mining — Spectral graph analysis 62

Page 63: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

top-down algorithms

general scheme

1. TOP-DOWN

2. compute betweenness value of all edges

3. remove the edge with the highest betweenness

4. recompute betweenness value of all remaining edges

5. repeat until no edges left

Data mining — Spectral graph analysis 63

Page 64: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

shortest-path betweenness

• how to compute shortest-path betweenness?• BFS from each vertex• leads to O(mn) for all edge betweenness• OK if there are single paths to all vertices

s

42

1 1 2

1

1/2

1/2

1/2

1/2

s

Data mining — Spectral graph analysis 64

Page 65: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

shortest-path betweenness

s

overall time of TOPDOWN is O(m2n)

Data mining — Spectral graph analysis 65

Page 66: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

shortest-path betweenness

1

1

11

2

3

s

overall time of TOPDOWN is O(m2n)

Data mining — Spectral graph analysis 66

Page 67: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

shortest-path betweenness

1

1

11

2

31/32/3 1

7/35/6

5/6

11/6 25/6

s

overall time of TOPDOWN is O(m2n)

Data mining — Spectral graph analysis 67

Page 68: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random-walk betweenness

• stochastic matrix of random walk is P = D−1 A• s is the vector with 1 at position s and 0 elsewhere• probability distribution over vertices at time n is s Pn

• expected number of visits at each vertex given by∑n

s Pn = s (1− P)−1

cu = E[# times passing from u to v ] =[s (1− P)−1

]u

1du

c = s (1− P)−1 D−1 = s (D − A)−1

• define random-walk betweenness at (u, v) as |cu − cv |

Data mining — Spectral graph analysis 68

Page 69: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

random-walk betweenness

• random-walk betweenness at (u, v) is |cu − cv |with c = s (D − A)−1

• one matrix inversion O(n3)

• in total O(n3m) time with recalculation• not scalable

• current-flow betweenness is equivalent!

[Newman and Girvan, 2004] recommend shortest-pathbetweenness

Data mining — Spectral graph analysis 69

Page 70: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

other modularity-based algorithms

spectral approach [Smyth and White, 2005]

Q =k∑

c=1

[mc

2m−(

dc

2m

)2]∝

k∑c=1

[(2m) mc − d2

c

]

=k∑

c=1

(2m)n∑

i,j=1

wijxicxjc −

(n∑

i=1

dixic

)2

=k∑

c=1

[(2m) xT

c W xc − xTc D xc

]= tr(X T (W ′ − D) X )

where X = [x1 . . . xk ] = [xic] point-cluster assignment matrix

Data mining — Spectral graph analysis 70

Page 71: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral-based modularity optimization

maximize tr(X T (W ′ − D) X )

such that X is an assignment matrix

solution:LQ X = XΛ

where LQ = W ′ − D, Q-Laplacian

• standard eigenvalue problem• but solution is fractional, we want integral• treat rows of X as vectors and cluster graph vertices using

k -means• [Smyth and White, 2005] propose two algorithms, based

on this idea

Data mining — Spectral graph analysis 71

Page 72: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

spectral-based modularity optimization

spectral algorithms perform almost as good as theagglomerative, but they are more efficient

organism

attribute

social relation

play

break

drive

catch

device

change

activity

folly

music

profession

learned profession

architecture

law

politics

medicine

theology

exercisecontrol

regulation lock

reproduction

judgment

estimate

discipline

training

representation

taxonomy

abstinenceinhibition

suppression

social control

government

restraint

collar

damperconfinement

imprisonment

containment

restriction

punishment

stick

detention

opinion

segregation

airbrake

band

body

brake

building

communication system

cosmography

dress

engineering

exhaust

fastener

infrastructure

instrumentality

memory

network

room settlespike

study

system

train

water system

trait

personality

character

nature

thoughtfulness

self−discipline

continence

wisdom

age

sound

majority

better

live body

body part

articulatory systemdigestive system

endocrine system

immune system

reticuloendothelial system

system

muscular structuremusculoskeletal system

nervous system system

system

reproductive systemurogenital system

respiratory systemsensory system

vascular system

skeletal systemlogicaccounting

explanation

content

gravitation

action

hypostasis

belief

doctrine

philosophy

theory

functionalism

gravitation

scientific theory

economic theory

major

frontier

knowledge domain

scientific knowledge

science

natural science

mathematics

pure mathematicsapplied mathematics

statistics

life science

medical science

agronomy

agrobiology

agrology

cognitive neuroscience

chemistry

physics

nuclear physics

atomic theory

wave theorycorpuscular theory

kinetic theoryrelativity

quantum theory

uncertainty principle

germ theory

information theory

evolution

inheritance earth science

architectonics

metallurgy

computer science

artificial intelligence

machine translation

nutrition

psychology

experimental psychology

cognitive psychologysocial psychology

information science

cognitive science

social science

anthropologyeconomics

game theory

sociology

systematicshumanistic disciplinehistory

structuralism

computational linguistics

etymology

historical linguistics

linguistics

grammar

syntax

lexicologysemantics

sound law

synchronic linguistics military science

judiciary

hierarchy

social organization

growthanabolism bodily process

catabolism

gastrulation

Krebs cycle

metabolism

natural process

organic process

oxidative phosphorylation

parturitiontransduction

transpiration

prime

make

grow

suspend

build up

develop

redevelop

prepare

build

mature

evolve

work out

elaborate

expand

happen

translate

complicate

socialize

cram

modernize

explicate

generateoriginate

create

cultivate

mortify

solarize

educate

amercepunish

great

leading/p/

scientific

technological

unscientific

pseudoscientific

Figure 2: Clusters for WordNet data, k = 12 (best viewed in color).

0 10 20 30 40 500

0.1

0.2

0.3

0.4

0.5

0.6

0.7

K

Q

normalized Qstandard Qtransition matrix

Figure 3: Q versus k for the WordNet data.

Ruppin E,Horn D,Shadmehr R

Morgan N,Rumelhart D,Keeler JBower J,Abu-Mostafa Y,Hasselmo M

Goodman R,Moore A,Atkeson C

Coolen A,Saad D,Hertz J

Alspector J,Meir R,Allen R

Barto A,Singh S,Sutton R

Bengio Y,Denker J,LeCun Y

Tresp V,Tsitsiklis J,Atlas L

Sejnowski T,Hinton G,Dayan P

Mozer M,Lee S,Jang J

Platt J,Smola A,Scholkopf B

Waibel A,Amari S,Tebelskis J

Moody J,Mjolsness E,Leen T

Tishby N,Warmuth M,Singer Y

Cauwenberghs G,Andreou A,Edwards R

Robinson A,de-Freitas J,Niranjan M

Wiles J,Pollack J,Blair A

Koch C,Bialek W,DeWeerth S

Eeckman F,Buhmann J,Baird B

Giles C,Cottrell G,Lippmann RBaldi P,Venkatesh S,Psaltis D

Thrun S,Baluja S,Merzenich M

Seung H,Lee D,vanHemmen J

Jordan M,Ghahramani Z,Saul L

Touretzky D,Spence C,Pearson J

Geiger D,Poggio T,Girosi F

Maass W,Zador A,Sontag E

Pentland A,Darrell T,Jebara T

Kawato M,Principe J,Vatikiotis-Bateson E

Nadal J,Personnaz L,Dreyfus G

Figure 6: Clustering for NIPS co-authorship data, k = 31 (best viewed in color).

0 20 40 60 80 1000

0.2

0.4

0.6

0.8

1

KQ

Spectral−1Spectral−2Newman

Figure 7: Q versus k for NIPS coauthorship data.

[Smyth and White, 2005]

Data mining — Spectral graph analysis 72

Page 73: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

other modularity-based algorithms

mathematical programming [Agarwal and Kempe, 2008]

Q ∝n∑

i,j=1

Bij(1− xij)

where

xij =

{0 if i and j get assigned to the same cluster1 otherwise

it should be

xik ≤ xij + xjk for all vertices i , j , k

solve the integer program with triangle inequality constraints

Data mining — Spectral graph analysis 73

Page 74: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

mathematical-programming approachfor modularity optimization

[Agarwal and Kempe, 2008]

• integer program is NP-hard• relax integrality constraints

replace xij ∈ {0,1} with 0 ≤ xij ≤ 1• corresponding linear program can be solved in polynomial

time• solve linear program and round the fractional solution• place in the same cluster vertices i and j if xij is small

(pivot algorithm [Ailon et al., 2008])

Data mining — Spectral graph analysis 74

Page 75: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

ResultsGaurav Agarwal, David Kempe: Modularity-Maximizing Graph Communities via Mathematical Programming 9

Network size n GN DA EIG VP LP UBKARATE 34 0.401 0.419 0.419 0.420 0.420 0.420DOLPH 62 0.520 - - 0.526 0.529 0.531MIS 76 0.540 - - 0.560 0.560 0.561BOOKS 105 - - 0.526 0.527 0.527 0.528BALL 115 0.601 - - 0.605 0.605 0.606JAZZ 198 0.405 0.445 0.442 0.445 0.445 0.446COLL 235 0.720 - - 0.803 0.803 0.805META 453 0.403 0.434 0.435 0.450 - -EMAIL 1133 0.532 0.574 0.572 0.579 - -

Table 2. The modularity obtained by many of the previouslypublished methods and by the methods introduced in this pa-per, along with the upper bound.

any clustering; it seems quite plausible that the clusteringproduced by our algorithms is in fact optimal.

Since the running time of the LP and VP roundingalgorithms is significantly larger than for past heuristics,we also compare them with Simulated Annealing [49], aslower and more exhaustive algorithm. For this compari-son, we report both the modularity values obtained andthe running time of the di!erent algorithms. For SimulatedAnnealing, we chose three cooling schedules, 0.999, 0.99and 0.95. As mentioned above, all the running times weremeasured on a Linux-based Intel PC with two 3.2GHz pro-cessors and 2GB of RAM. For readability, we omit fromthe table below the modularity obtained by the LP algo-rithm, which is given in Table 2 and identical to the onefor the VP algorithm, except for the DOLPH network.We also omit the results for the cooling schedule of 0.99.Both the modularity obtained and the running time werebetween the ones for 0.999 and 0.95.

Network SA (0.999) SA (0.95) VP LPKARATE 0.420 [0:12] 0.420 [0:02] 0.420 [0:06] [0:02]DOLPH 0.528 [2:55] 0.527 [0:05] 0.526 [0:09] [0:04]MIS 0.560 [4:22] 0.556 [0:10] 0.560 [0:11] [0:04]BOOKS 0.527 [13:02] 0.527 [0:26] 0.527 [0:12] [0:28]BALL 0.605 [4:10] 0.604 [0:06] 0.605 [0:23] [0:18]JAZZ 0.445 [58:05] 0.445 [2:50] 0.445 [0:24] [29:22]COLL 0.799 [25] 0.799 [0:32] 0.803 [1:45] [32:21]META 0.450 [146] 0.445 [9:02] 0.450 [1:30] -EMAIL 0.579 [1143] 0.575 [40:12] 0.579 [15:08] -

Table 3. The modularity and running times (in minutes andseconds) of our algorithms as well as Simulated Annealing withdi!erent cooling schedules.

Notice that the results obtained by our algorithm areonly inferior for one data set to Simulated Annealing withthe slowest cooling schedule. For all other data sets andschedules, our algorithms match or outperform SimulatedAnnealing, even while taking comparable or less time thanthe faster cooling schedules.

5 Conclusion

We have shown that the technique of rounding solutionsto fractional mathematical programs yields high-qualitymodularity maximizing communities, while also providinga useful upper bound on the best possible modularity. Thedrawback of our algorithms is their resource requirement.Due to !(n3) constraints in the LP, and !(n2) variablesin the VP, the algorithms currently do not scale beyondabout 300 resp. 4000 nodes. Thus, a central goal for fu-ture work would be to improve the running time withoutsacrificing solution quality. An ideal outcome would be apurely combinatorial algorithm avoiding the explicit solu-tion to the mathematical programs, but yielding the sameperformance.

Secondly, while our algorithms perform very well on allnetworks we considered, they do not come with a prioriguarantees on their performance. Heuristics with such per-formance guarantees are called approximation algorithms[29], and are desirable because they give the user a hardguarantee on the solution quality, even for pathologicalnetworks. Since the algorithms of Charikar et al. and Goe-mans and Williamson on which our approaches are baseddo have provable approximation guarantees, one wouldhope that similar guarantees could be attained for modu-larity maximization. However, this does not hold for theparticular algorithms we use, due to the shift of the ob-jective function by a constant. Obtaining approximationalgorithms for modularity maximization thus remains achallenging direction for future work.

Acknowledgments

We would like to thank Aaron Clauset, Cris Moore, MarkNewman and Ashish Vaswani for useful discussions andadvice, Fernando Ordonez for providing computational re-sources, and Roger Guimera for sharing his implementa-tion of Simulated Annealing. We also thank several anony-mous reviewers for helpful feedback on previous versionsof the paper. David Kempe has been supported in part byNSF CAREER Award 0545855.

References

1. M. Newman, A. Barabasi, and D. Watts. The Structureand Dynamics of Networks. Princeton University Press,2006.

2. J. Scott. Social Network Analysis: A Handbook. Sage Pub-lications, second edition, 2000.

3. S. Wasserman and K. Faust. Social Network Analysis.Cambridge University Press, 1994.

4. J. Kleinberg, R. Kumar, P. Raghavan, S. Rajagopalan, andA. Tomkins. The web as a graph: Measurements, modelsand methods. In International Conference on Combina-torics and Computing, 1999.

5. R. Guimera and L. Amaral. Functional cartography ofcomplex metabolic networks. Nature, 433:895–900, 2005.

(table from [Agarwal and Kempe, 2008])

Data mining — Spectral graph analysis 75

Page 76: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

need for scalable algorithms

• spectral, agglomerative, LP-based algorithms

• not scalable to very large graphs

• handle datasets with billions of vertices and edges• facebook: ∼ 1 billion users with avg degree 130• twitter: ≥ 1.5 billion social relations• google: web graph more than a trillion edges (2011)

• design algorithms for streaming scenarios• real-time story identification using twitter posts• election trends, twitter as election barometer

Data mining — Spectral graph analysis 76

Page 77: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

graph partitioning

• graph partitioning is a way to split the graph verticesin multiple machines

• graph partitioning objectives guarantee low communicationoverhead among different machines

• additionally balanced partitioning is desirable

G = (V, E)

Sunday, August 4, 13

• each partition contains ≈ n/k vertices

Data mining — Spectral graph analysis 77

Page 78: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

off-line k -way graph partitioning

METIS algorithm [Karypis and Kumar, 1998]

• popular family of algorithms and software

• multilevel algorithm

• coarsening phase in which the size of the graph issuccessively decreased

• followed by bisection (based on spectral)

• followed by uncoarsening phase in which the bisection issuccessively refined and projected to larger graphs

Data mining — Spectral graph analysis 78

Page 79: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

summary

• spectral analysis reveals structural properties of a graph

• used for graph partitioning, but also for other problems

• well-studied area, many results and techniques

• for graph partitioning and community detection manyother methods are available

Data mining — Spectral graph analysis 79

Page 80: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

acknowledgements

Luca Trevisan

Data mining — Spectral graph analysis 80

Page 81: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

references

Agarwal, G. and Kempe, D. (2008).Modularity-maximizing graph communities via mathematicalprogramming.The European Physical Journal B, 66(3).

Ailon, N., Charikar, M., and Newman, A. (2008).Aggregating inconsistent information: ranking and clustering.Journal of the ACM (JACM), 55(5).

Brandes, U., Delling, D., Gaertler, M., Görke, R., Höfer, M., Nikoloski, Z.,and Wagner, D. (2006).Maximizing modularity is hard.Technical report, DELIS – Dynamically Evolving, Large-ScaleInformation Systems.

Clauset, A., Newman, M., and Moore, C. (2004).Finding community structure in very large networks.arXiv.org.

Data mining — Spectral graph analysis 81

Page 82: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

references (cont.)Karypis, G. and Kumar, V. (1998).A fast and high quality multilevel scheme for partitioning irregulargraphs.SIAM J. Sci. Comput., 20(1):359–392.

Newman, M. (2004).Fast algorithm for detecting community structure in networks.Physical review E, 69(6).

Newman, M. E. J. and Girvan, M. (2004).Finding and evaluating community structure in networks.Physical Review E, 69(2).

Ng, A., Jordan, M., and Weiss, Y. (2001).On spectral clustering: Analysis and an algorithm.NIPS.

Shi, J. and Malik, J. (2000).Normalized cuts and image segmentation.IEEE transactions on Pattern Analysis and Machine Intelligence, 22(8).

Data mining — Spectral graph analysis 82

Page 83: Course : Data miningaris.me/contents/teaching/data-mining-2016/slides/...Course : Data mining Lecture : Spectral graph analysis Aristides Gionis Department of Computer Science Aalto

references (cont.)

Smyth, P. and White, S. (2005).A spectral clustering approach to finding communities in graphs.SDM.

von Luxburg, U. (2007).A Tutorial on Spectral Clustering.arXiv.org.

Data mining — Spectral graph analysis 83