In [74]:
using PyPlot
include("utils.jl")
using DiffusionTutorialUtilities
utils = DiffusionTutorialUtilities
A,xy = utils.load_graph_and_coords("newman-netsci")
utils.cgraphplot(A,xy,filled=false)
Out[74]:
In [75]:
include("diffusions.jl")
using DiffusionAlgorithms
In [76]:
lam1 = real(eigs(A)[1][1])
Out[76]:
In [77]:
function single_seed_katz(A,alpha,lam1,seed)
n = size(A,1)
@assert 1 <= seed <= n
v = zeros(size(A,1))
v[seed] = (1.-alpha)
x = (eye(n) - alpha*(1/lam1)*A) \ v
end
x = single_seed_katz(A,0.85,lam1,1)
utils.graphplot(A,xy)
scatter(xy[:,1],xy[:,2],400*x+5,400*x,edgecolor="None",cmap="inferno")
Out[77]:
In [78]:
using Interact
In [79]:
n = size(A,1)
f = figure()
@manipulate for alpha=0:0.01:0.99, seed=1:n; withfig(f) do
x = single_seed_katz(A,alpha,lam1,seed)
utils.graphplot(A,xy)
scatter(xy[:,1],xy[:,2],25*max(log(n*x),0.25),max(log(n*x),0),edgecolor="None",cmap="inferno")
axis("off")
colorbar()
#clim([0,sqrt(n)])
end
end
Out[79]:
In [11]:
close("all")
In [81]:
include("diffusions.jl")
include("utils.jl")
using DiffusionAlgorithms
using DiffusionTutorialUtilities
A,xy = utils.load_graph_and_coords("newman-netsci");
n = size(A,1)
# chebyshev point set of alphas
N=15; alphas = [0.999,0.995,0.99,0.95,0.9,0.85,0.8,0.75,0.66,0.5,0.25,0.1]
@manipulate for alpha=alphas, seed=1:n
@time x = DiffusionAlgorithms.single_seed_katz_power(A,alpha,lam1,seed)
@show extrema(x), 1/n
@show "here"
utils.cgraphplot(A,xy,0.05*log(1/minimum(x)*x),log(1/minimum(x)*x),utils._inferno_data)
end
Out[81]:
In [83]:
include("diffusions.jl")
include("utils.jl")
using DiffusionAlgorithms
using DiffusionTutorialUtilities
A,xy = utils.load_graph_and_coords("U3A");
lam1 = real(eigs(A)[1][1])
n = size(A,1)
# chebyshev point set of alphas
alphas = ([0.999,0.995,0.99,0.95,0.9,0.85,0.8,0.75,0.66,0.5,0.25,0.1,0.01,0.001])
@manipulate for alpha=alphas, seed=1:n
@time x = DiffusionAlgorithms.single_seed_katz_power(A,alpha,lam1,seed)
@show extrema(x)
@show "done alpha=$(alpha), seed=$(seed)"
utils.cgraphplot(A,xy,0.1*log(1/(max(minimum(x),1.e-12))*x),log(x+1.e-12),
utils._inferno_data)
end
Out[83]:
In [70]:
include("diffusions.jl")
include("utils.jl")
using DiffusionAlgorithms
using DiffusionTutorialUtilities
A,xy = utils.load_graph_and_coords("U3A");
lam1 = real(eigs(A)[1][1])
# chebyshev point set of alphas
alphas = ([0.999,0.995,0.99,0.95,0.9,0.85,0.8,0.75,0.66,0.5,0.25,0.1,0.01,0.001])
f = figure()
@manipulate for alpha=0:0.01:0.99, seed=1:n; withfig(f) do
@time x = DiffusionAlgorithms.single_seed_katz_power(A,alpha,lam1,seed)
semilogy(sort(x))
ylim([1.e-16,1])
end
end
Out[70]:
In [43]:
@time x = DiffusionAlgorithms.single_seed_katz_power(A,0.999,lam1,1)
Out[43]: