Network Analysis Graphs as Matrices - Michele Coscia · Graphs as Network Analysis Matrices Michele...

Post on 19-Aug-2020

13 views 0 download

Transcript of Network Analysis Graphs as Matrices - Michele Coscia · Graphs as Network Analysis Matrices Michele...

Network Analysis

Graphs as Matrices

Michele Coscia & Luca RossiITU København

Background:

Background:

Looking at a problem from a different

perspective

Sergey Brin & Larry Page

(1973-)

55 Million!

55 Million!

PageRank

PageRank● p of visiting v…

PageRank● p of visiting v…● … = p of visiting a neighbor u of v *

p of going from u to v

PageRank● p of visiting v…● … = p of visiting a neighbor u of v *

p of going from u to v● for v in V…

PageRank● p of visiting v…● … = p of visiting a neighbor u of v *

p of going from u to v● for v in V…● 55 million times!

PageRankG = (V, E)

PageRankG = (V, E) A = 1 if uv in E

PageRankG = (V, E) A = 1 if uv in E

PageRankG = (V, E) A = 1 if uv in E

PageRank

for v in V...

G = (V, E) A = 1 if uv in E

PageRank

for v in V... R := AR

G = (V, E) A = 1 if uv in E

~

PageRank

for v in V... R := AR

G = (V, E) A = 1 if uv in E

~

Row-normalized A

PageRank

for v in V... R := AR

G = (V, E) A = 1 if uv in E

~

Row-normalized A

Eigenvectorof A

Random Walks

Basics

A B C D E FA

B

C

D

E

F

A B

Basics

A B C D E FA

B

C

D

E

F

Do youknow each

other?

A B

Basics

A B C D E FA

B

C

D

E

F

Do youknow each

other?

A B

Yes! Yes!

Basics

A B C D E FA

B

C

D

E

F

Do youknow each

other?

A B

Yes! Yes!

X

X

Basics

Basics

1 2 3 4 5 6 7 8 9

Basics

1 2 3 4 5 6 7 8 9123456789

Basics

1 2 3 4 5 6 7 8 9123456789

Basics

1 2 3 4 5 6 7 8 9123456789

Basics

1 2 3 4 5 6 7 8 9123456789

Basics

1 2 3 4 5 6 7 8 9123456789

Basics

1 2 3 4 5 6 7 8 9123456789

Adjacency Matrix

Properties of Adjacency Matrices

Properties of Adjacency Matrices

3

Properties of Adjacency Matrices

3

3

2

1

Properties of Adjacency Matrices

Stochastic Adjacency

A B C D E FA

B

C

D

E

F

AX X X

Stochastic Adjacency

A B C D E FA

B

C

D

E

F

Pick oneof your friends

at random

AX X X

Stochastic Adjacency

A B C D E FA

B

C

D

E

F

Pick oneof your friends

at random

A

Mmm…E!

X X X

Stochastic Adjacency

Stochastic Adjacency● p of going from

v to u

Stochastic Adjacency● p of going from

v to u

● A / A.sum(axis = 1)

Stochastic Adjacency● p of going from

v to u

● A / A.sum(axis = 1)

Stochastic Adjacency● p of going from v

to u

● A / A.sum(axis = 1)

● Useful eigen-properties

Walk Probabilities

Walk Probabilities

Walk Probabilities

Walk Probabilities

Walk Probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

Walk probabilities

p(1→2) in two steps?

Walk probabilities

p(1→2) in two steps?

(p(1→5) * p(5→2)) + (p(1→9) * p(9→2))

Walk probabilities

p(1→2) in two steps?

(p(1→5) * p(5→2)) + (p(1→9) * p(9→2))

p(u→v)?

Powers of Stochastic

A

Powers of Stochastic

A

Powers of Stochastic

A

Powers of Stochastic

A A2

Powers of Stochastic

A A2

Powers of Stochastic

A A2

Powers of Stochastic

A A2

Powers of Stochastic

A A2

Powers of Stochastic

Powers of Stochastic

Powers of Stochastic

Powers of Stochastic

Powers of Stochastic

1

Powers of Stochastic

Powers of Stochastic

Powers of Stochastic

A2

A2

A2 A3

A2 A30

Stationary Distribution

Stationary Distribution● A∞ = π

Stationary Distribution● A∞ = π

Stationary Distribution● A∞ = π

● πA = π

Stationary Distribution● A∞ = π

● πA = π

● ~ PageRank

Disconnected Mazes

Disconnected Mazes

Disconnected Mazes

Disconnected Mazes

?

Disconnected Mazes

?

Multiple Components

A

Multiple Components

A30

Multiple Components

A30

Multiple Components

A30

Multiple Components

A30

Multiple Components

A30

Google’s Solution

Google’s Solution

Google’s Solution

Beamme up,Scotty!

Google’s Solution

Google’s Solution

A

Google’s Solution

A

Google’s Solution

A+ε

Stationary Distribution vs Degree

Stationary Distribution vs Degree

Stationary Distribution vs Degree

Corr = 1

Stationary Distribution vs Degree

Corr = 1π = k / k.sum()

Stationary Distribution vs PageRank

Stationary Distribution vs PageRank

Stationary Distribution vs PageRank

Stationary Distribution vs PageRank

Stationary Distribution vs PageRank

Graph Spectrum

A Recap on Eigenvectors

v

(x, y)

A Recap on Eigenvectors

v

w = Av

(x’, y’)

(x, y)

A Recap on Eigenvectors

v

w = Av

(x’, y’)(λx, λy)

(x, y)

A Recap on Eigenvectors

v

