Paths and Random Walks on Graphs Based on materials by - - PowerPoint PPT Presentation

paths and random walks on graphs
SMART_READER_LITE
LIVE PREVIEW

Paths and Random Walks on Graphs Based on materials by - - PowerPoint PPT Presentation

Paths and Random Walks on Graphs Based on materials by Lala Adamic and Purnamrita Sarkar 1 Mo#va#on: Link predic#on in social networks 2 Mo#va#on:


slide-1
SLIDE 1

Paths ¡and ¡ ¡ Random ¡Walks ¡on ¡Graphs ¡

Based ¡on ¡materials ¡by ¡Lala ¡Adamic ¡and ¡ Purnamrita ¡Sarkar ¡

1

slide-2
SLIDE 2

Mo#va#on: ¡Link ¡predic#on ¡in ¡social ¡networks ¡

2

slide-3
SLIDE 3

Mo#va#on: ¡Basis ¡for ¡recommenda#on ¡

3

slide-4
SLIDE 4

Mo#va#on: ¡Personalized ¡search ¡

4

slide-5
SLIDE 5

Why ¡graphs? ¡

  • The ¡underlying ¡data ¡is ¡naturally ¡a ¡graph ¡

– Papers ¡linked ¡by ¡cita>on ¡ – Authors ¡linked ¡by ¡co-­‑authorship ¡ – Bipar>te ¡graph ¡of ¡customers ¡and ¡products ¡ – Web-­‑graph ¡ ¡ – Friendship ¡networks: ¡who ¡knows ¡whom ¡

5

slide-6
SLIDE 6

What ¡are ¡we ¡looking ¡for ¡

  • Rank ¡nodes ¡for ¡a ¡par>cular ¡query ¡

– Top ¡k ¡matches ¡for ¡“Random ¡Walks” ¡from ¡Citeseer ¡ – Who ¡are ¡the ¡most ¡likely ¡co-­‑authors ¡of ¡“Manuel ¡Blum”. ¡ – Top ¡k ¡book ¡recommenda>ons ¡ ¡for ¡Jen ¡from ¡Amazon ¡ – Top ¡k ¡websites ¡matching ¡“Sound ¡of ¡Music” ¡ – Top ¡k ¡friend ¡recommenda>ons ¡for ¡Bob ¡when ¡he ¡joins ¡ “Facebook” ¡

6

slide-7
SLIDE 7

History: Graph theory

n Euler’s Seven Bridges of Königsberg – one of the first problems

in graph theory

n Is there a route that crosses each bridge only once and returns to

the starting point?

Source: http://en.wikipedia.org/wiki/Seven_Bridges_of_Königsberg Image 1 – GNU v1.2: Bogdan, Wikipedia; http://commons.wikimedia.org/wiki/Commons:GNU_Free_Documentation_License Image 2 – GNU v1.2: Booyabazooka, Wikipedia; http://commons.wikimedia.org/wiki/Commons:GNU_Free_Documentation_License Image 3 – GNU v1.2: Riojajar, Wikipedia; http://commons.wikimedia.org/wiki/Commons:GNU_Free_Documentation_License

slide-8
SLIDE 8

Eulerian paths

n If starting point and end point are the same:

n only possible if no nodes have an odd degree

n each path must visit and leave each shore

n If don’t need to return to starting point

n can have 0 or 2 nodes with an odd degree

  • Eulerian path: traverse each
  • edge exactly once
  • Hamiltonian path: visit
  • each vertex exactly once
slide-9
SLIDE 9

Node degree from matrix values

n Outdegree =

1 1 1 1 1 1 1

  • A =

= n j ij

A

1

  • example: outdegree for node 3 is 2, which

we obtain by summing the number of non- zero entries in the 3rd row n Indegree =

1 1 1 1 1 1 1

  • A =

= n i ij

A

1

  • example: the indegree for node 3 is 1,

which we obtain by summing the number of non-zero entries in the 3rd column

