03.12.2012 Views

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

C++ for Scientists - Technische Universität Dresden

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.4. GOOGLE’S PAGE RANK 275<br />

Taking the new refinements into account we can compute the importance score xk of a page k<br />

as follows:<br />

xk = � xj<br />

(14.4)<br />

nj<br />

j∈Lk<br />

Where Lk denotes the set of pages with a link to page k. Consider the simple example of Figure<br />

14.2. Using the <strong>for</strong>mula (14.4) we get the following equations <strong>for</strong> the importance scores of the<br />

pages in this example:<br />

x1 = x3 + x4<br />

2<br />

x2 = x1<br />

3<br />

x3 = x1<br />

3<br />

x4 = x1<br />

3<br />

+ x2<br />

2<br />

+ x2<br />

2<br />

+ x4<br />

2<br />

These linear equations can be written as Ax = x where x = [x1 x2 x3 x4] T and<br />

⎡<br />

⎤<br />

A =<br />

⎢<br />

⎣<br />

0 0 1 1<br />

2<br />

1<br />

3 0 0 0<br />

1<br />

3<br />

1<br />

3<br />

1 1<br />

2 0 2<br />

1<br />

2 0 0<br />

This trans<strong>for</strong>ms the web ranking problem into the standard problem of finding an eigenvector<br />

x with eigenvalue 1 <strong>for</strong> the square matrix A. This eigenvector can be found iteratively using<br />

the power method with a threshold τ:<br />

The power method converges to the eigenvector corresponding to the dominant eigenvalue λ1.<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

1. v (0) = some vector with � v (0) �= 1<br />

2. Repeat <strong>for</strong> k=1,2, . . . :<br />

2.1. Apply A: w = Av (k−1) .<br />

2.2. Normalize: v (k) = w/ � w �.<br />

3. Until �v (k−1) − v (k) � < τ<br />

The matrix A is called a column stochastic matrix, since it is a square matrix with positive<br />

entries and the entries in each column sum to one. In the case of a column stochastic matrix,<br />

this dominant eigenvalue is 1.<br />

14.4.1 Software<br />

Write a generic function:<br />

template <br />

void power iteration( V& v, Function & f, double tau ) ;<br />

that computes the power iteration algorithm 5 <strong>for</strong> a matrix A with starting vector v. The<br />

resulting eigenvector should be stored in v. The argument f is a functor that returns the result<br />

of the matrix vector product. Also write documentation and specify the conceptual constraints<br />

<strong>for</strong> the arguments.<br />

⎥<br />

⎦ .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!