w = Av

(x’, y’)

w = Av = λv

(λx, λy)

(x, y)

A Recap on Eigenvectors

v

w = Av

(x’, y’)

w = Av = λv

(λx, λy)

Eigenvector

(x, y)

A Recap on Eigenvectors

v

w = Av

(x’, y’)

w = Av = λv

(λx, λy)

Eigenvector

Eigenvalue

(x, y)

Right & Left

Av = λv

Right & Left

Av = λv Right Eigenvector

Right & Left

Av = λv Right Eigenvector

Right & Left

Av = λv

vA = vλ

Right Eigenvector

Right & Left

Av = λv

vA = vλ

Right Eigenvector

Left Eigenvector

Right & Left

Av = λv

vA = vλ

Right Eigenvector

Left Eigenvector

Right & Left

Av = λv

vA = vλ

Right Eigenvector

Left Eigenvector

Right & Left

Av = λv

vA = vλ

Right Eigenvector

Left Eigenvector

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

λ1

Eigenvalues & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

λ1

λ2

Eigenvalues & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvalues & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvalues & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvectors

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvectors

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

v1 v

2 v

3 … v

n-2 v

n-1 v

n

Eigenvectors

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

v1 v

2 v

3 … v

n-2 v

n-1 v

n

“Largest” Eigenvector

Eigenvectors

vi

a

b

c

d

e

f

g

h

i

l

m

n

o

Eigenvectors

vi

a

b

c

d

e

f

g

h

i

l

m

n

o

Eigenvectors

vi

a

b

c

d

e

f

g

h

i

l

m

n

o

Eigenvectors

vi

a

b

c

d

e

f

g

h

i

l

m

n

o

Eigenvectors

vi

a

b

c

d

e

f

g

h

i

l

m

n

o

Eigenvectors & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

λ1

λ2

Eigenvectors & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

λ1

λ2

v1 v

2

Eigenvectors & Components

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

If both equal to 1Graph has two components

λ1

λ2

v1 v

2

a

a

a

a

a

a

0

0

0

0

0

0

0

0

0

b

b

b

Eigenvectors & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

Eigenvectors & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

v1

Eigenvectors & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

v1

λ1

Eigenvectors & Components

λ1 > λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

v1

a

a

a

a

a

a

a

a

a

λ1

Left Largest Eigenvector

Left Largest Eigenvector

Left Largest Eigenvector

Left Largest Eigenvector

vL1 = π

Left Largest Eigenvector

vL1 = π

πA = π

Left Largest Eigenvector

vL1 = π

πA = π

πA = π1

Left Largest Eigenvector

vL1 = π

πA = π

πA = π1

λ1

Left Largest Eigenvector

vL1 = π

πA = π

πA = π1

λ1

Left & Right

Left & RightvL

1

Left & RightvL

1

Left & RightvL

1

v1

a

a

a

a

a

a

a

a

a

Left & RightvL

1

vR1

v1

a

a

a

a

a

a

a

a

a

Left & RightvL

1

vR1 A

Left & RightvL

1

vR1 AT

Left & RightvL

1

vR1 AT

A / A.sum(axis = 0)

Left & Right

AT

A / A.sum(axis = 0)

Left & Right

AT

A / A.sum(axis = 0)

vL1

vR1

Graph Laplacian

Degree Matrix

Degree MatrixZeros everywhere

Degree MatrixZeros everywhere

i-th diagonal element...

Degree MatrixZeros everywhere

i-th diagonal element... … is the degree of node i

Degree MatrixZeros everywhere

i-th diagonal element... … is the degree of node i

D

Laplacian Matrix

D A

Laplacian Matrix

D AL = -

Laplacian Matrix

L = D - A

Laplacian Matrix

L = D - A

Laplacian Matrix

L = D - A

Laplacian Matrix

L = D - A

0

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

A

L

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

A

L λ1 ≤ λ

2 ≤ λ

3 ≤ … ≤ λ

n-2 ≤ λ

n-1 ≤ λ

n

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

A

L λ1 ≤ λ

2 ≤ λ

3 ≤ … ≤ λ

n-2 ≤ λ

n-1 ≤ λ

n

0

Eigenvalues

λ1 ≥ λ

2 ≥ λ

3 ≥ … ≥ λ

n-2 ≥ λ

n-1 ≥ λ

n

1

A

L λ1 ≤ λ

2 ≤ λ

3 ≤ … ≤ λ

n-2 ≤ λ

n-1 ≤ λ

n

0

# of 0s = # of components

Eigenvectors

Eigenvectors

v1

Eigenvectors

v1

a

a

a

a

a

a

a

a

a

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

.37

.37

.28

.28

.12

-.23

-.38

-.38

-.43

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

.37

.37

.28

.28

.12

-.23

-.38

-.38

-.43

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

.37

.37

.28

.28

.12

-.23

-.38

-.38

-.43

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

.37

.37

.28

.28

.12

-.23

-.38

-.38

-.43

Eigenvectors

v1

a

a

a

a

a

a

a

a

av

2

.37

.37

.28

.28

.12

-.23

-.38

-.38

-.43

Eigenvectors

Eigenvectors

+

Eigenvectors

+-

Eigenvectors

Eigenvectors

2nd Eigenvector

Eigenvectors

2nd Eigenvector

3rd Eigenvector

Eigenvectors

Eigenvectors

Eigenvectors

Textbook Chapters● Adjacency Matrix

– Section 2.4● Stochastic, Graph Spectrum &

Laplacian– http://www.michelecoscia.com/?

page_id=1488● Done with Chapter 2!

– Section 2.11