trying to calculate the returnability of a network after every iteration

1 回表示 (過去 30 日間)
Nicolle Small
Nicolle Small 2021 年 4 月 6 日
回答済み: Zinea 2024 年 2 月 23 日
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.

回答 (1 件)

Zinea
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_valuescontains the returnability after each iteration.

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by