Electrical current from stopped random-walk traversals (source code)

= Electrical current from stopped random-walk traversals
{title2=$i(x,y)=w_{xy}(G(s,x)/w_x-G(s,y)/w_y)$}

In a finite connected <electrical network>, run the conductance <random walk> from $s$ until its first visit to a distinct vertex $t$. Let $G(s,x)$ be the expected visits to $x$ before stopping, and $w_x=\sum_yw_{xy}$. The expected signed number of traversals of $\{x,y\}$ is the displayed expression. Its divergence is $\mathbf1_{x=s}-\mathbf1_{x=t}$ by telescoping each path, and its resistance-weighted sum around a cycle is zero because $G(s,x)/w_x$ is a voltage. Uniqueness follows by summing $\sum_{\{x,y\}}w_{xy}(v_x-v_y)^2$: a zero-divergence voltage flow has zero energy. Thus the expected net traversals are exactly the unit source-to-sink current.