31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

11.24 Markov Chains ( markov chain )<br />

1. Definition<br />

We consider a Markov Chain to be a graph G in which each edge has an associated nonnegative<br />

integer weight w[e]. For every node (with at least one outgoing edge) the total<br />

weight of the outgoing edges must be positive A random walk in a Markov chain starts<br />

at some node s and then performs steps according to the following rule:<br />

Initially, s is the current node. Suppose node v is the current node and that e 0 , . . . , e d−1<br />

are the edges out of v. If v has no outgoing edge no further step can be taken. Otherwise,<br />

the walk follows edge e i with probability proportional to w[e i ] for all i, 0 ≤ i < d. <strong>The</strong><br />

target node of the chosen edge becomes the new current node.<br />

#include < <strong>LEDA</strong>/graph/markov chain.h ><br />

2. Creation<br />

markov chain M(const graph& G, const edge array& w, node s = nil);<br />

creates a Markov chain for the graph G with edge weights w. <strong>The</strong><br />

node s is taken as the start vertex (G.first node( ) if s is nil).<br />

3. Operations<br />

void M.step(int T = 1) performs T steps of the Markov chain.<br />

node M.current node( ) returns current vertex.<br />

int M.current outdeg( ) returns the outdegree of the current vertex.<br />

int<br />

M.number of steps( ) returns number of steps performed.<br />

int M.number of visits(node v)<br />

double M.rel freq of visit(node v)<br />

returns number of visits to node v.<br />

returns number of visits divided by the total number<br />

of steps.

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

Saved successfully!

Ooh no, something went wrong!