= n i i

A

1 3

= n j j

A

1 3

  • 1
  • 2
  • 3
  • 4
  • 5
slide-10
SLIDE 10

Defini#ons ¡ ¡

  • n ¡x ¡n ¡Adjacency ¡matrix ¡A. ¡

– A(i,j) ¡= ¡weight ¡on ¡edge ¡from ¡i ¡to ¡j ¡ – If ¡the ¡graph ¡is ¡undirected ¡A(i,j)=A(j,i), ¡i.e. ¡A ¡is ¡symmetric ¡

  • n ¡x ¡n ¡Transi>on ¡matrix ¡P. ¡

– P ¡is ¡row ¡stochas>c ¡ – P(i,j) ¡= ¡probability ¡of ¡stepping ¡on ¡node ¡j ¡from ¡node ¡i ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡A(i,j)/∑iA(i,j) ¡ ¡

  • n ¡x ¡n ¡Laplacian ¡Matrix ¡L. ¡

– L(i,j)=∑iA(i,j)-­‑A(i,j) ¡ – Symmetric ¡posi>ve ¡semi-­‑definite ¡for ¡undirected ¡graphs ¡ – Singular ¡

10

slide-11
SLIDE 11

11

Definitions

B E C A D

1 1 1 1 1 1 1 1 1 1 1 1 1 1

A=

Adjacency Matrix

B E C D A

1/2 1/2 1/3 1/3 1/3 1/4 1/4 1/4 1/4 1/2 1/2 1/3 1/3 1/3

P=

Transition Matrix

1/3 1/2 1/3 1/3 1/2 1/2 1/2 1/3 1/3 1/3 1/4 1/4 1/4 1/4

slide-12
SLIDE 12

12

Definitions

Graph Laplacian

L = D – A D D = diag(d)

B E C A D

A

1 1 1 1 1 1 1 1 1 1 1 1 1 1

D

2 3 4 2 3

L

2

  • 1
  • 1
  • 1

3

  • 1
  • 1
  • 1
  • 1

4

  • 1
  • 1
  • 1

2

  • 1
  • 1
  • 1
  • 1

3 A B C D E E D C B A

=

L

A B C D E E D C B A

A=

1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 2 3

d =

slide-13
SLIDE 13

13

Spectral Graph Analysis

Graph Laplacian

L = D – A D D = diag(d)

Take the eigendecomposition of L

B E C A D

A

1 1 1 1 1 1 1 1 1 1 1 1 1 1

D

2 3 4 2 3

L

2

  • 1
  • 1
  • 1

3

  • 1
  • 1
  • 1
  • 1

4

  • 1
  • 1
  • 1

2

  • 1
  • 1
  • 1
  • 1

3 A B C D E E D C B A

=

L

A B C D E E D C B A

A=

1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 2 3

d = =

L L

Λ

λ1 λ2 λ3 λ4 λ5 QT

Q

slide-14
SLIDE 14

Eigenvectors ¡

  • Intui>ve ¡defini>on: ¡ ¡An ¡eigenvector ¡is ¡a ¡

direc>on ¡for ¡a ¡matrix ¡

  • An ¡eigenvector ¡of ¡an ¡n ¡x ¡n ¡matrix ¡A ¡is ¡a ¡vector ¡

such ¡that ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡, ¡where ¡v ¡is ¡the ¡eigenvector ¡ and ¡λ ¡is ¡the ¡corresponding ¡eigenvalue ¡

– Mul>plying ¡vector ¡v ¡by ¡the ¡scalar ¡λ ¡effec>vely ¡ stretches ¡or ¡shrinks ¡the ¡vector ¡

  • An ¡n ¡x ¡n ¡matrix ¡should ¡have ¡n ¡linearly ¡

independent ¡eigenvectors ¡

Av v λ =

slide-15
SLIDE 15

