next up previous index
Next: How does one measure Up: Uniform Random Integer Generation Previous: Random Walk on n   Index

Random walk on a regular graph

A graph is defined by the pair of sets $(\X,E)$, $E \subset \X\times \X$, $X$ are called the vertices, E are called the edges. The graphs are unoriented and can have loops.

Random walk on a graph is defined as:

\begin{displaymath}K(x,y)=\left\{ \begin{array}{ll}
\frac{1}{d(x)} & (x,y) \in E, \; d(x)=degree(x)\\
0 & (x,y) \notin E
\end{array} \right.\end{displaymath}

Example 1 - The triangle:

\begin{displaymath}
K=\left [\begin {array}{ccc} 0&1/2&1/2\\ \noalign{\medskip }...
...8&1/4&3/8\\ \noalign{\medskip }3/8&3/8&1/4\end {array}\right ]
\end{displaymath}


\begin{displaymath}
K^6=
\left [\begin {array}{ccc} {\frac {11}{32}}&{\frac {21}...
...}{128}}&{\frac {43}{128}}&{\frac {21}{64}}\end {array}\right ]
\end{displaymath}

Here are the matlab commands to create the transition matrix and it's powers:

K=(1/2)*(ones(3)-diag(ones(3,1)))
K =
         0    0.5000    0.5000
    0.5000         0    0.5000
    0.5000    0.5000         0
>> K2=K*K
K2 =
    0.5000    0.2500    0.2500
    0.2500    0.5000    0.2500
    0.2500    0.2500    0.5000
>> K3=K2*K
K3 =
    0.2500    0.3750    0.3750
    0.3750    0.2500    0.3750
    0.3750    0.3750    0.2500
K7 =
    0.3281    0.3359    0.3359
    0.3359    0.3281    0.3359
    0.3359    0.3359    0.3281

>> sum(abs(K7(1,:)-(1/3)*ones(1,3)))
ans =
    0.0104

Example 2 - The Bucky Ball:
http://21net.com/difference/bucky100.htm

Figure 5.1: The Bucky Ball
\begin{figure}\psfig{figure=/home/susan/b494/bucky.ps} \end{figure}

With Matlab:
Try the slide show buckydem and look at the incidence/adjacency matrix $B$ created by:

[B V]= bucky;
Bu=(1/3)*B;
$Bu$ will be the transition matrix for the random walk on the graph.

We want to run experiments to find out how many steps an ant walking along the edges of the graph at random has to take in order to `get lost'.

Then we want to consider high powers of the transition matrix.

We write a little matlab function that does that:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function P=powermat(K,n)
%Computes the 2^n power of K
%powermat(K,n) outputs matrix or sparse
%according to K's form
prod=K;
for i=2:n
prod=prod*prod;
end
P=prod;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dist(Bu,(1/60)*ones(1,60),60)
ans =
    0.9500
>> B4=powermat(Bu,4);
>> B4(1,:)
ans =
   (1,1)       0.0925
   (1,2)       0.0183
   (1,3)       0.0544
   (1,4)       0.0544
   (1,5)       0.0183
   (1,6)       0.0101
   (1,7)       0.0663
   (1,8)       0.0183
   (1,9)       0.0183
.................
   (1,53)      0.0034
   (1,54)      0.0012
   (1,55)      0.0003
   (1,56)      0.0003
   (1,57)      0.0009
   (1,58)      0.0009
   (1,59)      0.0003

dist(B4,(1/60)*ones(1,60),60)
ans =
    0.4435

>> B7=powermat(Bu,7);
>> B7(1,:)
ans =
   (1,1)       0.0169
   (1,2)       0.0169
   (1,3)       0.0168
   (1,4)       0.0168
   (1,5)       0.0169
   (1,6)       0.0169
   (1,7)       0.0168
   (1,8)       0.0168
   (1,9)       0.0168
   (1,10)      0.0168
   (1,11)      0.0168
   (1,12)      0.0168
   (1,13)      0.0167
   (1,14)      0.0167
   (1,15)      0.0168
......
   (1,54)      0.0165
   (1,55)      0.0165
   (1,56)      0.0165
   (1,57)      0.0165
   (1,58)      0.0165
   (1,59)      0.0165
   (1,60)      0.0164

>> dist(B7,(1/60)*ones(1,60),60)
ans =
    0.0034

next up previous index
Next: How does one measure Up: Uniform Random Integer Generation Previous: Random Walk on n   Index
Susan Holmes 2002-01-12