Spectral Graph Theory (Basics)

68
CMU SCS Spectral Graph Theory (Basics) Charalampos (Babis) Tsourakakis CMU Charalampos E. Tsourakakis

description

Spectral Graph Theory (Basics). Charalampos (Babis) Tsourakakis CMU. Outline. Reminders Adjacency matrix Intuition behind eigenvectors: Bipartite Graphs Walks of length k Case Study: Triangles Laplacian Connected Components Intuition: Adjacency vs. Laplacian - PowerPoint PPT Presentation

Transcript of Spectral Graph Theory (Basics)

Page 1: Spectral Graph Theory (Basics)

CMU SCS

Spectral Graph Theory (Basics)

Charalampos (Babis) TsourakakisCMU

Charalampos E. Tsourakakis

Page 2: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 3: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 4: Spectral Graph Theory (Basics)

CMU SCS

Matrix Representations of G(V,E)Associate a matrix to a graph:• Adjacency matrix• Laplacian• Normalized Laplacian

Charalampos E. Tsourakakis

Main focus

Page 5: Spectral Graph Theory (Basics)

CMU SCS

Matrix as an operator

Charalampos E. Tsourakakis

e.g.,The image of the unit circle (sphere) under any mxn matrix is an ellipse (hyperellipse).

Page 6: Spectral Graph Theory (Basics)

CMU SCS

More Reminders• Let M be a symmetric nxn matrix.

Charalampos E. Tsourakakis

λ eigenvaluex eigenvector

Page 7: Spectral Graph Theory (Basics)

CMU SCS

More Reminders

1-Dimensional Invariant Subspaces

Charalampos E. Tsourakakis

y x

Ay

Ax (λ,u)

Diagonal:No rotation

Page 8: Spectral Graph Theory (Basics)

CMU SCS

Keep in mind!• For the rest of slides we are talking for

square nxn matrices

and unless noticed symmetric ones, i.e,

Charalampos E. Tsourakakis

nnn

n

mm

mmM

1

111

...

TMM

Page 9: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders

• Adjacency matrix– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Cheeger Inequality and Sparsest Cut:

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 10: Spectral Graph Theory (Basics)

CMU SCS

Adjacency matrix

Charalampos E. Tsourakakis

A=1

2 3

4

Undirected

Page 11: Spectral Graph Theory (Basics)

CMU SCS

Adjacency matrix

Charalampos E. Tsourakakis

A=1

2 3

410

0.3

2

4

Undirected Weighted

Page 12: Spectral Graph Theory (Basics)

CMU SCS

Adjacency matrix

Charalampos E. Tsourakakis

1

2 3

4

ObservationIf G is undirected,A = AT

Directed

Page 13: Spectral Graph Theory (Basics)

CMU SCS

Spectral TheoremTheorem [Spectral Theorem]• If M=MT, then

where

Charalampos E. Tsourakakis

Tnnn

T

Tn

T

n

n xxxxx

xxxM

111

11

1 ......

xi xj

λjλ i Reminder 1:

xi,xj orthogonal

Reminder 2:xi i-th principal axisλi length of i-th principal axis

0

0

Page 14: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders

• Adjacency matrix– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 15: Spectral Graph Theory (Basics)

CMU SCS

Bipartite Graphs

Charalampos E. Tsourakakis

Any graph with no cycles of odd length is bipartite

e.g., all trees are bipartite

Can we check if a graph is bipartitevia its spectrum?

Can we get the partition of the verticesin the two sets of nodes?

1 4

2 5

3 6

K3,3

Page 16: Spectral Graph Theory (Basics)

CMU SCS

Bipartite Graphs

Charalampos E. Tsourakakis

Adjacency matrix

where

Eigenvalues:

1 4

2 5

3 6

K3,3

Λ=[3,-3,0,0,0,0] Why λ1=-λ2=3?Recall: Ax=λx, (λ,x) eigenvalue-eigenvector

Page 17: Spectral Graph Theory (Basics)

CMU SCS

Bipartite Graphs

