44
Graph Partitioning II: Spectral Methods Seminar Social Media Mining University UC3M Date May 2017 Lecturer Carlos Castillo http://chato.cl/ Sources: Evimaria Terzi: “Clustering: graph cuts and spectral graph partitioning” [link] Daniel A. Spielman: “The Laplacian” [ link] Jure Leskovec: “Defining the graph laplacian” [ link]

Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

Graph Partitioning II: Spectral Methods

Seminar Social Media MiningUniversity UC3MDate May 2017Lecturer Carlos Castillo http://chato.cl/

Sources:● Evimaria Terzi: “Clustering: graph cuts and spectral graph

partitioning” [link]● Daniel A. Spielman: “The Laplacian” [link]● Jure Leskovec: “Defining the graph laplacian” [link]

Page 2: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

2

Graph projections

Page 3: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

3

Graphs are nice, but ...

● They describe only local relationships● We would like to understand a global structure● Our objective is transforming a graph into a

more familiar object: a cloud of points in Rk

R1

Page 4: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

4

Graphs are nice, but ...

● They describe only local relationships● We would like to understand a global structure● Our objective is transforming a graph into a

more familiar object: a cloud of points in Rk

R1

Distances should be somehow preserved

Page 5: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

5

Simple 3D graph projection

● Start a BFS from a random node, that has x=1, and nodes visited have ascending x

● Start a BFS from another random node, which has y=1, and nodes visited have ascending y

● Start a BFS from yet another node, which has z=1, and nodes visited have ascending z

● Project node n to position (xn, yn, zn)

How do you think this works in practice?

Page 6: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

6

Eigenvectors of adjacency matrix

Page 7: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

7

Adjacency matrix of G=(V,E)

● Matrix of size |V| x |V| such that:

● What is Ax? Think of x as a set of labels/values:

https://www.youtube.com/watch?v=YuKsZstrua4

Ax is a vector whose ith coordinate contains the sum of the x

j who are

in-neighbors of i

Page 8: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

8

Properties of adjacency matrix

● How many non-zeros are in every row of A?

https://www.youtube.com/watch?v=YuKsZstrua4

Page 9: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

9

Understanding the adjacency matrix

What is Ax? Think of x as a set of labels/values:

https://www.youtube.com/watch?v=YuKsZstrua4

Ax is a vector whose ith coordinate contains the sum of the x

j who are in-neighbors of i

Page 10: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

10

Spectral graph theory

● The study of the eigenvalues and eigenvectors of a graph matrix– Adjacency matrix

– Laplacian matrix (next)

● Suppose graph is d-regular (every node has degree d), what is the value of:

Page 11: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

11

An easy eigenvector of A

● Suppose graph is d-regular, i.e. all nodes have degree d:

● So [1, 1, …, 1]T is an eigenvector of eigenvalue d

Page 12: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

12

Disconnected graphs

● Suppose graph is disconnected (still regular)

● Then matrix has block structure:

S S'

Page 13: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

13

Disconnected graphs

● Suppose graph is disconnected (still regular)

S S'

Page 14: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

14

Disconnected graphs

● Suppose graph is disconnected (still regular)

S S'

Page 15: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

15

Disconnected graphs

● Suppose graph is disconnected (still regular)

● What happens if there are more than 2 connected components?

S S'

Page 16: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

16

In general

Disconnected graph Almost disconnected graph

Small “eigengap”

Page 17: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

17

Graph Laplacian

Page 18: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

18

Adjacency matrix

3

2

1

4

5

6

Page 19: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

19

Degree matrix

3

2

1

4

5

6

Page 20: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

20

Laplacian matrix

3

2

1

4

5

6

Page 21: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

21

Laplacian matrix L = D - A

● Symmetric● Eigenvalues non-negative and real● Eigenvectors real and orthogonal

Page 22: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

22

Constant vector is eigenvector of L

● The constant vector x=[1,1,...,1]T is again an eigenvector, but this time has eigenvalue 0

Page 23: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

23

If the graph is disconnected

● If there are two connected components, the same argument as for the adjacency matrix applies, and

● In general, the multiplicity of eigenvalue 0 is the number of connected components

Page 24: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

24

xTLx

Page 25: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

25

Important property of xTLx

Think of this quantity as the “stress” produced by the assignment of node labels x

Page 26: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

26

xTLx and graph cuts

● Suppose (S, S') is a cut of graph G● Set

0

01

1

1

Page 27: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

27

For symmetric matrices

● Important fact for symmetric matrices

https://en.wikipedia.org/wiki/Rayleigh_quotient

Page 28: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

28

Second eigenvector

● Orthogonal to the first one:● Normal:

Page 29: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

29

What does this mean?

0

Nodes should be placed at both sides of 0 because

Page 30: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

30

Example Graph 1

1

2

3

4

8

5

7

6

Page 31: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

31

Example Graph 1

1

2

3

4

8

5

7

6

Page 32: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

32

Example Graph 1, projected

1

2

3

4

8

5

7

6

0 0.247 0.383-0.383 -0.247

Page 33: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

33

Example Graph 1, communities

1

2

3

4

8

5

7

6

0 0.247 0.383-0.383 -0.247

S S'

Page 34: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

34

Example Graph 2

1

2

3

4

8

5

7

6

Page 35: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

35

Example Graph 3

1

2

3

4

8

5

7

6

Page 36: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

36

Example Graph 3, projected

0-0.057-0.246-0.210

-0.364 0.5510.139

1

2

3

4

8

5

7

6

Page 37: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

37

Example Graph 3, projectedhow to partition?

12

3

4

8

5

7

6

0-0.057-0.246-0.210

-0.364 0.5510.139

Page 38: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

38

Example Graph 3, projected

12

3

4

8

5

7

6

0-0.057-0.246-0.210

-0.364 0.5510.139

S S'

Page 39: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

39

A more complex graph

https://www.youtube.com/watch?v=jpTjj5PmcMM

Page 40: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

40

A graph with 4 “communities”

https://www.youtube.com/watch?v=jpTjj5PmcMM

Page 41: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

41

Other eigenvectors

Second eigenvector Third eigenvector

Value in second eigenvector

Val

ue in

thi

rd e

igen

vect

or

Page 42: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

42

Other eigenvectors

Second eigenvector Third eigenvector

Value in second eigenvector

Val

ue in

thi

rd e

igen

vect

or

Page 43: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

43

Interesting application: image segmentation [Shi & Malik 2000]

Transform into grid graph with edge weights proportional to pixel similarity

Page 44: Graph Partitioning II: Spectral Methods - Carlos …Spectral graph theory The study of the eigenvalues and eigenvectors of a graph matrix – Adjacency matrix – Laplacian matrix

44

Lots of examples!

http://www.cs.yale.edu/homes/spielman/sgta/SpectTut.pdf