Eigenvectors ¡Illustrated ¡

  • Consider ¡an ¡ellip>cal ¡data ¡cloud. ¡ ¡The ¡

eigenvectors ¡are ¡then ¡the ¡major ¡and ¡minor ¡ axes ¡of ¡the ¡ellipse ¡

slide-16
SLIDE 16

16

Spectral Graph Analysis

Λ

=

L L

λ1 λ2 λ3 λ4 λ5 q1 q2 q3 q5 q4 q1

T

q2

T

q3

T

q4

T

q5

T

Q QT

L

2

  • 1
  • 1
  • 1

3

  • 1
  • 1
  • 1
  • 1

4

  • 1
  • 1
  • 1

2

  • 1
  • 1
  • 1
  • 1

3 Eigenvector q1 is constant

Q

0.22

  • 0.27

0.5 0.65 0.45 0.22 0.65

  • 0.5

0.27 0.45

  • 0.89

0.00 0.00

  • 0.00

0.45 0.22 0.27 0.5

  • 0.65

0.45 0.22

  • 0.65
  • 0.5
  • 0.27

0.45

q1 q2 q3 q4 q5

E D C B A

Eigenvalue λ1 = 0

Λ

5.00 4.41 3.00 1.59 0.00 1 2 3 4 5

slide-17
SLIDE 17

17

Spectral Graph Analysis

q1 q2 q5 q10 q20 q50

Meshes provided by Gabriel Peyré

Λ

=

L L

λ1 λ2 λ3 λ4 λ5 q1 q2 q3 q5 q4 q1

T

q2

T

q3

T

q4

T

q5

T

Q QT

q1 q2 q1 q2

slide-18
SLIDE 18

Random ¡Walks ¡

Adjacency ¡matrix ¡A ¡

18

Transition matrix P

1 1 1 1 1 1/2 1/2 1

slide-19
SLIDE 19

What ¡is ¡a ¡random ¡walk ¡

19

1 1/2 1/2 1

t=0

slide-20
SLIDE 20

What ¡is ¡a ¡random ¡walk ¡

20

1 1/2 1/2 1 1 1/2 1/2 1

t=0 t=1

slide-21
SLIDE 21

What ¡is ¡a ¡random ¡walk ¡

21

1 1/2 1/2 1 1 1/2 1/2 1

t=0 t=1

1 1/2 1/2 1

t=2

slide-22
SLIDE 22

What ¡is ¡a ¡random ¡walk ¡

22

1 1/2 1/2 1 1 1/2 1/2 1

t=0 t=1

1 1/2 1/2 1

t=2

1 1/2 1/2 1

t=3

slide-23
SLIDE 23

Probability ¡Distribu>ons ¡

  • ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡probability ¡that ¡the ¡surfer ¡is ¡at ¡node ¡i ¡at ¡>me ¡t ¡
  • ¡ ¡
  • ¡ ¡
  • What ¡happens ¡when ¡the ¡surfer ¡walks ¡for ¡a ¡long ¡>me? ¡23

φ(t)

i

φ(t+1)

i

= X

j

φ(t)

i

× Pr(j → i)

φ(t+1)

i

= φ(t)

i

× P = φ(t−1)

i

× P × P = φ(t−2)

i

× P × P × P · · · = φ(0)

i

× P t

slide-24
SLIDE 24

Sta>onary ¡Distribu>on ¡

  • When ¡the ¡surfer ¡keeps ¡walking ¡for ¡a ¡long ¡>me ¡
  • When ¡the ¡distribu>on ¡does ¡not ¡change ¡anymore ¡

– i.e. ¡ ¡

  • For ¡“well-­‑behaved” ¡graphs ¡this ¡does ¡not ¡depend ¡
  • n ¡the ¡start ¡distribu>on!! ¡

24

φ(t+1) = φ(t)

slide-25
SLIDE 25

What ¡is ¡a ¡sta>onary ¡distribu>on? ¡ ¡ Intui>vely ¡and ¡Mathema>cally ¡