Charalampos E. Tsourakakis

1 4

2 5

3 6

11

1

1

1

1

1 4

5

6

1 1

1

1

233=3x1

Repeat same argument for the other nodes

Page 18: Spectral Graph Theory (Basics)

CMU SCS

Bipartite Graphs

Charalampos E. Tsourakakis

1 4

2 5

3 6

11

1

-1

-1

-1

1 4

5

6

-1 -1

-1

-1

-2-3-3=(-3)x1

Repeat same argument for the other nodes

Page 19: Spectral Graph Theory (Basics)

CMU SCS

Bipartite Graphs• Observation

u2 gives the partition of the nodes in the two sets S, V-S!

Charalampos E. Tsourakakis

S V-S

Theorem: λ2=-λ1 iff G bipartite. u2 gives the partition.

Question: Were we just “lucky”? Answer: No

Page 20: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders

• Adjacency matrix– Intuition behind eigenvectors: Bipartite Graphs

–Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 21: Spectral Graph Theory (Basics)

CMU SCS

Walks• A walk of length r in a directed graph:

where a node can be used more than once.• Closed walk when:

Charalampos E. Tsourakakis

1

2 3

4

1

2 3

4

Walk of length 2 2-1-4

Closed walk of length 32-1-3-2

Page 22: Spectral Graph Theory (Basics)

CMU SCS

Walks• Theorem

G(V,E) directed graph, adjacency matrix A. The number of walks from node u to node v in G with length r is (Ar)uv

• Proof Induction on k. See Doyle-Snell, p.165

Charalampos E. Tsourakakis

r

ijr

ijij aAaAaA .., , , 221

(i,j) (i, i1),(i1,j) (i,i1),..,(ir-1,j)

Page 23: Spectral Graph Theory (Basics)

CMU SCS

Walks

Charalampos E. Tsourakakis

1

2 3

4

1

2 3

4

1

2 3

4i=2, j=4 i=3, j=3

Page 24: Spectral Graph Theory (Basics)

CMU SCS

Walks

Charalampos E. Tsourakakis

1

2 3

4

1

3

4

2

Always 0,node 4 is a sink

Page 25: Spectral Graph Theory (Basics)

CMU SCS

Walks• Corollary A adjacency matrix of undirected G(V,E)

(no self loops), e edges and t triangles. Then the following hold:a) trace(A) = 0 b) trace(A2) = 2ec) trace(A3) = 6t

Charalampos E. Tsourakakis

11 2

1 2

3

Computing Ar is a bad idea:High memory requirements,expensive!

Page 26: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders

• Adjacency matrix– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k

–Case Study: Triangles• Laplacian

– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 27: Spectral Graph Theory (Basics)

CMU SCS

Why is Triangle Counting important?From the Graph Mining Perspective

• Clustering coefficient • Transitivity ratio

• Social Network Analysis fact:

“Friends of friends are friends”

A

CB

Other applications include:• Hidden Thematic Structure of the Web• Motif Detection, e.g., biological networks• Web Spam Detection

Charalampos E. Tsourakakis

Page 28: Spectral Graph Theory (Basics)

CMU SCS

Theorem

δ(G) = # triangles in graph G(V,E) = eigenvalues of adjacency

matrix A

||

1

