Broadcast Information within a network
이전 댓글 표시
Hello community, I have a complex network (graph), I want to randomly pick one node and let the node broadcast information through the network based on the average distance of the network. Can some please help....I've no idea how to implement this. Graph data set (Power Grid) can be downloaded from http://www-personal.umich.edu/~mejn/netdata/. Below is my code for reading and ploting the graph.
%Extracting edges from gml file graph
fileName = 'power.gml';
inputfile = fopen(fileName);
Edges=[];
l=0;
k=1;
while 1
% Get a line from the input file
tline = fgetl(inputfile);
% Quit if end of file
if ~ischar(tline)
break
end
nums = regexp(tline,'\d+','match');
if length(nums)
if l==1
l=3;
Edges(k,2)=str2num(nums{1});
k=k+1;
continue;
end
Edges(k,1)=str2num(nums{1});
l=1;
else
l=0;
continue;
end
end
Edges = Edges+1;
NewEdge = Edges;
%Edges(:,1:2) = sort(Edges(:,1:2));
Edges = unique(Edges(:,1:2),'rows','stable');
G = graph(Edges(:,1), Edges(:,2)); % create a graph from A
deg = degree(G);
figure % visualize the graph
plot(G);
title('Power Grid, Before Movement')
NewEdge = NewEdge(randperm(size(NewEdge,1)),:); % <-- Optional --
nodesize = numnodes(G);
size = nodesize;
not = [];
x = [];
for c = 1:size
[P,d] = shortestpath(G,c,nodesize);
if d == Inf
not = [not, d];
else
x = [x, d];
end
end
LongestShortestPath = max(x)
disp('Before Change');
AverageDistance = mean(x)
AverageDegree = mean(deg)
댓글 수: 2
Walter Roberson
2018년 10월 16일
What does it mean to "broadcast information" in your network?
Isaac Osei Agyemang
2018년 10월 16일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Networks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!