25

slide-26
SLIDE 26

What ¡is ¡a ¡sta>onary ¡distribu>on? ¡ ¡ Intui>vely ¡and ¡Mathema>cally ¡

  • The ¡sta>onary ¡distribu>on ¡at ¡a ¡node ¡is ¡related ¡to ¡the ¡amount ¡of ¡

>me ¡a ¡random ¡walker ¡spends ¡visi>ng ¡that ¡node. ¡

26

slide-27
SLIDE 27

What ¡is ¡a ¡sta>onary ¡distribu>on? ¡ ¡ Intui>vely ¡and ¡Mathema>cally ¡

  • The ¡sta>onary ¡distribu>on ¡at ¡a ¡node ¡is ¡related ¡to ¡the ¡amount ¡of ¡

>me ¡a ¡random ¡walker ¡spends ¡visi>ng ¡that ¡node. ¡

  • Remember ¡that ¡we ¡can ¡write ¡the ¡probability ¡distribu>on ¡as ¡

27

φ(t+1) = φ(t) × P

slide-28
SLIDE 28
  • The ¡sta>onary ¡distribu>on ¡at ¡a ¡node ¡is ¡related ¡to ¡the ¡amount ¡of ¡

>me ¡a ¡random ¡walker ¡spends ¡visi>ng ¡that ¡node. ¡

  • Remember ¡that ¡we ¡can ¡write ¡the ¡probability ¡distribu>on ¡as ¡
  • For ¡the ¡sta>onary ¡distribu>on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡we ¡have ¡

¡

φ(∞)

What ¡is ¡a ¡sta>onary ¡distribu>on? ¡ ¡ Intui>vely ¡and ¡Mathema>cally ¡

28

φ(t+1) = φ(t) × P φ(∞) = φ(∞) × P

slide-29
SLIDE 29

What ¡is ¡a ¡sta>onary ¡distribu>on? ¡ ¡ Intui>vely ¡and ¡Mathema>cally ¡

  • The ¡sta>onary ¡distribu>on ¡at ¡a ¡node ¡is ¡related ¡to ¡the ¡amount ¡of ¡

