trying to calculate the returnability of a network after every iteration
1 次查看(过去 30 天)
显示 更早的评论
i have a network which i am doing multiple calculations for. however the main one is the returnabilty using ths formula,
returnability = (trace(expm(AT))-n)/(trace(expm(A))-n);
however with my network, i have removed every edge and added them back randomly using this coding,
AT = triu(A);
m = numedges(G);
n = numnodes(G);
[i,j]=find(AT);
p = randperm(m);
for k = 1:m
I = j(p(k));
J = i(p(k));
AT(I,J) = 1;
end
where A is the adjacency matrix for the network.
The main thing i am struggling with is after each iteration of an edge being added i want to calculate the returnability. i know i will need a loop but i am not sure how to code it up.
any help/advice would be appreciated a lot.
0 个评论
回答(1 个)
Zinea
2024-2-23
You want to calculate the returnability using the given formula after each iteration of edge addition to the graph. For this, you need to incorporate 2 specific changes in your code:
1. Initialize a vector to store returnability values for each iteration. Add this line at the before the start of the loop.
returnability_values = zeros(m, 1);
2. Calculate the returnability for this iteration. Add this line just before the ‘end’ statement.
returnability = (trace(expm(AT)) - n) / (trace(expm(A)) - n);
returnability_values(edge_index) = returnability;
The vector ‘returnabillity_values’ contains the returnability after each iteration.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!