Clear Filters
Clear Filters

trying to calculate the returnability of a network after every iteration

2 views (last 30 days)
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.

Answers (1)

Zinea
Zinea on 23 Feb 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.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!