3)(6V

iiG

||21 ... V

Theorem [EigenTriangle]

Charalampos E. Tsourakakis

Page 29: Spectral Graph Theory (Basics)

CMU SCS

Theorem

δ(i) = #Δs vertex i participates at. = i-th eigenvector = j-th entry of

2||

1

3)(2 ij

V

jjui

ijuiu

iu

Theorem[EigenTriangleLocal]

Charalampos E. Tsourakakis

Page 30: Spectral Graph Theory (Basics)

CMU SCS

• Almost symmetric around 0!

Political BlogsOmit!

Keep only 3!

3

Algorithm’s idea

Charalampos E. Tsourakakis

Page 31: Spectral Graph Theory (Basics)

CMU SCS

Observe the trend

Charalampos E. Tsourakakis

Results: Edges vs. Speedup

Page 32: Spectral Graph Theory (Basics)

CMU SCS

2-3 eigenvaluesalmost ideal results!

Charalampos E. Tsourakakis

#Eigenvalues vs. ϱ

Page 33: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 34: Spectral Graph Theory (Basics)

CMU SCS

Laplacian

Charalampos E. Tsourakakis

L= D-A=1

2 3

4

Diagonal matrix, dii=di

Page 35: Spectral Graph Theory (Basics)

CMU SCS

Weighted Laplacian

Charalampos E. Tsourakakis

1

2 3

410

0.3

2

4

Page 36: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian–Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 37: Spectral Graph Theory (Basics)

CMU SCS

Connected Components• Lemma

Let G be a graph with n vertices and c connected components. If L is the Laplacian of G, then rank(L)=n-c.

• Proof see p.279, Godsil-Royle

Charalampos E. Tsourakakis

Page 38: Spectral Graph Theory (Basics)

CMU SCS

Connected Components

Charalampos E. Tsourakakis

G(V,E)L=

eig(L)=

#zeros = #components

1 2 3

6

7 5

4

Page 39: Spectral Graph Theory (Basics)

CMU SCS

Connected Components

Charalampos E. Tsourakakis

G(V,E)L=

eig(L)=

#zeros = #components

1 2 3

6

7 5

40.01

Indicates a “good cut”

Page 40: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components

– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 41: Spectral Graph Theory (Basics)

CMU SCS

Adjacency vs. Laplacian Intuition

Charalampos E. Tsourakakis

V-SLet x be an indicator vector: S

SixSix

i

i

if ,0 if ,1

Consider now y=Lx k-th coordinate

Page 42: Spectral Graph Theory (Basics)

CMU SCS

Adjacency vs. Laplacian Intuition

Charalampos E. Tsourakakis

Consider now y=Lx

G30,0.5

S

k

Page 43: Spectral Graph Theory (Basics)

CMU SCS

Adjacency vs. Laplacian Intuition

Charalampos E. Tsourakakis

Consider now y=Lx

G30,0.5

S

k

Page 44: Spectral Graph Theory (Basics)

CMU SCS

Adjacency vs. Laplacian Intuition

Charalampos E. Tsourakakis

Consider now y=Lx

G30,0.5

S

kk

Laplacian: connectivity, Adjacency: #paths

Page 45: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 46: Spectral Graph Theory (Basics)

CMU SCS

Why Sparse Cuts?• Clustering, Community Detection

• And more: Telephone Network Design, VLSI layout, Sparse Gaussian Elimination, Parallel Computation

Charalampos E. Tsourakakis

1

2 3

4

5

6 7

8

9

cut

Page 47: Spectral Graph Theory (Basics)

CMU SCS

Quality of a Cut• Edge expansion/Isoperimetric number φ

Charalampos E. Tsourakakis

1

2 3

4

Page 48: Spectral Graph Theory (Basics)

CMU SCS

Quality of a Cut• Edge expansion/Isoperimetric number φ

Charalampos E. Tsourakakis

1

2 3

4

and thus

Page 49: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

SixSix

i

i

if ,0 if ,1

Characteristic Vector x

Then:

SV-S

Edges across cut

Page 50: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

1

2 3

4

5

6 7

8

9

cut

x=[1,1,1,1,0,0,0,0,0]T

S V-S

xTLx=2

Page 51: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

Ratio cut

Sparsest ratio cut

NP-hard

Relax the constraint:

Normalize: ?

Page 52: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

Sparsest ratio cut

NP-hard

Relax the constraint:

Normalize:λ2

because of the Courant-Fisher theorem (applied to L)

Page 53: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

Each ball 1 unit of mass

Eigenvector value

Node idxLx x1 xnOSCILLATE

Page 54: Spectral Graph Theory (Basics)

CMU SCS

Why λ2?

Charalampos E. Tsourakakis

Fundamental mode of vibration: “along” the separator

Page 55: Spectral Graph Theory (Basics)

CMU SCS

Cheeger Inequality

Charalampos E. Tsourakakis

• Step 1: Sort vertices in non-decreasing order according to their assigned by the second eigenvector value.

• Step 2: Decide where to cut. • Bisection• Best ratio cut Two common heuristics

Page 56: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition

• Example• Normalized Laplacian

Charalampos E. Tsourakakis

Page 57: Spectral Graph Theory (Basics)

CMU SCS

Example: Spectral Partitioning

Charalampos E. Tsourakakis

• K500 • K500

dumbbell graph

A = zeros(1000); A(1:500,1:500)=ones(500)-eye(500); A(501:1000,501:1000)= ones(500)-eye(500); myrandperm = randperm(1000);B = A(myrandperm,myrandperm);

In social network analysis, such clusters are called communities

Page 58: Spectral Graph Theory (Basics)

CMU SCS

Example: Spectral Partitioning• This is how adjacency matrix of B looks

Charalampos E. Tsourakakis

spy(B)

Page 59: Spectral Graph Theory (Basics)

CMU SCS

Example: Spectral Partitioning• This is how the 2nd eigenvector of B looks

like.

Charalampos E. Tsourakakis

L = diag(sum(B))-B;[u v] = eigs(L,2,'SM');plot(u(:,1),’x’)

Not so much information yet…

Page 60: Spectral Graph Theory (Basics)

CMU SCS

Example: Spectral Partitioning• This is how the 2nd eigenvector looks if we

sort it.

Charalampos E. Tsourakakis

[ign ind] = sort(u(:,1));plot(u(ind),'x')

But now we seethe two communities!

Page 61: Spectral Graph Theory (Basics)

CMU SCS

Example: Spectral Partitioning• This is how adjacency matrix of B looks

now

Charalampos E. Tsourakakis

spy(B(ind,ind))

Cut here!Community 1

Community 2Observation: Both heuristics are equivalent for the dumbell

Page 62: Spectral Graph Theory (Basics)

CMU SCS

Outline• Reminders • Adjacency matrix

– Intuition behind eigenvectors: Bipartite Graphs– Walks of length k– Case Study: Triangles

• Laplacian– Connected Components– Intuition: Adjacency vs. Laplacian– Sparsest Cut and Cheeger Inequality :

• Derivation, intuition• Example

• Normalized Laplacian

Charalampos E. Tsourakakis

Page 63: Spectral Graph Theory (Basics)

CMU SCS

Where does it go from here?• Normalized Laplacian

– Ng, Jordan, Weiss Spectral Clustering – Laplacian Eigenmaps for Manifold Learning– Computer Vision and many more

applications…

Charalampos E. Tsourakakis

Standard reference: Spectral Graph TheoryMonograph by Fan Chung Graham

Page 64: Spectral Graph Theory (Basics)

CMU SCS

Why Normalized Laplacian

Charalampos E. Tsourakakis

• K500 • K500

The onlyweightededge!

Cut hereφ=φ=

Cut here>

So, φ is not good here…

Page 65: Spectral Graph Theory (Basics)

CMU SCS

Why Normalized Laplacian

Charalampos E. Tsourakakis

• K500 • K500

The onlyweightededge!

Cut hereφ=φ=

Cut here>Optimize Cheeger

constant h(G),balanced cuts

where

Page 66: Spectral Graph Theory (Basics)

CMU SCS

Conclusions• Spectrum tells us a lot about the graph.• What to remember

– What is an eigenvector (f:Nodes Reals)– Adjacency: #Paths– Laplacian: Sparsest Cut and Intuition– Normalized Laplacian: Normalized cuts, tend to

avoid unbalanced cuts

Charalampos E. Tsourakakis

Page 67: Spectral Graph Theory (Basics)

CMU SCS

References• A list of references is on my web site, in the

KDD tutorial web page www.cs.cmu.edu/~ctsourak/

Charalampos E. Tsourakakis

Page 68: Spectral Graph Theory (Basics)

CMU SCS

Thank you!

Charalampos E. Tsourakakis