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!