#%autoindent import math,sys from collections import deque from lslib import read_link_stream,get_graph_neighborhood,get_graph_neighborhood_plus,ls_dist from graphlib import graph_dist_sigma # Volume operations. def plusvol((q,d),(q_,d_)): q = float(q) q_ = float(q_) if d==d_: return (q+q_,d) elif d>d_: return (q,d) return (q_,d_) def minusvol(v,(q,d)): q = float(q) return(plusvol(v,(-q,d))) def divvol((q,d),(q_,d_)): q = float(q) q_ = float(q_) if d==d_: return float(q)/float(q_) assert dt N_prime = get_graph_neighborhood(L,t_prime) N_plus = get_graph_neighborhood_plus(L,t) # process nodes w reachable at t_prime from (i,u) in increasing order of distance for w in reachable[t_prime]: # compute distances and sigma in the graph G_t^+, used in the formulae... (d_wplus,sigma_wplus) = graph_dist_sigma(N_plus,w) # ...and apply the formulae for x in d_wplus: if (t_prime,x) in Dist and (t,x) in Dist and (t_prime,w) in Dist and Dist[(t,x)]+d_wplus[x] == Dist[(t_prime,w)]: vol[(t_prime,w)] = plusvol(vol.get((t_prime,w),(0.,0)), timesvol(vol.get((t,x),(0.,0)), (sigma_wplus[x]*(t_prime-t)**d_wplus[x]/math.factorial(d_wplus[x]),d_wplus[x]))) for y in N_prime.get(w,[]): if (t_prime,y) in Dist and Dist[(t_prime,w)] == Dist[(t_prime,y)]+1: vol[(t_prime,w)] = plusvol(vol.get((t_prime,w),(0.,0)),vol.get((t_prime,y),(0.,0))) t = t_prime # result return vol.get((j,v),(0.,0))