>me ¡a ¡random ¡walker ¡spends ¡visi>ng ¡that ¡node. ¡

  • Remember ¡that ¡we ¡can ¡write ¡the ¡probability ¡distribu>on ¡as ¡
  • For ¡the ¡sta>onary ¡distribu>on ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡we ¡have ¡
  • Whoa! ¡that’s ¡just ¡the ¡le[ ¡eigenvector ¡of ¡the ¡transi>on ¡matrix! ¡

29

φ(t+1) = φ(t) × P φ(∞) = φ(∞) × P

φ(∞)

slide-30
SLIDE 30

30

Power ¡Method ¡

(Horn ¡& ¡Johnson, ¡1985) ¡

  • P ¡has ¡a ¡unique ¡le[ ¡eigenvector ¡

– Called ¡the ¡Perron ¡vector ¡ ¡ ¡ ¡

¡

Power ¡method ¡to ¡compute ¡ ¡

1: set φ(0) to be a normalized nonnegative random vector 2: set i = 0 3: loop until φ(0), φ(1), . . . , φ(i−1), φ(i) converges 4: set φ(i+1) = Pφ(i) 5: normalize φ(i+1) 6: i++ 7: end loop 8: return φ(i)

φ(∞) φ(∞)

slide-31
SLIDE 31

Interes>ng ¡Ques>ons ¡

  • Does ¡a ¡sta>onary ¡distribu>on ¡always ¡

exist? ¡Is ¡it ¡unique? ¡

– Yes, ¡if ¡the ¡graph ¡is ¡“well-­‑behaved”. ¡

31

slide-32
SLIDE 32

Well-­‑behaved ¡graphs ¡

  • Irreducible: ¡There ¡is ¡a ¡path ¡from ¡every ¡node ¡to ¡every ¡other ¡
  • node. ¡

¡ ¡

32

Irreducible Not irreducible

slide-33
SLIDE 33

Well-­‑behaved ¡graphs ¡

  • Aperiodic: ¡The ¡GCD ¡of ¡all ¡cycle ¡lengths ¡is ¡1. ¡The ¡GCD ¡is ¡also ¡

called ¡period. ¡ ¡ ¡

33

Aperiodic Periodicity is 3

slide-34
SLIDE 34

Implica>ons ¡of ¡the ¡Perron ¡Frobenius ¡Theorem ¡

  • If ¡a ¡Markov ¡chain ¡is ¡irreducible ¡and ¡aperiodic ¡then ¡

the ¡largest ¡eigenvalue ¡of ¡the ¡transi>on ¡matrix ¡will ¡be ¡ equal ¡to ¡1 ¡and ¡all ¡the ¡other ¡eigenvalues ¡will ¡be ¡ strictly ¡less ¡than ¡1. ¡

– Let ¡the ¡eigenvalues ¡of ¡P ¡be ¡{σi| ¡i=0:n-­‑1} ¡in ¡non-­‑increasing ¡

  • rder ¡of ¡σi ¡. ¡

– σ0 ¡= ¡1 ¡> ¡σ1 ¡> ¡σ2 ¡>= ¡……>= ¡σn ¡

34

slide-35
SLIDE 35

Implica>ons ¡of ¡the ¡Perron ¡Frobenius ¡Theorem ¡

  • If ¡a ¡Markov ¡chain ¡is ¡irreducible ¡and ¡aperiodic ¡then ¡

the ¡largest ¡eigenvalue ¡of ¡the ¡transi>on ¡matrix ¡will ¡be ¡ equal ¡to ¡1 ¡and ¡all ¡the ¡other ¡eigenvalues ¡will ¡be ¡ strictly ¡less ¡than ¡1. ¡

– Let ¡the ¡eigenvalues ¡of ¡P ¡be ¡{σi| ¡i=0:n-­‑1} ¡in ¡non-­‑increasing ¡

  • rder ¡of ¡σi ¡. ¡

– σ0 ¡= ¡1 ¡> ¡σ1 ¡> ¡σ2 ¡>= ¡……>= ¡σn ¡

  • These ¡results ¡imply ¡that ¡for ¡a ¡well-­‑behaved ¡graph ¡

there ¡exists ¡an ¡unique ¡sta>onary ¡distribu>on. ¡

35

slide-36
SLIDE 36

Google’s ¡PageRank ¡

  • PageRank ¡is ¡a ¡“vote” ¡by ¡all ¡other ¡webpages ¡

about ¡the ¡importance ¡of ¡a ¡page ¡

  • A ¡link ¡to ¡a ¡page ¡counts ¡as ¡a ¡vote ¡of ¡support ¡
  • PageRank ¡uses ¡a ¡random ¡surfer ¡model ¡

– Occasionally, ¡the ¡surfer ¡gets ¡bored ¡and ¡jumps ¡to ¡a ¡ random ¡other ¡page ¡

  • “The ¡25,000,000,000 ¡Eigenvector: ¡ ¡the ¡Linear ¡

Algebra ¡Behind ¡Google” ¡

slide-37
SLIDE 37

37

Random ¡Walk ¡on ¡Web ¡Graph ¡

  • Probability ¡transi>on ¡matrix ¡given ¡by ¡
  • Use ¡a ¡telepor>ng ¡random ¡walk ¡(Page ¡et ¡al., ¡1998) ¡to ¡

ensure ¡that ¡the ¡graph ¡is ¡strongly ¡connected ¡and ¡ aperiodic: ¡

P = D−1A

Pu,v = Au,v dout

u

= Au,v Pn

v=1 Au,v

Pteleport = ηP + (1 − η)11T − I |V |

slide-38
SLIDE 38

PageRank ¡

38