trying to calculate the returnability of a network after every iteration

4 vues (au cours des 30 derniers jours)
Nicolle Small
Nicolle Small le 6 Avr 2021
Réponse apportée : Zinea le 23 Fév 2024
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.

Réponses (1)

Zinea
Zinea le 23 Fév 2024
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.

Catégories

En savoir plus sur Networks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by