Info
This question is closed. Reopen it to edit or answer.
How can I track the total number of node infections from a set of random seed nodes each? I tried using the v = bfsearch(G,s) command but I got an error report: Error using search (line 27) Starting node must specify one node.
2 views (last 30 days)
Show older comments
clear all
load('nodenetwork.mat');
network = A;
N=size(network,1);
beta=0.12;
gama=0.3;
deadline=20;
flag=zeros(1,N);
bnet=graph(network);
k=randperm(N);
randnodes=randsample(k,4);
flag(randnodes)=1;
for i=1:N
if flag(i)==1
%infect its neighbor
neighbor=find(network(i,:)==1);
for j=1:length(neighbor)
pinf=rand();
if (pinf>=beta)&&(flag(neighbor(j))==0)
flag(neighbor(j))=1;
end
speff=bfsearch(bnet, randnodes);
end
%rocovered
precv=rand();
if (precv>=gama) && (pinf < beta)
flag(i)=2;
network(i,:)=0;
network(:,i)=0;
end
end
end
%the number of S
S=length(find(flag==0));
%the number of I
I=length(find(flag==1));
%the number of R
R=length(find(flag==2));
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!